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条件中不加身份证件号有同班有可能存在同姓问题,这怎么解决更好。