Foxtable(狐表)用户栏目专家坐堂 → 导入问题


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

主题:导入问题

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


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
导入问题  发帖心情 Post By:2017/3/1 20:43:00 [只看该作者]

Dim xxmc As String = user.group
Dim oDocument2 As object = axWebBrowser2.Gettype().InvokeMember("Document", System.Reflection.BindingFlags.GetProperty, Nothing, axWebBrowser2, Nothing)
Dim oApplication2 As object = axWebBrowser2.Gettype().InvokeMember("Application", System.Reflection.BindingFlags.GetProperty, Nothing, oDocument2, Nothing)
oDocument2.save
Dim Book As New XLS.Book(e.Form.Controls("label1").text)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim bj1 As Integer
Dim xm1 As Integer
Dim bsm1 As Integer
Dim sfzjh1 As Integer
Dim csrq As Integer = -1
Dim p As WinForm.ProgressBar
p = e.Form.Controls("ProgressBar1")
p.Maximum = sheet.Rows.Count-1 '设置最大值
p.Minimum = 0 '设置最小值
p.Value = 0 '设置当前值
For i As Integer = 0 To sheet.Cols.count -1
    If sheet(0,i).value = "班级"
        bj1 =i
    End If
    If sheet(0,i).value = "学生姓名"
        xm1 = i
    End If
    If sheet(0,i).value = "身份证件号"
        sfzjh1 = i
    End If
    If sheet(0,i).value ="出生日期"
        csrq = i
    End If
Next
Tables("学生信息").StopRedraw()
For n As Integer = 1 To Sheet.Rows.Count -1
    Dim bj As String = sheet(n,bj1).value.replace(" ","").replace(chr(9),"")
    Dim xm As String = sheet(n,xm1).value.replace(" ","").replace(chr(9),"")
    Dim sfzjh As String = sheet(n,sfzjh1).value.replace(" ","").replace(chr(9),"")
    Dim dr As DataRow = DataTables("学生信息").sqlFind("班级 = '" & bj & "'and 学校名称 = '" & xxmc & "' And 学生姓名 = '" & xm & "' and 身份证件号 = '" & sfzjh & "'")
    If dr Is Nothing Then '如果不存在同考号的行
        dr =  DataTables("学生信息").AddNew()
    End If
    For m As Integer = 0 To sheet.Cols.count -1
        If m = csrq
            dr(sheet(0,m).value) = Nothing
        Else
            dr(sheet(0,m).value) = Sheet(n,m).Value.replace(" ","").replace(chr(9),"")
            dr("状态") = "在读:原籍在读"
            If dr("学校名称") = ""
            dr("学校名称") = xxmc
            End If
        End If
    Next
p.Value = n
Next
Tables("学生信息").ResumeRedraw()
For Each r As Row In Tables("学生信息").Rows
    For Each c As Col In Tables("学生信息").Cols
        If r.IsNull(c.Name) =  False AndAlso c.IsString Then
            r(c.Name) = r(c.Name).replace(" ","")
            r(c.Name) = r(c.Name).replace(chr(9),"")
        End If
    Next
Next
DataTables("学生信息").DataCols("身份证件号").RaiseDataColChanged()
DataTables("学生信息").save()
e.Form.close

Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.cSELE  CT DIS 学校名称, 年级, 班级  From {学生信息} where 学校名称 = '" & xxmc & "'"
dt = cmd.ExecuteReader()
Dim trv As WinForm.TreeView = Forms("学生信息").Controls("TreeView1")
trv.BuildTree(dt,"学校名称|年级|班级")

 

 

老师,你好,我上面的代码有两个问题请教

一、我是想如果找到记录则覆盖,如果除班级,学生姓名,学校名称,身份证件号其他字段有变化则按新值覆盖。

二、find条件中不加身份证件号有同班有可能存在同姓问题,这怎么解决更好。


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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/3/1 21:54:00 [只看该作者]

1、

 

Dim ary() As String = {"班级", "学生姓名", "学校名称", "身份证件号"}

If Array.IndexOf(ary, dr(sheet(0,m).value)) < 0 Then

    dr(sheet(0,m).value) = Sheet(n,m).Value.replace(" ","").replace(chr(9),"")

End If

 

2、sqlFind改成sqlSelect,看有多少行,如果大于1行,就在备注列,备注成重复,然后手工处理。

 


 回到顶部