Foxtable(狐表)用户栏目专家坐堂 → 限制了一样的不能导入,不起效果,请老师帮忙看看


  共有2162人关注过本帖树形打印复制链接

主题:限制了一样的不能导入,不起效果,请老师帮忙看看

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/4 9:15:00 [显示全部帖子]

不理解你的问题,你要实现什么功能?我测试可以导入数据。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/4 11:00:00 [显示全部帖子]

Dim dlg As new OpenFileDialog
    dlg.Filter = "Excel文件|*.xls"
    Dim fl As String
    If dlg.ShowDialog = DialogResult.OK Then
        fl = dlg.FileName
        Vars("rz")=True
        Dim dic As Dictionary(Of String ,String)
        'Dim cmd As new SQLCommand
        'cmd.CommandText = "select * From {khda}"
        'Dim dt As DataTable = cmd.ExecuteReader(True)
        Dim book As new XLS.Book(fl)
        Dim sheet As XLS.Sheet = book.Sheets("sheet1")
        If sheet(0,1).Value<>"品名" Then
            msgbox("第一列品名不匹配")
            Return
        End If
        If sheet(0,2).Value<>"封装" Then
            msgbox("第二列封装不匹配")
            Return
        End If
        DataTables("销售").StopRedraw()
        Dim bz As Integer=0
        Dim d As Double
        Dim nms() As String = {"品名","封装","数量","单价","金额","仓库","区域","电话","备注"}
        For n As Integer = 1 To Sheet.Rows.Count -1
            If Sheet(n,1).Value=""
                Exit For
            End If
            Dim filter As String
            Dim filter1 As String
            If Sheet(n,2).Value Is Nothing Then
                filter = "品名 ='" & Sheet(n,1).Value.Replace("*", "[*]").Replace("'", "''").Replace("%", "[%]")  & "' and 封装 Is null and 单价=" & Sheet(n,4).Value & " And (仓库<>'现货' or 仓库 is null)"
                filter1 = "品名 ='" & Sheet(n,1).Value.Replace("*", "[*]").Replace("'", "''").Replace("%", "[%]")   & "' and 封装 Is null and (仓库<>'现货'  or 仓库 is null)"
               
            Else
                filter = "品名 ='" & Sheet(n,1).Value.Replace("*", "[*]").Replace("'", "''").Replace("%", "[%]")   & "' and 封装='" & Sheet(n,2).Value  &"' And 单价=" & Sheet(n,4).Value & " And (仓库<>'现货'  or 仓库 is null)"
                filter1 = "品名 ='" & Sheet(n,1).Value.Replace("*", "[*]").Replace("'", "''").Replace("%", "[%]") &"'   And 封装='" & Sheet(n,2).Value  &"' And (仓库<>'现货'  or 仓库 is null)"
            End If
            'For Each pc As DataRow In DataTables("销售").Select("品名='" & Sheet(n,1).Value.Replace("*", "[*]").Replace("'", "''").Replace("%", "[%]") &"' And 封装='" & Sheet(n,2).Value &"' and (仓库<>'现货'  or 仓库 is null)")
            Dim pc As DataRow = DataTables("销售").find(filter)
            'If (pc("单价")-Sheet(n,4).Value)>0  Or pc Is Nothing
            If pc Is Nothing
                Dim dr As DataRow =  DataTables("销售").AddNew()
                For m As Integer = 0 To nms.Length-1
                   
                    Select Case m
                        Case 0,1
                            dr(nms(m)) = Sheet(n,m+1).Value.trim().replace(chr(10), "").replace(chr(13), "")
                        Case 2,3,4
                            If Sheet(n,m+1).Value=""  Or Sheet(n,m+1).Value.trim="" Then
                            Else
                                If Double.TryParse(Sheet(n,m+1).Value, d)
                                    dr(nms(m)) = Sheet(n,m+1).Value
                                Else
                                    msgbox("行"& n & "列" & m+1 & "显示为" &Sheet(n,m+1).Value & "不是数值,记住后,请更改")
                                End If
                            End If
                        Case Else
                            dr(nms(m)) = Sheet(n,m+1).Value
                           
                    End Select
                Next
                dr.save
                Sheet(n,13).Value  ="导入成功"
               
               
                book.Save(fl)
                Dim zd As Integer
                Dim dj As Long=0
                Do While DataTables("销售").Select(filter1).Count>3
                    For Each cf As DataRow In DataTables("销售").Select(filter1)
                        If dj<cf("单价")
                            dj=cf("单价")
                            zd=cf("_identify")
                        End If
                    Next
                    DataTables("销售").DeleteFor("_identify='" & zd &"'")
                Loop
            Else
                Sheet(n,13).Value  ="重复未导入!!"
            End If
        Next
        DataTables("销售").Save
        'DataTables("销售").DeleteFor("品名 is null")
        'DataTables("销售").Save
        Tables("销售").ResumeRedraw()
        msgbox("导入完成!!")
        Tables("销售").Sort="仓库"
        DataTables("销售").LoadFilter=""
        DataTables("销售").load

        Vars("rz")=False
    Else
        Return
    End If


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/4 11:36:00 [显示全部帖子]

你这段代码,要实现什么功能?删除单价大于dj变量的行?

 

If DataTables("销售").Select(filter1).Count>3 Then

    DataTables("销售").DeleteFor("单价 > " & dj & " and " & filter1)

End If


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/7/4 12:22:00 [显示全部帖子]

 

If DataTables("销售").Select(filter1).Count>3 Then

    Dim fdr As DataRow = DataTables("销售").find(filter1, "单价 desc")

    fdr.delete

End If

 


 回到顶部