仓库管理系统源代码数据库实训 第8页
End If
'-------------------
Else
'--------------------
If .Fields(4) = 0 Then
MsgBox ("此物品已为空!")
Text1(0).SelStart = 0
Text1(0).SelLength = Len(Text1(0))
Text1(0).SetFocus
Exit Sub
Else
.Fields(4) = .Fields(4) - Val(Text1(4))
.Update
'给出库加信息
outstorehouse.RecordSource = "outstorehouse"
outstorehouse.Refresh
With outstorehouse.Recordset
.AddNew
.Fields(0) = Text1(0)
.Fields(1) = Text1(1)
.Fields(2) = Text1(2)
.Fields(3) = Text1(3)
.Fields(4) = Text1(4)
.Fields(5) = Text1(5)
.Fields(6) = Text1(6)
.Fields(7) = Text1(7)
.Fields(8) = Text1(8)
.Fields(9) = Text1(9)
.Fields(10) = Text1(10)
.Update
End With
Call list1disp
Call Command2_Click
End If
'--------------------
End If
End With
End If
'---------------------------------------------------------------------
'-------------------------给出库添加信息------------------------------
'---------------------------------------------------------------------
End Sub
Private Sub Command2_Click()
Call clearzore
Text1(6).Text = Date
Text1(9).Text = Operater1
Me.Text1(0).SetFocus
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Me.Top = (Mainform.Height - Me.Height) / 2 - 800
Me.Left = (Mainform.Width - Me.Width) / 2
Me.Caption = "仓库管理系统→" & "出库操作"
outstorehouse.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Storehouse.mdb;Persist Security Info=False"
person.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Storehouse.mdb;Persist Security Info=False"
stock.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Storehouse.mdb;Persist Security Info=False"
Call clearzore
Call list1def
Text1(9).Text = Operater1
Text1(6).Text = Date
Call list1disp
End Sub
Private Sub list1def() '将list1的表头初始化
list1.TextMatrix(0, 0) = "品名"
list1.TextMatrix(0, 1) = "规格"
list1.TextMatrix(0, 2) = "导电"
list1.TextMatrix(0, 3) = "硬度"
list1.TextMatrix(0, 4) = "数量"
list1.TextMatrix(0, 5) = "单位"
list1.TextMatrix(0, 6) = "出库日期"
list1.TextMatrix(0, 7) = "领料人编码"
list1.TextMatrix(0, 8) = "领料人"
list1.TextMatrix(0, 9) = "经手人"
list1.TextMatrix(0, 10) = "说明"
End Sub
Private Sub clearzore() '将数据项初始化
For i = 0 To 10
Text1(i).Text = ""
Text1(i).BackColor = &HFFC0C0
Next i
End Sub
Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).BackColor = &HC0FFFF
End Sub
Private Sub Text1_LostFocus(Index As Integer)
Text1(Index).BackColor = &HFFC0C0
If Index = 7 Then
person.RecordSource = "select * from person where 编号 = '" + Trim(Text1(7)) + "'"
person.Refresh
If person.Recordset.EOF Then
MsgBox ("库中无此人,请重新输入编号!")
Text1(7).Text = ""
Text1(8).Text = ""
'Text1(7).SetFocus
Else
Text1(8).Text = person.Recordset.Fields(1)
End If
End If
End Sub
Private Sub list1disp()
Dim roww As Integer ''行
roww = 1
list1.Clear
list1.rows = 1
Call list1def
outstorehouse.RecordSource = "select * from outstorehouse"
outstorehouse.Refresh
If outstorehouse.Recordset.EOF = False Then
outstorehouse.Recordset.MoveFirst
End If
Do While outstorehouse.Recordset.EOF = False
list1.rows = list1.rows + 1
list1.TextMatrix(roww, 0) = outstorehouse.Recordset.Fields(0)
list1.TextMatrix(roww, 1) = outstorehouse.Recordset.Fields(1)
list1.TextMatrix(roww, 2) = outstorehouse.Recordset.Fields(2)
list1.TextMatrix(roww, 3) = outstorehouse.Recordset.Fields(3)
list1.TextMatrix(roww, 4) = outstorehouse.Recordset.Fields(4)
list1.TextMatrix(roww, 5) = outstorehouse.Recordset.Fields(5)
list1.TextMatrix(roww, 6) = outstorehouse.Recordset.Fields(6)
list1.TextMatrix(roww, 7) = outstorehouse.Recordset.Fields(7)
list1.TextMatrix(roww, 8) = outstorehouse.Recordset.Fields(8)
list1.TextMatrix(roww, 9) = outstorehouse.Recordset.Fields(9)
list1.TextMatrix(roww, 10) = outstorehouse.Recordset.Fields(10)
roww = roww + 1
outstorehouse.Recordset.MoveNext
Loop
End Sub
5.2.6设置管理员窗体
图5.6管理员窗体设置
与该窗体相关的代码
Dim row1 As Integer '选择某条记录
Dim pd As Integer '判断是否选中某一项记录
Dim datacount As Integer '判断数据库中是否有记录
Private Sub cmdadd_Click() '添加操作员
operater.RecordSource = "select * from operater where 姓名='" & Trim(Text1(0)) & "'"
operater.Refresh
If operater.Recordset.EOF = False Then
MsgBox "该操作员已经存在!!!"
Else
If Option1(0).Value = True Then
czqx = 1
Else
czqx = 2
End If
operater.Recordset.AddNew