|
楼主 |
发表于 2011-12-10 10:48:20
|
显示全部楼层
河北省沧州市
Private Sub Imgok_Click() '确定
Select Case i
Case 1
If Text1 = "" Then
MsgBox "号码不能为空", 4, "成品管理系统"
Text1.SetFocus
Exit Sub
End If
If Combo1.Text = "" Then
MsgBox "规格不能为空", 4, "成品管理系统"
Combo1.SetFocus
Exit Sub
End If
If DTPicker1.Value = "" Then
MsgBox "日期不能为空", 4, "成品管理系统"
DTPicker1.SetFocus
Exit Sub
End If
cnn.Execute ("insert into 成品档案 values ('" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Combo1 & "','" & Combo2 & "','" & Text4 & "','" & Text5 & "','" & Text6 & "','" & Text7 & "','" & DTPicker1.Value & "','" & cmnj & "','" & cmbx & "','" & cmyd & "','" & cmbf & "')")
If cmyd.Text = "是" Then '是否降级
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from 成品降级表", adoCon, adOpenKeyset, adLockOptimistic
rs1.AddNew
rs1.Fields("炉批号") = Text1.Text
rs1.Fields("喷标号") = Text2.Text
rs1.Fields("内部号") = Text3.Text
rs1.Fields("时间") = DTPicker1.Value
rs1.Fields("降级原因") = " "
rs1.Fields("经手人") = " "
rs1.Fields("备注") = " "
rs1.Update
rs1.Close
End If
If cmbf.Text = "是" Then '是否报废
Dim rs2 As New ADODB.Recordset
rs2.Open "select * from 车辆报废表", adoCon, adOpenKeyset, adLockOptimistic
rs2.AddNew
rs2.Fields("车牌号码") = Text1.Text
rs2.Fields("报废原因") = " "
rs2.Fields("报废日期") = DTPicker1.Value
rs2.Fields("经手人") = " "
rs2.Fields("备注") = " "
rs2.Update
rs2.Close
End If
MsgBox "记录添加成功!", 4, "成品管理系统"
Adodc1.Refresh
Case 2
cnn.Execute ("update 成品档案 set 喷标号='" & Text2 & "',内部号='" & Text3 & "',规格='" & Combo1 & "',材质='" & Combo2 & "',米长='" & Text4 & "',重量='" & Text5 & "',合同号='" & Text7 & "',垛位='" & Text7 & "',交库日期='" & DTPicker1.Value & "',涂油否='" & cmnj.Text & "',平头否='" & cmbx.Text & "',降级否='" & cmyd.Text & "',报废否='" & cmbf.Text & "' where 车牌号码='" & Text1 & "'")
If cmyd.Text = "否" Then
' Dim rs1 As New ADODB.Recordset
rs1.Open "select * from 成品降级表 where 炉批号='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
rs1.Delete
rs1.Update
rs1.Close
End If
ElseIf cmyd.Text = "是" Then '是否异动
rs1.Open "select * from 成品降级表 where 炉批号 ='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount = 0 Then
rs1.AddNew
rs1.Fields("车牌号码") = Text1.Text
rs1.Fields("异动时间") = DTPicker1.Value
rs1.Fields("异动地点") = " "
rs1.Fields("经手人") = " "
rs1.Fields("备注") = " "
rs1.Update
rs1.Close
End If
End If
If cmbf.Text = "是" Then '是否报废
' Dim rs2 As New ADODB.Recordset
rs2.Open "select * from 成品报废表 where 炉批号 ='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
If rs2.RecordCount = 0 Then
rs2.AddNew
rs2.Fields("车牌号码") = Text1.Text
rs2.Fields("报废原因") = " "
rs2.Fields("报废日期") = DTPicker1.Value
rs2.Fields("经手人") = " "
rs2.Fields("备注") = " "
rs2.Update
rs2.Close
End If
ElseIf cmbf.Text = "否" Then
rs2.Open "select * from 成品降级表 where 炉批号 ='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
If rs2.RecordCount > 0 Then
rs2.Delete
rs2.Update
rs2.Close
End If
End If
MsgBox "记录修改成功!", , "成品管理系统"
Adodc1.Refresh
End Select
Lockctl
Imgok.Enabled = False: Imgcancel.Enabled = False
Imgadd.Enabled = True: Imgupdate.Enabled = True
Imgdelete.Enabled = True: Adodc1.Enabled = True
End Sub |
|