需求通过后台数据更新的方式将“派发工序表”的数据插入到“Fa_Gz”表,照着帮助写了下面代码,请指正
If usna="admin" Then
Dim Result As DialogResult
Result = MessageBox.Show("联系管理员对接资料,确定要对接员工计件薪资吗?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim dt1 As DataTable
Dim cmd1 As New SQLCommand
cmd1.C
cmd1.CommandText = "Select * F rom {派发工序表} Where 订单号 = "'" & Tables("派发工序表_table2").current("订单号") &"' And 单据状态 = "已完成"
For Each dr As DataRow In dt1.DataRows
Dim dt2 As DataTable
Dim cmd2 As New SQLCommand
cmd2.C
cmd2.CommandText = "Select * F rom {Fa_Gz} Where PQID = "'" & CInt(dr("鼎邦制单数ID")) &"' And Art_No = " & CInt(dr("工序号")) & " and zano = '" & CInt(dr("箱号")) & "'
dt2 = cmd2.ExecuteReader(True)
For Each nr As DataRow In dt2.DataRows
If nr Is Nothing Then
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = cmd.CommandText & " INSERT INTO Fa_Gz (实际生产员工, indate,Num,扫码人,Art_No,订单号,indatetwo,PQID,manno,monmoney) VALUES (dr(实际生产员工), dr(扫码时间),dr(件数),dr(扫码人),dr(工序号),dr(箱号),dr(订单号),dr(扫码时间),dr(鼎邦制单数ID),dr(实际生产员工工号),dr(基本工价),br("基本工价")*br("工价系数")*br("件数"))
cmd.ExecuteNonQuery
End If
Next
Next
End If
Else
MessageBox.show("你无权执行此项操作!")
End If