⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmdatamake.frm

📁 使用vb来编制仓库管理方面的绝佳例子
💻 FRM
📖 第 1 页 / 共 5 页
字号:
    .Fields(10) = Text1(6)
    .Update
  End With
  For i = 2 To 6
    Text1(i) = ""
  Next i
  Call list2disp("instorehouse") '再显表格
  Command4(0).Enabled = True
  Command2(0).Enabled = False
End Sub


Private Sub Command3_Click(Index As Integer)   '删除操作
  YesNo = MsgBox("删除记录不能恢复,真的删除吗?", vbYesNo)
  If YesNo = 6 Then
    instorehouse.RecordSource = "select * from instorehouse where 自动编号=" + RecNO
    instorehouse.Refresh
    instorehouse.Recordset.Delete
    instorehouse.Recordset.Update
    Call list2disp("instorehouse")
    Else
     Exit Sub
  End If
    If RecNO = RecNO1 Then
    Command4(0).Enabled = False
    End If
    Command3(0).Enabled = False
End Sub

Private Sub Command4_Click(Index As Integer)  '取消操作
  Command4(0).Enabled = False
  instorehouse.RecordSource = "select * from instorehouse where 自动编号=" + RecNO1
  instorehouse.Refresh
  With instorehouse.Recordset
    .Fields(2) = instorehousetext1(0)
    .Fields(3) = instorehousetext1(1)
    .Fields(4) = instorehousetext1(2)
    .Fields(5) = Val(instorehousetext1(3))
    .Fields(10) = instorehousetext1(4)
    .Update
  End With
  Call list2disp("instorehouse")
End Sub

Private Sub Command5_Click(Index As Integer)
  Unload Me
End Sub

Private Sub command6_Click(Index As Integer)  '全部删除
 Dim row1 As Integer
 YesNo = MsgBox("删除记录不能恢复,真的删除吗?", vbYesNo)
  If YesNo = 6 Then
 '删除表格中的数据
  row1 = list2.rows
  For i = 1 To row1 - 1
    instorehouse.RecordSource = "select * from instorehouse where 自动编号=" + Trim(list2.TextMatrix(i, 12))
    instorehouse.Refresh
    instorehouse.Recordset.Delete
    instorehouse.Recordset.Update
   Next i
  '———————————
   Call list2disp("instorehouse")
  Else
    Exit Sub
  End If
   Command2(0).Enabled = False
   Command3(0).Enabled = False
   Command4(0).Enabled = False
   command6(0).Enabled = False
End Sub

Private Sub Form_Load()
Me.Top = (Mainform.Height - Me.Height) / 2 - 800
Me.Left = (Mainform.Width - Me.Width) / 2
Me.Caption = "仓库管理系统→" & "数据管理"
instorehouse.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Storehouse.mdb;Persist Security Info=False"
outstorehouse.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 list2disp("instorehouse")
If list2count = 0 Then
   command6(0).Enabled = False   '判断是否list2中是否有数据来全部删除
   list2.Enabled = False
   Else
   command6(0).Enabled = True
   list2.Enabled = True
 End If
 Command2(0).Enabled = False '修改
 Command3(0).Enabled = False '删除
 Command4(0).Enabled = False '取消
 '对修改的文本框屏蔽
 Text1(2).Enabled = False
 Text1(3).Enabled = False
 Text1(4).Enabled = False
 Text1(5).Enabled = False
 Text1(6).Enabled = False
 
'-------------------------------出库数据管理的代码----------------------
 Call list1disp("outstorehouse")
 If list1count = 0 Then
   CmdDelAll(1).Enabled = False
   list1.Enabled = False
   Else
   CmdDelAll(1).Enabled = True
   list1.Enabled = True
 End If
 CmdModif(1).Enabled = False
 CmdDel(1).Enabled = False
 CmdCanse(1).Enabled = False
 For i = 9 To 19
   Text1(i).Enabled = False
 Next i
'-----------------------------------------------------------------------
'------------------------------库存数据管理的代码-----------------------
Call list3disp("stock")
If list3count = 0 Then
  CmdDelAll3(2).Enabled = False
  list3.Enabled = False
  Else
  CmdDelAll3(2).Enabled = True
  list3.Enabled = True
 End If
