📄 frmplang1.frm
字号:
End Sub
Private Sub cmdSave_Click()
Dim intCount As Integer
Dim sMeg As String
Dim MsgText As String
Dim dBeginDate As String
Dim dEndDate As String
For intCount = 0 To 4
If Trim(txtItem(intCount) & " ") = "" Then
Select Case intCount
Case 0
sMeg = "产品编号"
Case 1
sMeg = "计量单位"
Case 2
sMeg = "产品数量"
Case 3
sMeg = "单价"
Case 4
sMeg = "总金额"
End Select
sMeg = sMeg & "不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
txtItem(intCount).SetFocus
Exit Sub
End If
Next intCount
'添加判断是否有相同的ID记录
If gintPLANGmode = 1 Then
txtSQL = "select * from plang where pl_no ='" & Trim(txtM_NO) & "' and dm = '" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
MsgBox "已经存在相同产品的生产计划记录!", vbOKOnly + vbExclamation, "警告"
Combo1(0).SetFocus
mrc.Close
Exit Sub
End If
End If
'先删除已有记录
txtSQL = "delete from plang where pl_no ='" & Trim(txtM_NO) & "' and dm = '" & Trim(txtItem(0)) & "'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
'再加入新记录
txtSQL = "insert plang (pl_no,pl_man,pl_date,dm,mc,jldw,pl_sl,dj,jine,cp_date,st_date) values ('"
txtSQL = txtSQL & Trim(txtM_NO) & "','"
txtSQL = txtSQL & Trim(txtYWDM) & "','"
txtSQL = txtSQL & Trim(txtM_DATE) & "','"
txtSQL = txtSQL & Trim(txtItem(0)) & "','"
txtSQL = txtSQL & Trim(Combo1(0)) & "','"
For intCount = 1 To 4
txtSQL = txtSQL & Trim(txtItem(intCount)) & "','"
Next intCount
dBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay(0)), "yyyy-mm-dd")
dEndDate = Format(CDate(cboYear(1) & "-" & cboMonth(1) & "-" & cboDay(1)), "yyyy-mm-dd")
txtSQL = txtSQL & Trim(dBeginDate) & "','"
txtSQL = txtSQL & Trim(dEndDate) & "')"
Set mrc = ExecuteSQL(txtSQL, MsgText)
If gintPLANGmode = 1 Then
MsgBox "添加记录成功!", vbOKOnly + vbExclamation, "添加记录"
For intCount = 0 To 4
txtItem(intCount) = ""
Next intCount
For intCount = 0 To 0
Combo1(intCount).ListIndex = 0
Next intCount
mblChange = False
'Unload frmPLANG
'Unload frmPLANGLIST
'frmPLANGLIST.txtSQL = "select * from plang"
'frmPLANGLIST.Show 0
Unload Me
frmPLANG.txtSQL = "select pl_no,dm,mc,jldw,pl_sl,dj,jine,cp_date,st_date,bz from plang where pl_no ='" & Trim(txtM_NO) & "'"
frmPLANG.ShowData
ElseIf gintPLANGmode = 2 Then
'Unload Me
'Unload frmPLANG
'Unload frmPLANGLIST
'frmPLANGLIST.txtSQL = "select * from plang"
'frmPLANGLIST.Show 0
Unload Me
frmPLANG.txtSQL = "select pl_no,dm,mc,jldw,pl_sl,dj,jine,cp_date,st_date,bz from plang where pl_no ='" & Trim(txtM_NO) & "'"
frmPLANG.ShowData
End If
End Sub
Private Sub Combo1_Change(Index As Integer)
mblChange = True
End Sub
Private Sub Combo1_Click(Index As Integer)
Dim mrcc As ADODB.Recordset
Dim mrcd As ADODB.Recordset
Dim MsgText As String
If Index = 0 Then
txtItem(0) = Combo1(0).ItemData(Combo1(0).ListIndex)
txtSQL = "select jldw,lsj from dm_wz where dm = '" & Trim(txtItem(0)) & "'"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
txtItem(1) = mrcc.Fields(0)
txtItem(3) = Format(mrcc.Fields(1), "###0.00")
End If
mrcc.Close
End If
End Sub
Private Sub Form_Load()
Dim intCount As Integer
Dim MsgText As String
Dim i, j As Integer
Dim mrcc As ADODB.Recordset
Combo1(0).Clear
If gintPLANGmode = 1 Then
Me.Caption = Me.Caption & "添加"
For i = 0 To 4
txtItem(i).Text = ""
Next i
Combo1(0).Clear
ElseIf gintPLANGmode = 2 Then
Set mrc = ExecuteSQL(txtSQL, MsgText)
If mrc.EOF = False Then
With mrc
txtItem(0) = .Fields(0)
Combo1(0).AddItem .Fields(1)
Combo1(0).ItemData(Combo1(0).NewIndex) = .Fields(0)
Combo1(0).ListIndex = 0
For intCount = 1 To 3
txtItem(intCount) = .Fields(intCount + 1)
Next intCount
End With
txtItem(0).Enabled = False
End If
Me.Caption = Me.Caption & "修改"
End If
For i = 0 To 5
cboYear(0).AddItem Year(Now()) + i
cboYear(1).AddItem Year(Now()) + i
Next i
cboYear(0).ListIndex = 0
cboYear(1).ListIndex = 0
For j = 1 To 12
cboMonth(0).AddItem j
cboMonth(1).AddItem j
Next j
cboMonth(0).Text = Month(Now())
cboMonth(1).Text = Month(Now())
For j = 1 To 31
cboDay(0).AddItem j
cboDay(1).AddItem j
Next j
cboDay(0).Text = Day(Now())
cboDay(1).Text = Day(Now())
txtSQL = "select dm,mc from dm_wz"
Set mrcc = ExecuteSQL(txtSQL, MsgText)
If Not mrcc.EOF Then
Do While Not mrcc.EOF
Combo1(0).AddItem mrcc.Fields(1)
Combo1(0).ItemData(Combo1(0).NewIndex) = mrcc.Fields(0)
mrcc.MoveNext
Loop
End If
mrcc.Close
mblChange = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
gintDHmode = 0
End Sub
Private Sub txtItem_Change(Index As Integer)
Dim intCount As Integer
'用于计算工资
Dim dblTotal As Double
'有变化设置gblchange
mblChange = True
If (Index = 2) Then
dblTotal = 0
If Trim(txtItem(3)) <> "" And Trim(txtItem(2) <> "") Then
dblTotal = CDbl(txtItem(2)) * CDbl(txtItem(3))
End If
txtItem(4) = Format(dblTotal, "#0.00")
End If
Exit Sub
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
EnterToTab KeyCode
End Sub
Private Sub txtItem_KeyPress(Index As Integer, KeyAscii As Integer)
If Index >= 2 And Index <= 2 Then
'MsgBox KeyCode
'对键入字符进行控制
'txtQuantity(Index).Locked = False
'小数点只允许输入一次
If KeyAscii = 190 Then
If InStr(Trim(txtItem(Index)), ".") = 0 Then
If Len(Trim(txtItem(Index))) > 0 Then
txtItem(Index).Locked = False
Else
txtItem(Index).Locked = True
End If
Else
txtItem(Index).Locked = True
End If
Exit Sub
End If
'非数字不能输入
If KeyAscii > 57 Or KeyAscii < 48 Then
txtItem(Index).Locked = True
Else
txtItem(Index).Locked = False
End If
'允许Backspace
If KeyAscii = 8 Then
txtItem(Index).Locked = False
End If
'Delete键
If KeyAscii = 46 Then
txtItem(Index).Locked = False
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -