控件事件没有其他代码了,控件绑定了表格,表事件DataColChanged代码只有这个:
If e.DataCol.Name = "项目名称" Then
Dim nms()As String = {"合同编码","所属机构","合同金额"}
If e.NewValue Is Nothing Then
For Each nm As String In nms
e.DataRow(nm)= Nothing
Next
Else
Dim c md As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.C ommandText = "S ELECT DISTINCT 合同编码,所属机构,项目名称,合同金额 From {合同签订} where [项目名称]= '" & e.NewValue & "'"
dt = cmd.ExecuteReader()
If dt.datarows.count > 0
Dim dr As DataRow = dt.datarows(0)
For Each nm As String In nms
e.DataRow(nm)= dr(nm)
Next
End If
End If
End If
If e.DataRow("付款金额") >= "30000" Then
If e.DataCol.Name = "供货方名称" OrElse e.DataCol.Name = "付款金额" Then
Dim nms()As String = {"供货方账号","供货方开户银行"}
If e.NewValue Is Nothing Then
For Each nm As String In nms
e.DataRow(nm)= Nothing
Next
Else
If e.DataRow("供货方名称") <> Nothing Then
Dim c md As New SQLCommand
Dim dt As DataTable
cmd.C
'cmd.C ommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
cmd.C ommandText = "S ELECT DISTINCT 项目名称,供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "' and [项目名称] = '" & e.DataRow("项目名称") & "'"
dt = cmd.ExecuteReader()
If dt.datarows.count > 0 Then
Dim dr As DataRow = dt.datarows(0)
For Each nm As String In nms
e.DataRow(nm)= dr(nm)
Next
e.DataRow("是否签订采购合同") = True
Else
e.DataRow("供货方名称") = Nothing
e.DataRow("是否签订采购合同") = False
MessageBox.Show("该供应商还未签订供应合同,不能办理委托支付事宜!","提示",MessageBoxButtons.OK,MessageBoxIcon.None)
Return
End If
End If
End If
End If
Else
Dim nmw()As String = {"供货方账号","供货方开户银行"}
Dim c md As New SQLCommand
Dim dt As DataTable
cmd.C
'cmd.C ommandText = "S ELECT DISTINCT 供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "'"
cmd.C ommandText = "S ELECT DISTINCT 项目名称,供货方名称,供货方账号,供货方开户银行 From {采购合同管理} where [供货方名称]= '" & e.NewValue & "' and [项目名称] = '" & e.DataRow("项目名称") & "'"
dt = cmd.ExecuteReader()
If dt.datarows.count > 0 Then
Dim dr As DataRow = dt.datarows(0)
For Each nm As String In nmw
e.DataRow(nm)= dr(nm)
Next
e.DataRow("是否签订采购合同") = True
End If
End If
而且只有一个项目会有这种情况,其他项目没这样的情况
[此贴子已经被作者于2022/9/19 10:19:11编辑过]