If User.Group = "经理" Then
Dim jzr1 As String = Tables("客户").Current("客户名称")
Dim cnt1 As Integer = DataTables("日常业务").SQLCompute("Count(业务编号)","客户名称 = '" & jzr1 & "' And 已办结 = 0")
If cnt1 >= 1 Then '如果未办结业务
MessageBox.Show("此客户有未办结业务?先进行业务办结,再停用客户!", "提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
With Tables("客户")
If .Current IsNot Nothing Then
.Current.Reject()
End If
End With
Forms("客户增加窗口").Close()
Dim Filter1 As String = "客户名称 = '" & jzr1 & "' And 已办结 = 0"
DataTables("日常业务").LoadFilter = Filter1
DataTables("日常业务").Load()
MainTable = Tables("日常业务")'在此加入相应的代码
Forms("业务办理主窗口").Open()
Else
Dim jg1 As DialogResult
jg1 = MessageBox.Show("确定要停用此客户吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If jg1 = DialogResult.Yes Then
Tables("客户").Current("停用人") = User.Name
Tables("客户").Current("停用时间") = Date.Today()
Tables("客户").Current("停用") = True
Tables("客户").Current("VIP") = False
Dim jg3 As DialogResult
jg3 = MessageBox.Show("现在将终止此客户全部合同,确定要继续吗?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
If jg3 = DialogResult.Yes Then
Dim jzr2 As String = Tables("客户").Current("客户名称")
Dim Filter2 As String = "客户名称 = '" & jzr2 & "'"
DataTables("主合同").LoadFilter = Filter2
DataTables("主合同").Load()
Dim drs As List(of DataRow) = DataTables("主合同").Select(Filter2) '获得此客户所有合同
For Each dr As DataRow In drs
If dr("已终止") = False Then '如果此合同没有锁定且未终止
DataTables("合同附件之代理明细").LoadFilter = dr("合同编号")
DataTables("合同附件之代理明细").Load()
Dim mxs As List(of DataRow) = DataTables("合同附件之代理明细").Select(dr("合同编号")) '获得此合同所有明细
For Each mx As DataRow In mxs
If mx("已终止") = False Then '如果此合同明细没有锁定且未终止
mx("已终止") = True
Tables("合同附件之代理明细").Save()
End If
Next
dr("已终止") = True
Tables("主合同").Save()
End If
Next
Tables("客户").Save()
MessageBox.Show("客户停用成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
With Tables("客户")
If .Current IsNot Nothing Then
.Current.Reject()
End If
End With
End If
Else
Tables("客户").Current("停用") = False
Tables("客户").Current("停用人") = Nothing
Tables("客户").Current("停用时间") = Nothing
End If
End If
Else
MessageBox.show("你无停用客户权限!")
End If
代码运行错误,如下:
此主题相关图片如下:2.png
麻烦老师帮忙修改一下,哪里出错了,我实在是无能为力了!如果有可能的话(自己感觉有点啰嗦),将代码精简一下,十分感谢!