CmdModif3(2).Enabled = False
CmdDel3(2).Enabled = False
CmdCanse3(2).Enabled = False
 Text1(22).Enabled = False
 Text1(23).Enabled = False
 Text1(24).Enabled = False
 Text1(25).Enabled = False
'-----------------------------------------------------------------------
End Sub

Private Sub list2_Click()
 Text1(2).Enabled = True
 Text1(3).Enabled = True
 Text1(4).Enabled = True
 Text1(5).Enabled = True
 Text1(6).Enabled = True
 Dim row1 As Integer
 row1 = list2.Row
 instorehouse.RecordSource = "select * from instorehouse where 自动编号=" + Trim(list2.TextMatrix(row1, 12))
 instorehouse.Refresh
 With instorehouse.Recordset
   Text1(2) = .Fields(2)
   Text1(3) = .Fields(3)
   Text1(4) = .Fields(4)
   Text1(5) = .Fields(5)
   Text1(6) = .Fields(10)
 End With
 For i = 2 To 6    '用来修改时将当前的数保存,以便取消用
     instorehousetext(i - 2) = Text1(i)
 Next i
 RecNO = Trim(list2.TextMatrix(row1, 12))
 Text1(2).SetFocus
 Command3(0).Enabled = True
 Command2(0).Enabled = True
End Sub



Private Sub Text1_GotFocus(Index As Integer)
Text1(Index).BackColor = &HC0FFFF
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index))
End Sub

Private Sub Text1_LostFocus(Index As Integer)
  Text1(Index).BackColor = &HFFC0C0
End Sub
Private Sub clearzore()
  For i = 0 To 25
     Text1(i) = ""
     Text1(i).BackColor = &HFFC0C0
  Next
End Sub
Private Sub list2disp(StrSQL As String)
  Dim roww As Integer           ''行
  roww = 1
  list2.Clear
  list2.rows = 1
  Call list2def
  instorehouse.RecordSource = StrSQL
  instorehouse.Refresh
  If instorehouse.Recordset.EOF = False Then
    instorehouse.Recordset.MoveFirst
    list2count = instorehouse.Recordset.RecordCount
    Else
    list2count = 0
  End If
  Do While instorehouse.Recordset.EOF = False
    list2.rows = list2.rows + 1
    list2.TextMatrix(roww, 0) = instorehouse.Recordset.Fields(0)
    list2.TextMatrix(roww, 1) = instorehouse.Recordset.Fields(1)
    list2.TextMatrix(roww, 2) = instorehouse.Recordset.Fields(2)
    list2.TextMatrix(roww, 3) = instorehouse.Recordset.Fields(3)
    list2.TextMatrix(roww, 4) = instorehouse.Recordset.Fields(4)
    list2.TextMatrix(roww, 5) = instorehouse.Recordset.Fields(5)
    list2.TextMatrix(roww, 6) = instorehouse.Recordset.Fields(6)
    list2.TextMatrix(roww, 7) = instorehouse.Recordset.Fields(7)
    list2.TextMatrix(roww, 8) = instorehouse.Recordset.Fields(8)
    list2.TextMatrix(roww, 9) = instorehouse.Recordset.Fields(9)
    list2.TextMatrix(roww, 10) = instorehouse.Recordset.Fields(10)
    list2.TextMatrix(roww, 11) = instorehouse.Recordset.Fields(11)
    list2.TextMatrix(roww, 12) = instorehouse.Recordset.Fields(12)
    roww = roww + 1
    instorehouse.Recordset.MoveNext
  Loop
End Sub
Private Sub list2def() '将list2的表头初始化  入库
  list2.TextMatrix(0, 0) = "品名"
  list2.TextMatrix(0, 1) = "规格"
  list2.TextMatrix(0, 2) = "导电"
  list2.TextMatrix(0, 3) = "硬度"
  list2.TextMatrix(0, 4) = "数量"
  list2.TextMatrix(0, 5) = "单位"
  list2.TextMatrix(0, 6) = "入库日期"
  list2.TextMatrix(0, 7) = "入料人编号"
  list2.TextMatrix(0, 8) = "入料人"
  list2.TextMatrix(0, 9) = "经手人"
  list2.TextMatrix(0, 10) = "说明"
  list2.TextMatrix(0, 11) = "入库标识"
  list2.TextMatrix(0, 12) = "自动编号"
