?? frm_out.frm
字號:
BeginProperty Column14
ColumnWidth = 2085.166
EndProperty
BeginProperty Column15
Object.Visible = 0 'False
ColumnWidth = 2085.166
EndProperty
BeginProperty Column16
Object.Visible = 0 'False
ColumnWidth = 2085.166
EndProperty
EndProperty
End
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "提貨單位:"
Height = 180
Left = 5250
TabIndex = 27
Top = 5160
Width = 900
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "提貨人:"
Height = 180
Left = 3420
TabIndex = 25
Top = 5175
Width = 720
End
Begin VB.Label Label9
ForeColor = &H00C00000&
Height = 315
Left = 90
TabIndex = 23
Top = 5175
Width = 3210
End
End
Attribute VB_Name = "frm_out"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Prices As Single '定義一個計算價格的變量
Dim i As Integer '運用在FOR循環(huán)中的變量
Dim StrTemp '用于顯示編號信息的變量
Dim StrNum As Long '用于顯示編號信息的變量
Dim ETemp As Integer '定義一個日志標(biāo)識變量
Private Sub Cmd_Add_Click()
For i = 0 To 5 '單擊“添加”按鈕之后,清空文本框中的內(nèi)容
Text1(i).Text = ""
Next i
Adodc1.RecordSource = "select * from tb_out order by ID"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveLast
StrNum = Val(Adodc1.Recordset.Fields("ID")) + 1 '使出貨編號加1
Select Case Len(Trim(StrNum)) '位數(shù)不足者補0
Case 1
StrTemp = "00000"
Case 2
StrTemp = "0000"
Case 3
StrTemp = "000"
Case 4
StrTemp = "00"
Case 5
StrTemp = "0"
Case 6
StrTemp = ""
End Select
Text1(0).Text = "L" & Trim(StrTemp) & Trim(Str(StrNum))
Else
Text1(0).Text = "L000001" '給出貨編號賦一個初值
StrNum = 1
End If
Text1(1).SetFocus
Cmd_save.Enabled = True
Cmd_del.Enabled = False
End Sub
'*** “刪除”商品出庫信息按鈕的事件過程 ***
Private Sub Cmd_del_Click()
rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3) '運用API函數(shù)SetWindowPos,來實現(xiàn)取消窗體置前的功能
If Adodc1.Recordset.EOF = False Then
c = MsgBox("您確認(rèn)要刪除該記錄嗎?", 17)
If c = vbOK Then
Adodc1.Recordset.Delete '刪除貨品出庫信息記錄
Adodc1.Refresh
Call Main
adoRs.Open "select * from tb_KCXX where KC_name='" + Text1(2).Text + "' and KC_UNIT ='" + Combo1.Text + "' and KC_Price=" & Val(Text1(4).Text) & "", adoCon, adOpenKeyset
If adoRs.RecordCount > 0 Then
Dim SNum As Integer
'重新計算庫存貨品的數(shù)量
SNum = Val(adoRs.Fields("KC_Num")) + Val(Text1(3).Text)
'修改該貨品的庫存數(shù)量
Set adoRs = adoCon.Execute("UPDATE tb_KCXX SET KC_Num='" + Str(SNum) + "' where KC_name='" + Text1(2).Text + "' and KC_UNIT ='" + Combo1.Text + "' and KC_Price=" & Val(Text1(4).Text) & "")
End If
adoCon.Close
ETemp = 1 '設(shè)置刪除標(biāo)識
Call joinRZ '添加日志
For i = 0 To 5 '清空文本框中的內(nèi)容
Text1(i).Text = ""
Next i
Cmd_del.Enabled = False
End If
Else
MsgBox "當(dāng)前數(shù)據(jù)庫中已經(jīng)沒有可刪除的記錄", 64
End If
Call TRefresh
End Sub
Private Sub Cmd_exit_Click()
Unload Me
End Sub
'*** “保存”貨品出庫信息按鈕的事件過程 ***
Private Sub Cmd_save_Click()
rtn = SetWindowPos(Me.hwnd, -2, 0, 0, 0, 0, 3) '運用API函數(shù)SetWindowPos,來實現(xiàn)取消窗體置前的功能
Adodc1.RecordSource = "select * from tb_out where ID=" + Str(StrNum) + "" '判斷所要保存的信息是否已經(jīng)存在
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
MsgBox "該信息已經(jīng)存在,信息保存不成功", 64
Call TRefresh '調(diào)用數(shù)據(jù)刷新的過程
Else
c = MsgBox("您確認(rèn)要保存該信息嗎?", 33)
If c = vbOK Then
If Text1(1).Text = "" Or Text1(3).Text = "" Or Text1(4).Text = "" Or Text2.Text = "" Then
MsgBox "貨品數(shù)量、單價、名稱或者提貨人信息不能為空值!", 48
Else
'IsNumeric函數(shù)用于判斷輸入的信息是否為數(shù)值型數(shù)據(jù)
If Not IsNumeric(Text1(3).Text) Or Not IsNumeric(Text1(4).Text) Then
MsgBox "輸入的貨品數(shù)量或單價必須為數(shù)值型數(shù)據(jù)", 48
Else
Call Main '調(diào)用公共模塊中的連接數(shù)據(jù)庫函數(shù)
adoRs.Open "select * from tb_KCXX where Kc_IDs='" + Text1(1).Text + "'", adoCon, adOpenKeyset
If adoRs.RecordCount > 0 Then
Dim SNum As Integer
SNum = Val(adoRs.Fields("KC_Num")) - Val(Text1(3).Text) '計算庫存中相應(yīng)貨品的數(shù)量
If SNum >= 0 Then
NumId = Val(Mid(Text1(0).Text, 2, Len(Text1(0).Text)))
Prices = Val(Text1(3).Text) * Val(Text1(4).Text) '計算出庫貨品的金額
'修改庫存中貨品的數(shù)量
Set adoRs = adoCon.Execute("UPDATE tb_KCXX SET KC_Num='" + Str(SNum) + "' where Kc_IDs='" + Text1(1).Text + "'")
'保存貨品出庫信息
Set adoRs = adoCon.Execute("insert into tb_OUT (ID,OUT_NumID,OUT_id,OUT_name,OUT_UNIT,OUT_Num,OUT_Price,OUT_Money,OUT_Date,out_year,out_month,OUT_THDW,OUT_people,OUT_Wpeople,OUT_Remark) values(" & StrNum & ",'" & Text1(0).Text & "','" & Text1(1).Text & "','" & Text1(2).Text & "','" & Combo1.Text & "','" & Text1(3).Text & "','" & Text1(4).Text & "'," & Prices & ",'" & Str(DTPicker1.Value) & "','" & Trim(Str(DTPicker1.Year)) & "','" & Trim(Str(DTPicker1.Month)) & "','" & Text3.Text & "','" & Text2.Text & "','" & Name1 & "','" & Text1(5).Text & "')")
MsgBox "信息保存成功", 64
Cmd_save.Enabled = False
Else
Dim Strs As String
Strs = "該貨品的庫存數(shù)量為 " & adoRs.Fields("kc_num") & " ,貨品出庫數(shù)量不應(yīng)大于其庫存數(shù)量"
MsgBox Strs, 48
End If
End If
adoCon.Close '關(guān)閉數(shù)據(jù)連接
End If
End If
Else
End If
End If
Call TRefresh '調(diào)用數(shù)據(jù)刷新過程
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '如果按下的是回車鍵,則光標(biāo)落到文本框當(dāng)中
Text1(3).SetFocus
End If
End Sub
Private Sub DataGrid1_Click()
Call JionBack '調(diào)用數(shù)據(jù)反綁定過程 '調(diào)用數(shù)據(jù)反綁定過程
Cmd_del.Enabled = True
Cmd_save.Enabled = False
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '如果按下的是回車鍵,則光標(biāo)落到文本框當(dāng)中
Text1(5).SetFocus
End If
End Sub
Private Sub Form_Load()
rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3) '運用API函數(shù)SetWindowPos,來實現(xiàn)使窗體置前的功能
'利用代碼連接數(shù)據(jù)庫
Adodc1.ConnectionString = CnnStr
Adodc1.RecordSource = "select * from tb_out" '連接出庫信息數(shù)據(jù)表
Adodc1.Refresh
Me.Left = (Screen.Width - Me.Width) / 2 '使窗體居中
Me.Top = (Screen.Height - Me.Height) / 2
DTPicker1.Value = Date
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
If Index = 1 Then '如果是第2個文本框,則調(diào)用frm_Tout窗體
frm_Tout.Show
frm_Tout.Left = 4100
frm_Tout.Top = 2750
frm_Tout.DataGrid1.SetFocus
ElseIf Index = 1 Then
Text1(2).SetFocus
ElseIf Index = 2 Then
Combo1.SetFocus
ElseIf Index = 3 Then
Text1(4).SetFocus
ElseIf Index = 4 Then
DTPicker1.SetFocus
ElseIf Index = 5 Then
Text2.SetFocus
End If
End If
End Sub
Private Sub Text2_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text3_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Cmd_save_Click
Cmd_Add.SetFocus
End If
End Sub
Private Sub Timer1_Timer() '通過時鐘控件隨時檢測數(shù)據(jù)庫中記錄的條數(shù)
If Adodc1.Recordset.RecordCount > 0 Then
Label9.Caption = "目前數(shù)據(jù)庫中共有 " & Adodc1.Recordset.RecordCount & " 條出庫數(shù)據(jù)"
End If
End Sub
'*** 自定義的數(shù)據(jù)反綁定過程 ***
Private Sub JionBack()
Dim SLen As Integer
If Adodc1.Recordset.RecordCount > 0 Then
StrNum = Val(Adodc1.Recordset.Fields("OUT_NumID"))
SLen = Len(Trim(StrNum))
Select Case SLen '位數(shù)不足者補0
Case 1
StrTemp = "00000"
Case 2
StrTemp = "0000"
Case 3
StrTemp = "000"
Case 4
StrTemp = "00"
Case 5
StrTemp = "0"
Case 6
StrTemp = ""
End Select
On Error Resume Next '執(zhí)行錯誤處理
Text1(0).Text = Adodc1.Recordset(1)
Text1(1).Text = Adodc1.Recordset(2)
Text1(2).Text = Adodc1.Recordset(3)
Combo1.Text = Adodc1.Recordset(4)
Text1(3).Text = Adodc1.Recordset(5)
Text1(4).Text = Adodc1.Recordset(6)
DTPicker1.Value = Adodc1.Recordset(8)
Text1(5).Text = Adodc1.Recordset("out_remark")
Text2.Text = Adodc1.Recordset.Fields("OUT_people")
Text3.Text = Adodc1.Recordset.Fields("OUT_THDW")
End If
End Sub
'*** 自定義的數(shù)據(jù)刷新過程 ***
Private Sub TRefresh()
Adodc1.RecordSource = "select * from tb_OUT order by OUT_NumID"
Adodc1.Refresh
End Sub
'*** 自定義的添加日志過程 ***
Private Sub joinRZ()
'添加系統(tǒng)日志
Open (App.Path & "\系統(tǒng)日志.ini") For Input As #1
Do While Not EOF(1)
Line Input #1, Intext
TStr = TStr + Intext + Chr(13) + Chr(10)
Loop
Close #1
If ETemp = 0 Then '添加修改信息日志
TStr = TStr + " " + Name1 + " " + Format(Now, "yyyy-mm-dd hh:mm:ss") + " " + "修改票號 " + Text1(0).Text + "(" + Text1(2).Text + ")" + Chr(13) + Chr(10)
ElseIf ETemp = 1 Then '添加刪除信息日志
TStr = TStr + " " + Name1 + " " + Format(Now, "yyyy-mm-dd hh:mm:ss") + " " + "刪除票號 " + Text1(0).Text + "(" + Text1(2).Text + ")" + Chr(13) + Chr(10)
End If
Open (App.Path & "\系統(tǒng)日志.ini") For Output As #1 '將日志信息保存到文件當(dāng)中
Print #1, TStr
Close #1
End Sub
Private Sub Form_Unload(Cancel As Integer)
frm_main.Enabled = True '在窗體關(guān)閉的時候使主窗體可用
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -