老师,下面代码能简化吗?请指教,谢谢!
初始不加载任何数据
Dim ary() As String = Functions.Execute("Xueqi")
cmd.C
cmd.CommandText = "select * F rom {教工基本信息} Where 教工编号 = '" & e.Form.Controls("教工编号").Text & "' And 离职日期 Is Null"
dt = cmd.ExecuteReader(True) '记得将参数设置为True
If dt.DataRows.Count = 0 Then
Dim max As String = DataTables("教工基本信息").SQLCompute("Max(教工编号)","教工编号 Like '" & ary(2) & "%'")
If max = "" Then
e.Form.Controls("教工编号").text= ary(2) & "01"
Else
Dim v As Integer = max.SubString(6,2)
e.Form.Controls("教工编号").text= ary(2) & format(v +1,"00")
End If
dr = DataTables("教工基本信息").AddNew()
dr("录入人") = _UserXingming
dr("录入日期") = Format(Date.Now,"yyyy-MM-dd")
dr("教工编号") = e.Form.Controls("教工编号").text
dr("教工姓名") = e.Form.Controls("教工姓名").text
dr("进本校日期") = e.Form.Controls("进本校日期").text
dr("手机号码") = e.Form.Controls("手机号码").text
dr("党派") = e.Form.Controls("党派").text
dr("民族") = e.Form.Controls("民族").text
dr("学历") = e.Form.Controls("学历").text
dr("专业") = e.Form.Controls("专业").text
dr("身份证号码") = e.Form.Controls("身份证号码").text
dr("毕业日期") = e.Form.Controls("毕业日期").text
dr("毕业院校") = e.Form.Controls("毕业院校").text
dr("资格证号码") = e.Form.Controls("资格证号码").text
dr("资格证类别") = e.Form.Controls("资格证类别").text
dr("职称") = e.Form.Controls("职称").text
dr("籍贯") = e.Form.Controls("籍贯").text
dr("家庭住址") = e.Form.Controls("家庭住址").text
dr("履历") = e.Form.Controls("履历").text
dr("特长") = e.Form.Controls("特长").text
Tables("教工基本信息").Save()
Else If dt.DataRows.Count > 0 Then
dr = dt.DataRows(0)
dr("教工编号") = e.Form.Controls("教工编号").text
dr("教工姓名") = e.Form.Controls("教工姓名").text
dr("进本校日期") = e.Form.Controls("进本校日期").text
dr("手机号码") = e.Form.Controls("手机号码").text
dr("党派") = e.Form.Controls("党派").text
dr("民族") = e.Form.Controls("民族").text
dr("学历") = e.Form.Controls("学历").text
dr("专业") = e.Form.Controls("专业").text
dr("身份证号码") = e.Form.Controls("身份证号码").text
dr("毕业日期") = e.Form.Controls("毕业日期").text
dr("毕业院校") = e.Form.Controls("毕业院校").text
dr("资格证号码") = e.Form.Controls("资格证号码").text
dr("资格证类别") = e.Form.Controls("资格证类别").text
dr("职称") = e.Form.Controls("职称").text
dr("籍贯") = e.Form.Controls("籍贯").text
dr("家庭住址") = e.Form.Controls("家庭住址").text
dr("履历") = e.Form.Controls("履历").text
dr("特长") = e.Form.Controls("特长").text
dr("修改人") = _UserXingming
dr("修改日期") = Format(Date.Now,"yyyy-MM-dd")
dt.Save()
End If