?? main_rcyw_tsrk.frm
字號:
jsr.BackColor = &HFFFF00
End Sub
Private Sub jsr_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then '按回車鍵
Text1.Visible = True
'到達第1行,第1列
MS1.Row = 1
MS1.Col = 1
Text1.SetFocus
End If
End Sub
Private Sub jsr_LostFocus()
jsr.BackColor = &HFFFFFF
End Sub
Private Sub MS1_Click()
If MS1.Row >= 1 And MS1.TextMatrix(MS1.Row - 1, 6) <> "" Then '在MS1表格第1行或大于第1行時
Text1.Visible = True 'text1可見
Text1.SetFocus
End If
End Sub
Private Sub MS1_entercell()
Dim X, Y, p As String
If MS1.CellWidth <= 0 Or MS1.CellHeight <= 0 Then Exit Sub
X = MS1.TextMatrix(MS1.FixedRows, MS1.Col)
Y = MS1.TextMatrix(MS1.Row, 0)
If Y <> "" Then
If MS1.Col - MS1.LeftCol <= 3 Then MS1.LeftCol = MS1.LeftCol + 1
If MS1.CellWidth > 0 And MS1.CellHeight > 0 Then
Text1.Width = MS1.CellWidth
Text1.Height = MS1.CellHeight
Text1.Left = MS1.CellLeft + MS1.Left
Text1.Top = MS1.CellTop + MS1.Top
End If
X = MS1.TextMatrix(MS1.FixedRows, MS1.Col)
Y = MS1.TextMatrix(MS1.Row, 0)
p = MS1.TextMatrix(MS1.Row, MS1.Col)
Text1.text = MS1.text
Text1.SelStart = 0
Text1.SelLength = Len(Text1.text)
End If
End Sub
Private Sub MS1_RowColChange() '格式化金額
For i = 1 To 100
If MS1.TextMatrix(i, 1) <> "" Then
MS1.TextMatrix(i, 9) = Format(MS1.TextMatrix(i, 9), "#0.00")
MS1.TextMatrix(MS1.Row, 11) = Val(MS1.TextMatrix(MS1.Row, 9)) * Val(MS1.TextMatrix(MS1.Row, 10))
MS1.TextMatrix(i, 11) = Format(MS1.TextMatrix(i, 11), "#0.00")
End If
Next i
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyReturn Then
Text1.text = MS1.text
Adodc3.RecordSource = "select * from kcb where 條形碼='" + MS1.TextMatrix(MS1.Row, 2) + "'"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount > 0 Then '當記錄大于零時
If MS1.Col = 2 Then
With Adodc3.Recordset
'賦值給MS1表格
If .Fields("書號") <> "" Then MS1.TextMatrix(MS1.Row, 1) = .Fields("書號")
If .Fields("條形碼") <> "" Then MS1.TextMatrix(MS1.Row, 2) = .Fields("條形碼")
If .Fields("書名") <> "" Then MS1.TextMatrix(MS1.Row, 3) = .Fields("書名")
If .Fields("作者") <> "" Then MS1.TextMatrix(MS1.Row, 4) = .Fields("作者")
If .Fields("出版社") <> "" Then MS1.TextMatrix(MS1.Row, 5) = .Fields("出版社")
If .Fields("圖書類別") <> "" Then MS1.TextMatrix(MS1.Row, 7) = .Fields("圖書類別")
If .Fields("存放位置") <> "" Then MS1.TextMatrix(MS1.Row, 8) = .Fields("存放位置")
If .Fields("單價") <> "" Then MS1.TextMatrix(MS1.Row, 9) = .Fields("單價")
'Text1.text = MS1.text
Text1.SetFocus
MS1.Col = 6
End With
End If
End If
If Adodc1.Recordset.RecordCount > 0 Then '當記錄大于零時
If MS1.Col = 1 Then
With Adodc1.Recordset
'賦值給MS1表格
If .Fields("書號") <> "" Then MS1.TextMatrix(MS1.Row, 1) = .Fields("書號")
If .Fields("條形碼") <> "" Then MS1.TextMatrix(MS1.Row, 2) = .Fields("條形碼")
If .Fields("書名") <> "" Then MS1.TextMatrix(MS1.Row, 3) = .Fields("書名")
If .Fields("作者") <> "" Then MS1.TextMatrix(MS1.Row, 4) = .Fields("作者")
If .Fields("出版社") <> "" Then MS1.TextMatrix(MS1.Row, 5) = .Fields("出版社")
If .Fields("圖書類別") <> "" Then MS1.TextMatrix(MS1.Row, 7) = .Fields("圖書類別")
If .Fields("存放位置") <> "" Then MS1.TextMatrix(MS1.Row, 8) = .Fields("存放位置")
If .Fields("單價") <> "" Then MS1.TextMatrix(MS1.Row, 9) = .Fields("單價")
'Text1.text = MS1.text
MS1.Col = 6
Text1.SetFocus
End With
End If
Grid1.Visible = False
If MS1.Col = 6 Then MS1.Col = 9
If MS1.Col = 10 Then
MS1.Row = MS1.Row + 1
MS1.Col = 1
Else
If MS1.Col + 1 <= MS1.Cols - 1 Then
MS1.Col = MS1.Col + 1
Else
If MS1.Row + 1 <= MS1.Rows - 1 Then
MS1.Row = MS1.Row + 1
MS1.Col = 1
End If
End If
End If
Else
If MS1.Col = 10 Then
MS1.Row = MS1.Row + 1
MS1.Col = 1
Else
If MS1.Col + 1 <= MS1.Cols - 1 Then
MS1.Col = MS1.Col + 1
Else
If MS1.Row + 1 <= MS1.Rows - 1 Then
MS1.Row = MS1.Row + 1
MS1.Col = 1
End If
End If
End If
End If
End If
If KeyCode = vbKeyUp Then
If MS1.Row > 1 Then MS1.Row = MS1.Row - 1
End If
If KeyCode = vbKeyDown And (MS1.TextMatrix(MS1.Row, 1)) <> "" Then
If MS1.Row < 99 Then MS1.Row = MS1.Row + 1
End If
If KeyCode = vbKeyLeft Then
If Text1.text <> "" Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.text)
End If
If MS1.Col - 10 <= MS1.Cols + 1 Then
MS1.Col = MS1.Col - 1
If MS1.Col = 0 Then MS1.Col = 1
Else
If MS1.Row + 1 <= MS1.Row - 1 Then
MS1.Row = MS1.Row + 1
MS1.Col = 1
End If
End If
End If
If KeyCode = vbKeyRight Then
If Text1.text <> "" Then
Text1.SelStart = 0
Text1.SelLength = Len(Text1.text)
End If
If MS1.Col + 1 <= MS1.Cols - 1 Then
MS1.Col = MS1.Col + 1
Else
If MS1.Row + 1 <= MS1.Rows - 1 Then
MS1.Row = MS1.Row + 1
MS1.Col = 1
End If
End If
End If
If KeyCode = vbKeyPageDown And MS1.Col = 1 Then
Adodc1.RecordSource = "select * from kcb"
Adodc1.Refresh
Grid1.Visible = True
Grid1.SetFocus
End If
End Sub
Private Sub Text1_Change()
MS1.text = Text1.text '賦值給MS1.text
If MS1.Col = 1 Then
'按書號查詢庫存圖書信息
Adodc1.RecordSource = "select * from kcb where 書號 like +'" + Text1.text + "'+'%'"
Adodc1.Refresh
If Text1.text = "" Then '當text1.text為空時
Grid1.Visible = False 'grid1不可見
Else
If Adodc1.Recordset.RecordCount > 0 Then '當記錄大于零時
Grid1.Visible = True 'grid1可見
Text1.Visible = True
Text1.SetFocus
Else
Grid1.Visible = False
End If
End If
End If
If MS1.Col = 9 Then MS1.TextMatrix(MS1.Row, 11) = Val(MS1.TextMatrix(MS1.Row, 9)) * Val(MS1.TextMatrix(MS1.Row, 10))
If MS1.Col = 10 Then MS1.TextMatrix(MS1.Row, 11) = Val(MS1.TextMatrix(MS1.Row, 9)) * Val(MS1.TextMatrix(MS1.Row, 10))
If MS1.Col = 7 Then
Text1.Visible = False
Combo1.Visible = True
Combo1.Width = MS1.CellWidth
Combo1.Left = MS1.CellLeft + MS1.Left
Combo1.Top = MS1.CellTop + MS1.Top
Combo1.SetFocus
End If
Dim a, B As Single
For i = 1 To 101
a = Val(MS1.TextMatrix(i, 11)) + a
B = Val(MS1.TextMatrix(i, 10)) + B
If MS1.TextMatrix(i, 1) <> "" And MS1.TextMatrix(i, 10) <> "" Then pz.Caption = i
Next i
'計算合計金額,合計數量
hjje.Caption = a '計算合計金額
hjsl.Caption = B '計算合計數量
End Sub
Private Sub CmdReg_Click()
'查詢所有入庫數據,并按票號排序
Adodc2.RecordSource = "select * from rkb order by 票號"
Adodc2.Refresh
'創建入庫票號
If Adodc2.Recordset.RecordCount > 0 Then
If Not Adodc2.Recordset.EOF Then Adodc2.Recordset.MoveLast
If Adodc2.Recordset.Fields("票號") <> "" Then
lsph = Right(Trim(Adodc2.Recordset.Fields("票號")), 4) + 1
PH.Caption = Date & "rk" & Format(lsph, "0000")
End If
Else
PH.Caption = Date & "rk" & "0001"
End If
'設置jsr有效
jsr.Enabled = True
'jsr獲得焦點
jsr.SetFocus
Text1.Enabled = True
MS1.Enabled = True
'確定文本框在MS1表格中的位置
Text1.Width = MS1.CellWidth
Text1.Height = MS1.CellHeight
Text1.Left = MS1.CellLeft + MS1.Left
Text1.Top = MS1.CellTop + MS1.Top
'設置按鈕有效或無效
CmdSave.Enabled = True
CmdCancel.Enabled = True
CmdReg.Enabled = False
End Sub
Private Sub CmdSave_Click()
For i = 1 To 101
If MS1.TextMatrix(i, 1) <> "" Then
Set rs1 = New ADODB.Recordset
rs1.Open "select * from rkb", Cnn, adOpenKeyset, adLockOptimistic
'添加入庫商品信息到"rkb"表中
rs1.AddNew
If MS1.TextMatrix(i, 1) <> "" Then rs1.Fields("書號") = MS1.TextMatrix(i, 1)
If MS1.TextMatrix(i, 2) <> "" Then rs1.Fields("條形碼") = MS1.TextMatrix(i, 2)
If MS1.TextMatrix(i, 3) <> "" Then rs1.Fields("書名") = MS1.TextMatrix(i, 3)
If MS1.TextMatrix(i, 4) <> "" Then rs1.Fields("作者") = MS1.TextMatrix(i, 4)
If MS1.TextMatrix(i, 5) <> "" Then rs1.Fields("出版社") = MS1.TextMatrix(i, 5)
If MS1.TextMatrix(i, 6) <> "" Then rs1.Fields("版次") = MS1.TextMatrix(i, 6)
If MS1.TextMatrix(i, 7) <> "" Then rs1.Fields("圖書類別") = MS1.TextMatrix(i, 7)
If MS1.TextMatrix(i, 8) <> "" Then rs1.Fields("存放位置") = MS1.TextMatrix(i, 8)
If MS1.TextMatrix(i, 9) <> "" Then rs1.Fields("單價") = MS1.TextMatrix(i, 9)
If MS1.TextMatrix(i, 10) <> "" Then rs1.Fields("入庫數量") = MS1.TextMatrix(i, 10)
If MS1.TextMatrix(i, 11) <> "" Then rs1.Fields("金額") = MS1.TextMatrix(i, 11)
If jsr.text <> "" Then rs1.Fields("經手人") = jsr.text
If PH.Caption <> "" Then rs1.Fields("票號") = PH.Caption
If jsr.text <> "" Then rs1.Fields("操作員") = frm_main.St1.Panels(3).text
If rq.Caption <> "" Then rs1.Fields("日期") = rq.Caption
rs1.Update '更新表
'查找庫存圖書信息
Set rs2 = New ADODB.Recordset
rs2.Open "select * from kcb where 書號='" + MS1.TextMatrix(i, 1) + "'", Cnn, adOpenKeyset, adLockOptimistic
If rs2.RecordCount = 0 Then
'添加入庫圖書信息到"kcb"表中
rs2.AddNew
If MS1.TextMatrix(i, 1) <> "" Then rs2.Fields("書號") = MS1.TextMatrix(i, 1)
If MS1.TextMatrix(i, 2) <> "" Then rs2.Fields("條形碼") = MS1.TextMatrix(i, 2)
If MS1.TextMatrix(i, 3) <> "" Then rs2.Fields("書名") = MS1.TextMatrix(i, 3)
If MS1.TextMatrix(i, 4) <> "" Then rs2.Fields("作者") = MS1.TextMatrix(i, 4)
If MS1.TextMatrix(i, 5) <> "" Then rs2.Fields("出版社") = MS1.TextMatrix(i, 5)
If MS1.TextMatrix(i, 7) <> "" Then rs2.Fields("圖書類別") = MS1.TextMatrix(i, 7)
If MS1.TextMatrix(i, 8) <> "" Then rs2.Fields("存放位置") = MS1.TextMatrix(i, 8)
If MS1.TextMatrix(i, 9) <> "" Then rs2.Fields("單價") = MS1.TextMatrix(i, 9)
If MS1.TextMatrix(i, 10) <> "" Then rs2.Fields("現存數量") = MS1.TextMatrix(i, 10)
If MS1.TextMatrix(i, 10) <> "" Then rs2.Fields("圖書總數") = MS1.TextMatrix(i, 10)
If MS1.TextMatrix(i, 11) <> "" Then rs2.Fields("金額") = MS1.TextMatrix(i, 11)
rs2.Fields("借出次數") = 0
rs2.Update '更新表
Else
'更新"kcb"表中的"庫存"及"庫存金額"
Adodc1.Recordset.Fields("現存數量") = Val(MS1.TextMatrix(i, 10)) + Val(Adodc1.Recordset.Fields("現存數量"))
Adodc1.Recordset.Fields("圖書總數") = Val(MS1.TextMatrix(i, 10)) + Val(Adodc1.Recordset.Fields("圖書總數"))
Adodc1.Recordset.Fields("金額") = Val(Adodc1.Recordset.Fields("圖書總數")) * Val(Adodc1.Recordset.Fields("單價"))
Adodc1.Recordset.Update
End If
End If
Next i
Set rs3 = New ADODB.Recordset
rs3.Open "select * from rkph", Cnn, adOpenKeyset, adLockOptimistic
rs3.AddNew
rs3.Fields("票號") = PH.Caption
rs3.Fields("入庫品種") = pz.Caption
rs3.Fields("入庫數量") = hjsl.Caption
rs3.Fields("合計金額") = hjje.Caption
rs3.Fields("經手人") = jsr.text
rs3.Fields("操作員") = frm_main.St1.Panels(3).text
rs3.Fields("日期") = rq.Caption
rs3.Update
rs1.Close
rs2.Close
rs3.Close
'清空數據
For i = 1 To 101
For j = 1 To 11
MS1.TextMatrix(i, j) = ""
Next j
Next i
jsr.text = ""
pz.Caption = ""
hjsl.Caption = ""
hjje.Caption = ""
Text1.Visible = False '設置控件不可見
MS1.Enabled = False
CmdSave.Enabled = False
CmdReg.Enabled = True
CmdCancel.Enabled = False
End Sub
Private Sub CmdCancel_Click() '取消操作
jsr.text = ""
pz.Caption = ""
hjsl.Caption = ""
hjje.Caption = ""
For i = 1 To 100
For j = 1 To 11
MS1.TextMatrix(i, j) = ""
Next j
Next i
jsr.Enabled = False
Text1.Enabled = False
MS1.Enabled = False
CmdSave.Enabled = False
CmdCancel.Enabled = False
CmdReg.Enabled = True
CmdReg.SetFocus
End Sub
Private Sub CmdEnd_Click()
frm_main.Enabled = True
Unload Me
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -