📄 frm_kcgl_scll.frm
字号:
Text1(8).Text = rs6.Fields("wlxx_wldw")
Text1(9).Text = rs6.Fields("wlxx_wlsl")
Text1(10).Text = Val(Text1(5).Text) * Val(Text1(9).Text)
End If
rs6.Close
End Sub
Private Sub Cbx_wlbh_GotFocus()
Cbx_Wlbh.BackColor = &HFFFF80
End Sub
Private Sub Cbx_wlbh_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text1(6).SetFocus
End Sub
Private Sub Cbx_wlbh_LostFocus()
Cbx_Wlbh.BackColor = &HFFFFFF
rs3.Open "select * from tb_SCGL_wlxx where wlxx_id='" + Cbx_Wlbh.Text + "'", cnn, adOpenKeyset
If rs3.RecordCount > 0 Then
Text1(6).Text = rs3.Fields("wlxx_wlmc")
Text1(7).Text = rs3.Fields("wlxx_wlgg")
Text1(8).Text = rs3.Fields("wlxx_wldw")
Text1(9).Text = rs3.Fields("wlxx_wlsl")
Text1(10).Text = Val(Text1(5).Text) * Val(Text1(9).Text)
End If
rs3.Close
rs7.Open "select sum(scll_llsl) from tb_SCGL_scll where scll_scjhd='" + Cbx_Scjhd + "' and scll_wlbh='" + Cbx_Wlbh + "'", cnn, adOpenKeyset
If rs7.RecordCount > 0 Then
If IsNull(rs7.Fields(0)) Then
Text1(11).Text = 0
Else
Text1(11).Text = rs7.Fields(0)
End If
End If
rs7.Close
Myrs.Open "select * from tb_SCGL_wlxx where wlxx_id='" + Cbx_Wlbh.Text + "' and wlxx_cpbh='" + Text1(1).Text + "' ", cnn, adOpenKeyset
If Myrs.RecordCount <= 0 Then
MsgBox "输入的物料编号不正确,或该产品没有相应的物料信息!", , "信息提示"
Cbx_Wlbh.ListIndex = 0
Cbx_Wlbh.SetFocus
Myrs.Close
Exit Sub
End If
Myrs.Close
End Sub
Private Sub Dgr_Scll_Click()
view_data
End Sub
Private Sub Dtp_llrq_GotFocus()
Dtp_llrq.CalendarBackColor = &HFFFF80
End Sub
Private Sub Dtp_llrq_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text1(14).SetFocus
End Sub
Private Sub Dtp_llrq_LostFocus()
Dtp_llrq.CalendarBackColor = &HFFFFFF
End Sub
Private Sub Form_Activate()
Adodc1.ConnectionString = PublicStr
If sql <> "" Then
Adodc1.RecordSource = sql & " order by scll_id"
Adodc1.Refresh
Call view_data '调用过程
If Adodc1.Recordset.RecordCount = 0 Then
MsgBox "没有找到符合条件的记录!", , "提示窗口"
End If
End If
Call Dgr_Title
End Sub
Sub Dgr_Title()
Dgr_Scll.Columns(0).Caption = "领料单编号"
Dgr_Scll.Columns(1).Caption = "生产计划单"
Dgr_Scll.Columns(2).Caption = "产品编号"
Dgr_Scll.Columns(3).Caption = "产品名称"
Dgr_Scll.Columns(4).Caption = "产品规格"
Dgr_Scll.Columns(5).Caption = "产品单位"
Dgr_Scll.Columns(6).Caption = "产品数量"
Dgr_Scll.Columns(7).Caption = "物料编号"
Dgr_Scll.Columns(8).Caption = "物料名称"
Dgr_Scll.Columns(9).Caption = "物料规格"
Dgr_Scll.Columns(10).Caption = "物料单位"
Dgr_Scll.Columns(11).Caption = "单位需求量"
Dgr_Scll.Columns(12).Caption = "物料数量"
Dgr_Scll.Columns(13).Caption = "已领数量"
Dgr_Scll.Columns(14).Caption = "领料数量"
Dgr_Scll.Columns(15).Caption = "未领数量"
Dgr_Scll.Columns(16).Caption = "领料日期"
Dgr_Scll.Columns(17).Caption = "备注信息"
End Sub
Private Sub Form_Load()
Dim rs2 As New ADODB.Recordset
rs2.Open "select * from tb_SCGL_scjhd where scjhd_jhsl <> 0", cnn, adOpenKeyset
If rs2.RecordCount > 0 Then
For i = 0 To rs2.RecordCount - 1
'向Cbx_Scjhd控件中添加数据项
Cbx_Scjhd.AddItem Trim(rs2.Fields("scjhd_id"))
rs2.MoveNext
Next i
End If
rs2.Close
Cbx_Scjhd.ListIndex = 0
tlbState Toolbar1, False
view_data
'设置DataGrid标题
Call Dgr_Title
'设置控件状态
For i = 0 To Text1.UBound
Text1(i).Enabled = False
Next i
For i = 0 To 10
Text1(i).Locked = True
Next i
Cbx_Scjhd.Enabled = False
Cbx_Wlbh.Enabled = False
Dtp_llrq.Enabled = False
Dtp_llrq.Value = Date
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sql = ""
End Sub
Private Sub Text1_Change(Index As Integer)
If Index = 12 Then
Text1(13).Text = Val(Text1(10).Text) - Val(Text1(11).Text) - Val(Text1(12).Text)
End If
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).BackColor = &HFFFF80
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index))
End Sub
Private Sub text1_KeyPress(Index As Integer, KeyAscii As Integer)
If KeyAscii = 13 Then
If Index = 5 Then
Cbx_Wlbh.SetFocus
Exit Sub
End If
' If Index = 13 Then
' Dtp_llrq.SetFocus
' Exit Sub
' End If
If Index = 14 Then Exit Sub
Text1(Index + 1).SetFocus
End If
If KeyAscii = vbKeyUp And Index > 1 Then Text1(Index - 1).SetFocus
End Sub
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).BackColor = &HFFFFFF
If Index = 12 Then
If Not IsNumeric(Text1(12).Text) Then
MsgBox "请输入正确的领料数量!", , "信息提示"
Text1(12).Text = ""
Text1(12).SetFocus
Exit Sub
End If
ElseIf Index = 12 Then
If Text1(12).Text = "" Then
MsgBox "系统不准许领料数量为空!", , "信息提示"
Text1(12).Text = ""
Text1(12).SetFocus
Exit Sub
End If
ElseIf Index = 13 Then
If Val(Text1(13).Text) < 0 Then
MsgBox "系统不准许领料数量超过计划单的数量!", , "信息提示"
Text1(12).Text = ""
Text1(12).SetFocus
Exit Sub
End If
End If
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.key
Case "add" '添加
blnadd1 = True
tlbState Toolbar1, True
'自动创建编号
Mystr = Left(Date, 4) + Right(Left(Date, 7), 2) + Right(Date, 2)
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from tb_SCGL_scll where scll_id like+ '%'+'" + Mystr + "'+'%' order by scll_id", cnn, adOpenKeyset
If rs1.RecordCount > 0 Then
If rs1.EOF = False Then rs1.MoveLast
Text1(0).Text = "SCLL" + Mystr + "d" + Format(Val(Right(Trim(rs1.Fields("scll_id")), 3)) + 1, "###000") '编号自动加1
Else
Text1(0).Text = "SCLL" + Mystr + "d001"
End If
rs1.Close '关闭数据集对象
'设置控件状态
For i = 1 To Text1.UBound
Text1(i).Enabled = True
Text1(i).Text = ""
Next i
For i = 0 To 11
Text1(i).Locked = True
Next i
Cbx_Scjhd.Enabled = True
Cbx_Wlbh.Enabled = True
' Dtp_llrq.Enabled = True
For i = 8 To 11
Toolbar1.Buttons(i).Enabled = False
Next i
SSTab1.Tab = 0
Cbx_Scjhd.SetFocus
Case "modify" '修改
If Adodc1.Recordset.RecordCount > 0 Then
blnadd1 = False
view_data
For i = 1 To Text1.UBound
Text1(i).Enabled = True
Next i
For i = 0 To 10
Text1(i).Locked = True
Next i
tlbState Toolbar1, True
Cbx_Scjhd.Enabled = True
Cbx_Wlbh.Enabled = True
' Dtp_llrq.Enabled = True
For i = 8 To 11
Toolbar1.Buttons(i).Enabled = False
Next i
Else
MsgBox "系统没有要修改的数据!", , "生产关系管理系统"
End If
Case "delete" '删除
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.Delete
Unload Me
Adodc1.Refresh
Frm_Kcgl_Scll.Show 1
Else
MsgBox "系统没有要删除的数据!", , "提示窗口"
End If
Case "save" '保存
If Cbx_Scjhd.Text = "" Then
MsgBox "系统不允许产品计划单为空!", , "提示窗口"
Exit Sub
End If
If Cbx_Wlbh = "" Then
MsgBox "系统不允许物料编号为空!", , "提示窗口"
Exit Sub
End If
On Error GoTo SaveErr '出现错误转向错误处理
If blnadd1 = False Then
Set rs1 = New ADODB.Recordset
rs1.Open "select * from tb_SCGL_Scll where Scll_id='" + Text1(0) + "'order by Scll_id", cnn, adOpenStatic
If rs1.RecordCount > 0 Then
Myval = MsgBox("您确实要修改这条数据吗?", vbYesNo)
If Myval = vbYes Then
cnn.Execute ("update tb_SCGL_scll set scll_scjhd='" + Cbx_Scjhd.Text + "',scll_cpbh='" + Text1(1) + "',scll_cpmc='" + Text1(2) + _
"',scll_cpgg='" + Text1(3).Text + "',scll_cpdw='" + Text1(4) + "',scll_cpsl='" + Text1(5).Text + "',scll_wlbh='" + Cbx_Wlbh.Text + _
"',scll_wlmc='" + Text1(6) + "',scll_wlgg='" + Text1(7) + "',scll_wldw='" + Text1(8) + "',scll_dwsl='" + Text1(9) + "',scll_wlsl='" + Text1(10) + "',scll_ylsl='" + Text1(11).Text + "',scll_llsl='" + Text1(12) + "',scll_sysl='" + Text1(13) + "',scll_llrq='" + str(Dtp_llrq.Value) + "',scll_bz='" + Text1(14) + "' where scll_id='" + Text1(0) + "'")
' Unload Me
' Adodc1.Refresh
' Frm_Kcgl_Scll.Show 1
Adodc1.Refresh
Set Dgr_Scll.DataSource = Adodc1
Call Dgr_Title
End If
End If
rs1.Close
Else
rs5.Open "select * from tb_SCGL_wlkc where wlkc_wlbh='" + Cbx_Wlbh.Text + "'", cnn, adOpenKeyset
If rs5.RecordCount > 0 Then
SL = rs5.Fields("wlkc_kcsl")
If Val(Text1(12).Text) > SL Then
MsgBox "库存数量不足,数量仅为" + str(SL), , "信息提示"
Text1(12).Text = ""
Text1(12).SetFocus
rs5.Close
Exit Sub
Else
SL1 = rs5.Fields("wlkc_kcsl") - Val(Text1(12).Text)
cnn.Execute ("update tb_SCGL_wlkc set wlkc_kcsl ='" + str(SL1) + "' where wlkc_wlbh='" + Cbx_Wlbh.Text + "'")
End If
End If
rs5.Close
Set rs1 = New ADODB.Recordset
rs1.Open "tb_SCGL_scll", cnn, adOpenKeyset, adLockOptimistic
'添加客户信息
rs1.AddNew
rs1.Fields("scll_id") = Text1(0).Text
rs1.Fields("scll_scjhd") = Cbx_Scjhd.Text
rs1.Fields("scll_cpbh") = Text1(1).Text
rs1.Fields("scll_cpmc") = Text1(2).Text
rs1.Fields("scll_cpgg") = Text1(3).Text
rs1.Fields("scll_cpdw") = Text1(4).Text
rs1.Fields("scll_cpsl") = Text1(5).Text
rs1.Fields("scll_wlbh") = Cbx_Wlbh.Text
rs1.Fields("scll_wlmc") = Text1(6).Text
rs1.Fields("scll_wlgg") = Text1(7).Text
rs1.Fields("scll_wldw") = Text1(8).Text
rs1.Fields("scll_dwsl") = Text1(9).Text
rs1.Fields("scll_wlsl") = Text1(10).Text
rs1.Fields("scll_ylsl") = Text1(11).Text
rs1.Fields("scll_llsl") = Text1(12).Text
rs1.Fields("scll_sysl") = Text1(13).Text
rs1.Fields("scll_llrq") = Dtp_llrq.Value
rs1.Fields("scll_bz") = Text1(14).Text
rs1.Update '更新数据库
Adodc1.Refresh
rs1.Close
End If
Call Dgr_Title
For i = 0 To Text1.UBound
Text1(i).Enabled = False
Next i
Cbx_Scjhd.Enabled = False
Cbx_Wlbh.Enabled = False
' Dtp_llrq.Enabled = False
tlbState Toolbar1, False
For i = 8 To 11
Toolbar1.Buttons(i).Enabled = True
Next i
Exit Sub
SaveErr: '错误处理
MsgBox Err.Description, , "信息提示"
Case "cancel"
view_data
For i = 0 To Text1.UBound
Text1(i).Enabled = False
Next i
Cbx_Scjhd.Enabled = False
Cbx_Wlbh.Enabled = False
' Dtp_llrq.Enabled = False
tlbState Toolbar1, False
For i = 8 To 11
Toolbar1.Buttons(i).Enabled = True
Next i
Case "find"
Tb = "tb_SCGL_Scll"
Load Frm_Cxct
Frm_Cxct.Show 1
Case "first" '移到第一条记录
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MoveFirst
Call view_data '调用过程
Call Dgr_Title
Case "previous" '移到上一条记录
If Adodc1.Recordset.RecordCount > 0 Then
If Adodc1.Recordset.BOF = False Then Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF = True Then Adodc1.Recordset.MoveFirst
End If
Call view_data '调用过程
Call Dgr_Title
Case "next" '移到下一条记录
If Adodc1.Recordset.RecordCount > 0 Then
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
End If
Call view_data '调用过程
Call Dgr_Title
Case "last" '移到最后一条记录
If Adodc1.Recordset.EOF = False Then Adodc1.Recordset.MoveLast
Call view_data '调用过程
Call Dgr_Title
Case "close"
Unload Me
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -