Dim dr As DataRow = DataTables("POS机库存资料").Find("机具条码='" & e.Form.Controls("jijutiaoma").text & "'")
If dr Is Nothing Then
msgbox("没有查到符合条件的数据,请核实机具是否入库!")
Return
ElseIf dr.IsNull("商户ID") = False Then
msgbox("该机具已经被其他商户占用,不能重复绑定!请核实机具条码!")
Return
End If
Dim sr As String
Dim dr1 As Table = Tables("商户资料表")
If dr1.Current.Isnull("机具ID") Then
dr("商户ID") = dr1.Current("商户ID")
dr("商户名称") = dr1.Current("商户名称")
dr("客户ID") = dr1.Current("客户ID")
dr("客户姓名") = dr1.Current("法人姓名")
dr("机具是否绑定") = True
dr1.Current("机具ID")=dr("机具ID")
dr1.Current("机具条码")=dr("机具条码")
sr = dr1.Current.DataRow.OriginalValue("机具条码")
Dim lsjl As DataRow = DataTables("POS机绑定商户历史记录表").Find("机具条码='" & sr & "' and 解绑日期 is null")
If lsjl Is Nothing Then
lsjl = DataTables("POS机绑定商户历史记录表").addnew
lsjl("机具ID") =dr("机具ID")
lsjl("机具条码") =dr("机具条码")
lsjl("机具类型") =dr("机具类型")
lsjl("机具型号") =dr("机具型号")
lsjl("所属仓库") =dr("所属仓库")
lsjl("商户ID") =dr1.Current("商户ID")
lsjl("商户名称") =dr1.Current("商户名称")
lsjl("客户ID") =dr1.Current("客户ID")
lsjl("客户姓名") =dr1.Current("法人姓名")
lsjl("绑定日期") =Date.Today
End If
DataTables("POS机库存资料"). Save
DataTables("POS机绑定商户历史记录表"). Save '
msgbox(dr("商户名称") & "机具成功绑定商户 ")
e.Form.Controls("jijutiaoma").text =Nothing
e.Form.Controls("jijutiaoma").Enabled= False
e.Form.Controls("jijuzhuangtaixiegai").Enabled=True
e.Form.Controls("jijubangding").Enabled=False
e.Form.Controls("jijujiebang").Enabled= False
Else
Dim dlg = MessageBox.Show("该商户已经绑定其他机具,是否解绑后重新绑定新机具,单击是解绑后重新绑定,单击否则添加新商户并绑定到新增的商户,单击取消放弃操作", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)
If dlg = DialogResult.Yes Then
For Each fdr As DataRow In DataTables("POS机库存资料").Select("机具ID='" & dr1.Current("机具ID") & "'")
fdr("商户ID") = Nothing
fdr("商户名称") = Nothing
fdr("客户ID") = Nothing
fdr("客户姓名") = Nothing
fdr("机具是否绑定") = False
Next
dr("商户ID") = dr1.Current("商户ID")
dr("商户名称") = dr1.Current("商户名称")
dr("客户ID") = dr1.Current("客户ID")
dr("客户姓名") = dr1.Current("法人姓名")
dr("机具是否绑定") = True
dr1.Current("机具ID")=dr("机具ID")
dr1.Current("机具条码")=dr("机具条码")
sr = dr1.Current.DataRow.OriginalValue("机具条码")
Dim lsjl As DataRow = DataTables("POS机绑定商户历史记录表").Find("机具条码='" & sr & "' and 解绑日期 is null")
If lsjl IsNot Nothing Then
lsjl ("解绑日期") =Date.Today
lsjl = DataTables("POS机绑定商户历史记录表").addnew
lsjl("机具ID") =dr("机具ID")
lsjl("机具条码") =dr("机具条码")
lsjl("机具类型") =dr("机具类型")
lsjl("机具型号") =dr("机具型号")
lsjl("所属仓库") =dr("所属仓库")
lsjl("商户ID") =dr1.Current("商户ID")
lsjl("商户名称") =dr("商户名称")
lsjl("客户ID") =dr("客户ID")
lsjl("客户姓名") =dr("客户姓名")
lsjl("绑定日期") =Date.Today 这句代码那有问题呢?如果窗体打开后给已经绑定机具的商户如果连续解绑再重新重新绑定的新机具时,第一次运行正常,第二次以及以后各次“POS机绑定商户历史记录表”中已经解绑的机具“解绑日期”不赋值,必须把窗体关闭重启后才能正常,如果是新绑定的机具立即解绑重新绑定机具也是同样的结果。甜老师看看哪错了?
Else
lsjl = DataTables("POS机绑定商户历史记录表").addnew
lsjl("机具ID") =dr("机具ID")
lsjl("机具条码") =dr("机具条码")
lsjl("机具类型") =dr("机具类型")
lsjl("机具型号") =dr("机具型号")
lsjl("所属仓库") =dr("所属仓库")
lsjl("商户ID") =dr1.Current("商户ID")
lsjl("商户名称") =dr("商户名称")
lsjl("客户ID") =dr("客户ID")
lsjl("客户姓名") =dr("客户姓名")
lsjl("绑定日期") =Date.Today
End If
DataTables("POS机库存资料"). Save
DataTables("POS机绑定商户历史记录表"). Save
msgbox(dr("商户名称") & "机具成功绑定商户 ")
e.Form.Controls("jijutiaoma").text =Nothing
e.Form.Controls("jijutiaoma").Enabled= False
e.Form.Controls("jijuzhuangtaixiegai").Enabled=True
e.Form.Controls("jijubangding").Enabled=False
e.Form.Controls("jijujiebang").Enabled= False
ElseIf dlg = DialogResult.No
'新增加的代码
Dim tbl As Table =Tables("商户资料表")
sr = dr1.Current.DataRow.OriginalValue("机具条码")
Dim lsjl As DataRow = DataTables("POS机绑定商户历史记录表").Find("机具条码='" & sr & "' and 解绑日期 is null")
Dim sr1 As Row = tbl.Current
Dim nr As DataRow = tbl.DataTable.addnew
nr("通道名称") = sr1("通道名称")
nr("网点地址") = sr1("网点地址")
nr("商户名称") = sr1("商户名称")
nr("网点名称") = sr1("网点名称")
nr("网点编号") = sr1("网点编号")
nr("备注") = sr1("备注")
nr("商户照片") = sr1("商户照片")
nr("商户编号") = sr1("商户编号")
nr("客户ID") = sr1("客户ID")
nr("法人姓名") = sr1("法人姓名")
dr("商户ID") = nr("商户ID")
dr("商户名称") = nr("商户名称")
dr("客户ID") = nr("客户ID")
dr("客户姓名") = nr("法人姓名")
dr("机具是否绑定") = True
nr("机具ID")=dr("机具ID")
nr("机具条码")=dr("机具条码")
If lsjl IsNot Nothing Then
lsjl = DataTables("POS机绑定商户历史记录表").addnew
lsjl("机具ID") =dr("机具ID")
lsjl("机具条码") =dr("机具条码")
lsjl("机具类型") =dr("机具类型")
lsjl("机具型号") =dr("机具型号")
lsjl("所属仓库") =dr("所属仓库")
lsjl("商户ID") =dr("商户ID")
lsjl("商户名称") =dr1.Current("商户名称")
lsjl("客户ID") =dr1.Current("客户ID")
lsjl("客户姓名") =dr1.Current("法人姓名")
lsjl("绑定日期") =Date.Today
End If
DataTables("POS机库存资料"). Save
DataTables("POS机绑定商户历史记录表"). Save '
msgbox("该机具成功绑定商户 ")
End If
End If
[此贴子已经被作者于2017/10/18 14:00:22编辑过]