End Sub

'---------------------------------出库操作的代码----------------------------------------------------
Private Sub cmddel_Click(Index As Integer)
  YesNo = MsgBox("删除记录不能恢复,真的删除吗?", vbYesNo)
  If YesNo = 6 Then
    outstorehouse.RecordSource = "select * from outstorehouse where 编号=" + recNO2_1
    outstorehouse.Refresh
    outstorehouse.Recordset.Delete
    outstorehouse.Recordset.Update
    Call list1disp("outstorehouse")
    If list1count = 0 Then CmdDelAll(1).Enabled = False
    Else
     Exit Sub
  End If
    If RecNO = RecNO1 Then
    CmdCanse(1).Enabled = False
    End If
   CmdDel(1).Enabled = False
End Sub

Private Sub CmdCanse_Click(Index As Integer)
  CmdCanse(1).Enabled = False
  outstorehouse.RecordSource = "select * from outstorehouse where 编号=" + recno2_2
  outstorehouse.Refresh
  With outstorehouse.Recordset
    For i = 2 To 11
     .Fields(i) = outstorehousetext1(i - 2)
    Next i
     .Fields(17) = outstorehousetext1(10)
     .Update
  End With
  Call list1disp("outstorehouse")
End Sub

Private Sub CmdModif_Click(Index As Integer)
  If IsNumeric(Text1(11)) = False Then
    MsgBox ("要修改的数值输入有误!")
    Text1(11).SetFocus
    Exit Sub
  End If
  For i = 0 To 10
    outstorehousetext1(i) = outstorehousetext(i)
  Next i
  recno2_2 = recNO2_1
  outstorehouse.RecordSource = "select * from outstorehouse where 编号=" + recno2_2
  outstorehouse.Refresh
  With outstorehouse.Recordset
    For i = 9 To 18
     .Fields(i - 7) = Text1(i)
    Next i
    .Fields(17) = Text1(19)
    .Update
  End With
  For i = 9 To 19
    Text1(i) = ""
  Next i
  Call list1disp("outstorehouse") '再显表格
  CmdCanse(1).Enabled = True
  CmdModif(1).Enabled = False
End Sub

Private Sub CmdDelAll_Click(Index As Integer)
 Dim row1 As Integer
 YesNo = MsgBox("删除记录不能恢复,真的删除吗?", vbYesNo)
  If YesNo = 6 Then
 '删除表格中的数据
  row1 = list1.rows
  For i = 1 To row1 - 1
    outstorehouse.RecordSource = "select * from outstorehouse where 编号=" + Trim(list1.TextMatrix(i, 18))
    outstorehouse.Refresh
    outstorehouse.Recordset.Delete
    outstorehouse.Recordset.Update
   Next i
  '———————————
   Call list1disp("outstorehouse")
   If list1count = 0 Then CmdDelAll(1).Enabled = False
  Else
    Exit Sub
  End If
   Command2(0).Enabled = False
   Command3(0).Enabled = False
   Command4(0).Enabled = False
End Sub

Private Sub CmdFind_Click(Index As Integer)  '出库的查询操作
Dim list1SQL As String
 If Text1(7) = "" Or Text1(8) = "" Then
   MsgBox ("品名和规格不能为空!")
   Text1(7).SelStart = 0
   Text1(7).SelLength = Len(Text1(7))
   Text1(7).SetFocus
   Exit Sub
 End If
 list1SQL = "select * from outstorehouse where 品名='" + Trim(Text1(7)) + "' and 规格='" + Trim(Text1(8)) + "'"
 Call list1disp(list1SQL)
 If list1count = 0 Then
   CmdDelAll(1).Enabled = False   '判断是否list2中是否有数据来全部删除
   Text1(7).SetFocus
   list1.Enabled = False   '控制list2是否可以单击
   Else
   CmdDelAll(1).Enabled = True
   list1.Enabled = True
 End If
End Sub
Private Sub list1_Click()
 For i = 9 To 19
   Text1(i).Enabled = True
 Next i
 Dim row1 As Integer
 row1 = list1.Row
 outstorehouse.RecordSource = "select * from outstorehouse where 编号=" + Trim(list1.TextMatrix(row1, 18))
 outstorehouse.Refresh
 If outstorehouse.Recordset.E

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -