📄 教材入库.frm
字号:
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "教 材 名:"
Height = 180
Index = 9
Left = 120
TabIndex = 3
Top = 360
Width = 810
End
End
Begin VB.Line Line1
X1 = 0
X2 = 10140
Y1 = 6945
Y2 = 6945
End
End
End
Attribute VB_Name = "教材入库"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i, a, bz
Private Sub Combo1_Click()
On Error Resume Next
Adodc2.Recordset.MoveFirst
Adodc2.Recordset.Find "教材名='" & Trim(Combo1) & "'"
Text5 = Adodc2.Recordset.Fields("作者")
Text6 = Adodc2.Recordset.Fields("出版社")
DTPicker1 = Adodc2.Recordset.Fields("出版日期")
'If Combo1 = "" Then
' Text1 = ""
' Text2 = ""
' Text3 = ""
' Text5 = ""
' Text6 = ""
' DTPicker1 = Date
'End If
End Sub
Private Sub Command1_Click()
On Error Resume Next
If Command1.Caption = "继续" Then
Command1.Caption = "入库"
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
Combo1.SetFocus
Else
If Combo1.Text = "--*请选择*--" Or Text1 = "" Or Text2 = "" Or Combo1.Text = "" Or Combo4.Text = "" Or Combo2.Text = "" Then
MsgBox "信息不完整!", 48
Combo1.SetFocus
Else
a = 0
For i = 0 To Combo2.ListCount
If Combo2.List(i) = Combo2.Text Then a = 1
Next
If a = 0 Then Combo2.AddItem Combo2.Text
a = 0
For i = 0 To Combo4.ListCount
If Combo4.List(i) = Combo4.Text Then a = 1
Next
If a = 0 Then Combo4.AddItem Combo4.Text
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields(1) = Combo1.Text
Adodc1.Recordset.Fields(2) = Text5
Adodc1.Recordset.Fields(3) = Text6
Adodc1.Recordset.Fields(4) = DTPicker1
Adodc1.Recordset.Fields(5) = Combo4.Text
Adodc1.Recordset.Fields(6) = Text1
Adodc1.Recordset.Fields(7) = Text2
Adodc1.Recordset.Fields(8) = Text3
Adodc1.Recordset.Fields(9) = Combo2.Text
Adodc1.Recordset.Fields(10) = DTPicker2
Adodc1.Recordset.Update
Adodc3.RecordSource = "select * from 教材库存表 where 教材名='" & Combo1.Text & "'" & " and 作者='" & Text5 & "'" & " and 出版社='" & Text6 & "'" & " and 出版日期=#" & Str$(DTPicker1.Value) & "#" & " and 单价=" & Val(Text1) & "" & " and 书类别='" & Combo4.Text & "'"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount = 0 Then
Adodc3.Recordset.AddNew
Adodc3.Recordset.Fields(0) = Combo1.Text
Adodc3.Recordset.Fields(1) = Text5
Adodc3.Recordset.Fields(2) = Text6
Adodc3.Recordset.Fields(3) = DTPicker1
Adodc3.Recordset.Fields(4) = Text1
Adodc3.Recordset.Fields(5) = Combo4.Text
Adodc3.Recordset.Fields(6) = Text2
Adodc3.Recordset.Update
Combo1.ListIndex = 0
Text5 = ""
Text6 = ""
DTPicker1 = Date
Combo4.ListIndex = 0
Text1 = ""
Text2 = ""
Text3 = ""
DTPicker1 = Date
Combo1.SetFocus
Else
Adodc3.Recordset.MoveFirst
Adodc3.Recordset.Fields(6) = Val(Adodc3.Recordset.Fields(6)) + Val(Adodc1.Recordset.Fields(7))
Adodc3.Recordset.Update
Combo1.ListIndex = 0
Text5 = ""
Text6 = ""
DTPicker1 = Date
Combo4.ListIndex = 0
Text1 = ""
Text2 = ""
Text3 = ""
DTPicker1 = Date
Combo1.SetFocus
End If
End If
End If
Combo1.Text = ""
Text5 = ""
Text6 = ""
Text1 = ""
Text2 = ""
Text3 = ""
Combo4 = ""
Combo2 = ""
DTPicker1 = Date
DTPicker2 = Date
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
On Error Resume Next
'Adodc3.RecordSource = "select * from 教材库存表 where 教材名='" & Combo1.Text & "'" & " and 作者='" & Text5 & "'" & " and 出版社='" & Text6 & "'" & " and 出版日期=#" & Str$(DTPicker1.Value) & "#" & " and 单价=" & Val(Text1) & "" & " and 书类别='" & Combo4.Text & "'"
'Adodc3.Refresh
Adodc3.Recordset.MoveFirst
Adodc3.Recordset.Fields("教材名") = Combo1.Text
Adodc3.Recordset.Fields("作者") = Text5
Adodc3.Recordset.Fields("出版社") = Text6
Adodc3.Recordset.Fields("出版日期") = DTPicker1
Adodc3.Recordset.Fields("单价") = Text1
Adodc3.Recordset.Fields("书类别") = Combo4
Adodc3.Recordset.Fields("库存数量") = Adodc3.Recordset.Fields("库存数量") + (Text2 - Adodc1.Recordset.Fields(7))
Adodc3.Recordset.Update
Adodc1.Recordset.Fields(1) = Combo1.Text
Adodc1.Recordset.Fields(2) = Text5
Adodc1.Recordset.Fields(3) = Text6
Adodc1.Recordset.Fields(4) = DTPicker1
Adodc1.Recordset.Fields(5) = Combo4.Text
Adodc1.Recordset.Fields(6) = Text1
Adodc1.Recordset.Fields(7) = Text2
Adodc1.Recordset.Fields(8) = Text3
Adodc1.Recordset.Fields(9) = Combo2.Text
Adodc1.Recordset.Fields(10) = DTPicker2
Adodc1.Recordset.Update
End Sub
Private Sub Command4_Click()
Adodc1.Recordset.CancelUpdate
Adodc1.Recordset.CancelUpdate
Combo1.Text = Adodc1.Recordset.Fields(1)
Text5 = Adodc1.Recordset.Fields(2)
Text6 = Adodc1.Recordset.Fields(3)
DTPicker1 = Adodc1.Recordset.Fields(4)
Combo4.Text = Adodc1.Recordset.Fields("书类别")
Text1 = Adodc1.Recordset.Fields(6)
Text2 = Adodc1.Recordset.Fields(7)
Text3 = Adodc1.Recordset.Fields(8)
Combo2.Text = Adodc1.Recordset.Fields(9)
DTPicker2 = Adodc1.Recordset.Fields(10)
End Sub
Private Sub Command5_Click()
Dim i
On Error Resume Next
i = MsgBox("你确认要删除这条记录吗?", 4, "系统提示")
If i = 6 Then
Adodc3.RecordSource = "select * from 教材库存表 where 教材名='" & Adodc1.Recordset.Fields(1) & "'" & " and 作者='" & Adodc1.Recordset.Fields(2) & "'" & " and 出版社='" & Adodc1.Recordset.Fields(3) & "'" & " and 出版日期=#" & Adodc1.Recordset.Fields(4) & "#" & " and 单价=" & Val(Adodc1.Recordset.Fields(6)) & "" & " and 书类别='" & Adodc1.Recordset.Fields(5) & "'"
Adodc3.Refresh
Adodc3.Recordset.Fields(6) = Adodc3.Recordset.Fields(6) - Adodc1.Recordset.Fields(7)
Adodc3.Recordset.Update
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
Combo1.Text = ""
Text5 = ""
Text6 = ""
Text1 = ""
Text2 = ""
Text3 = ""
Combo4 = ""
Combo2 = ""
DTPicker1 = Date
DTPicker2 = Date
Else
End If
End Sub
Private Sub Command7_Click()
rk = 1
教材入库查询.Show
End Sub
Private Sub DataGrid1_Click()
On Error Resume Next
Combo1.Text = Adodc1.Recordset.Fields(1)
Text5 = Adodc1.Recordset.Fields(2)
Text6 = Adodc1.Recordset.Fields(3)
DTPicker1 = Adodc1.Recordset.Fields(4)
Combo4.Text = Adodc1.Recordset.Fields(5)
Text1 = Adodc1.Recordset.Fields(6)
Text2 = Adodc1.Recordset.Fields(7)
Text3 = Adodc1.Recordset.Fields(8)
Combo2.Text = Adodc1.Recordset.Fields(9)
DTPicker2 = Adodc1.Recordset.Fields(10)
Adodc3.RecordSource = "select * from 教材库存表 where 教材名='" & Combo1.Text & "'" & " and 作者='" & Text5 & "'" & " and 出版社='" & Text6 & "'" & " and 出版日期=#" & Str$(DTPicker1.Value) & "#" & " and 单价=" & Val(Text1) & "" '"
Adodc3.Refresh
Command1.Caption = "继续"
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command2.Enabled = True
End Sub
Private Sub Form_Activate()
Combo1.SetFocus
DTPicker1 = Date
DTPicker2 = Date
Command1.Caption = "入库"
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
End Sub
Private Sub Form_Load()
On Error Resume Next
Adodc2.Recordset.MoveFirst
Combo1.Clear
Do While Not Adodc2.Recordset.EOF
Combo1.AddItem Adodc2.Recordset.Fields("教材名")
Adodc2.Recordset.MoveNext
Loop
Combo1 = ""
Adodc3.Recordset.MoveFirst
Combo4.Clear
Do While Not Adodc3.Recordset.EOF
a = 0
For i = 0 To Combo4.ListCount
If Combo4.List(i) = Adodc3.Recordset.Fields("书类别") Then a = 1
Next
If a = 0 Then Combo4.AddItem Adodc3.Recordset.Fields("书类别")
Adodc3.Recordset.MoveNext
Loop
Combo4 = ""
Adodc1.Recordset.MoveFirst
Combo2.Clear
Do While Not Adodc1.Recordset.EOF
a = 0
For i = 0 To Combo2.ListCount
If Combo2.List(i) = Adodc1.Recordset.Fields("经手人") Then a = 1
Next
If a = 0 Then Combo2.AddItem Adodc1.Recordset.Fields("经手人")
Adodc1.Recordset.MoveNext
Loop
Combo2 = ""
Combo1 = ""
Combo4 = ""
Text1 = ""
Text2 = ""
Text3 = ""
Text5 = ""
Text6 = ""
End Sub
Private Sub Form_Unload(Cancel As Integer)
主窗体.Enabled = True
End Sub
Private Sub Text1_Lostfocus()
bz = 0
For i = 1 To Len(Text1)
If Asc(Mid$(Text1, i, 1)) >= 48 And Asc(Mid$(Text1, i, 1)) <= 57 Or Asc(Mid$(Text1, i, 1)) = 46 Then
bz = 0
Else
bz = 1
End If
Next
If bz = 0 Then
Text3 = Val(Text1) * Val(Text2)
Else
MsgBox "请输入数字!", vbOKOnly + vbInformation: Text1 = ""
End If
End Sub
Private Sub Text2_Lostfocus()
bz = 0
For i = 1 To Len(Text2)
If Asc(Mid$(Text2, i, 1)) < 48 Or Asc(Mid$(Text2, i, 1)) > 57 Then bz = 1
Next
If bz = 0 Then
Text3 = Val(Text1) * Val(Text2)
Else
MsgBox "请输入数字!", vbOKOnly + vbInformation: Text2 = ""
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -