frmStock.frm
上传用户:xianglong
上传日期:2022-06-19
资源大小:1105k
文件大小:20k
- VERSION 5.00
- Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
- Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
- Begin VB.Form frmMaterial
- BorderStyle = 1 'Fixed Single
- Caption = "物料信息的建立与维护"
- ClientHeight = 6780
- ClientLeft = 2040
- ClientTop = 660
- ClientWidth = 8565
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 6780
- ScaleWidth = 8565
- StartUpPosition = 1 '所有者中心
- Begin VB.CommandButton comDate
- Height = 600
- Left = 2160
- Picture = "frmStock.frx":0000
- Style = 1 'Graphical
- TabIndex = 23
- Top = 2280
- Width = 615
- End
- Begin MSComctlLib.Toolbar Tlbar
- Align = 1 'Align Top
- Height = 810
- Left = 0
- TabIndex = 0
- Top = 0
- Width = 8565
- _ExtentX = 15108
- _ExtentY = 1429
- ButtonWidth = 1032
- ButtonHeight = 1376
- Appearance = 1
- Style = 1
- ImageList = "ImList2"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 9
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "增加"
- Key = "Add"
- ImageIndex = 1
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "修改"
- Key = "Edit"
- ImageIndex = 2
- EndProperty
- BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "保存"
- Key = "Save"
- ImageIndex = 3
- EndProperty
- BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "删除"
- Key = "Del"
- ImageIndex = 4
- EndProperty
- BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "退出"
- Key = "Exit"
- ImageIndex = 5
- EndProperty
- EndProperty
- End
- Begin VB.TextBox txtDate
- Height = 320
- Left = 1200
- TabIndex = 13
- Top = 2520
- Width = 975
- End
- Begin MSComCtl2.MonthView MonthView1
- Height = 2220
- Left = 2160
- TabIndex = 12
- Top = 2760
- Width = 4065
- _ExtentX = 7170
- _ExtentY = 3916
- _Version = 393216
- ForeColor = -2147483630
- BackColor = 8438015
- Appearance = 1
- StartOfWeek = 25559041
- CurrentDate = 39125
- End
- Begin VB.Data d1
- Caption = "Data1"
- Connect = "Access"
- DatabaseName = ""
- DefaultCursorType= 0 '缺省游标
- DefaultType = 2 '使用 ODBC
- Exclusive = 0 'False
- Height = 372
- Left = 2520
- Options = 0
- ReadOnly = 0 'False
- RecordsetType = 1 'Dynaset
- RecordSource = ""
- Top = 5040
- Visible = 0 'False
- Width = 1692
- End
- Begin VB.TextBox txtChange
- Height = 288
- Left = 7200
- TabIndex = 10
- Top = 1800
- Width = 1095
- End
- Begin VB.TextBox txtVol
- Height = 288
- Left = 5160
- TabIndex = 9
- Top = 1320
- Width = 975
- End
- Begin VB.TextBox txtVolPrice
- Height = 288
- Left = 5160
- TabIndex = 8
- Top = 1800
- Width = 975
- End
- Begin VB.TextBox txtToday
- Height = 288
- Left = 3240
- TabIndex = 7
- Top = 1800
- Width = 975
- End
- Begin VB.TextBox txtLast
- Height = 288
- Left = 3240
- TabIndex = 6
- Top = 1320
- Width = 975
- End
- Begin VB.TextBox txtName
- Height = 288
- Left = 1200
- TabIndex = 5
- Top = 1800
- Width = 975
- End
- Begin VB.Frame Frame2
- Caption = "物料信息"
- ForeColor = &H00000000&
- Height = 2172
- Left = 120
- TabIndex = 3
- Top = 840
- Width = 8295
- Begin VB.TextBox txtInventory
- Height = 288
- Left = 7080
- TabIndex = 26
- Top = 1680
- Width = 1095
- End
- Begin VB.ComboBox Combo1
- Height = 300
- Left = 7080
- TabIndex = 11
- Top = 480
- Width = 1095
- End
- Begin VB.TextBox txtCode
- Height = 288
- Left = 1080
- TabIndex = 4
- Top = 480
- Width = 975
- End
- Begin VB.Label Label9
- BackStyle = 0 'Transparent
- Caption = "库 存:"
- ForeColor = &H00000000&
- Height = 255
- Left = 6120
- TabIndex = 25
- Top = 1680
- Width = 975
- End
- Begin VB.Label Label6
- BackStyle = 0 'Transparent
- Caption = "物料名称:"
- ForeColor = &H00000000&
- Height = 255
- Left = 120
- TabIndex = 22
- Top = 960
- Width = 855
- End
- Begin VB.Label Label2
- BackStyle = 0 'Transparent
- Caption = "昨日金额:"
- ForeColor = &H00000000&
- Height = 255
- Left = 2160
- TabIndex = 21
- Top = 480
- Width = 855
- End
- Begin VB.Label Label3
- BackStyle = 0 'Transparent
- Caption = "物料类型:"
- ForeColor = &H00000000&
- Height = 255
- Index = 0
- Left = 6120
- TabIndex = 20
- Top = 480
- Width = 975
- End
- Begin VB.Label Label7
- BackStyle = 0 'Transparent
- Caption = "今日金额:"
- ForeColor = &H00000000&
- Height = 255
- Left = 2160
- TabIndex = 19
- Top = 960
- Width = 855
- End
- Begin VB.Label Label8
- BackStyle = 0 'Transparent
- Caption = "日均额:"
- ForeColor = &H00000000&
- Height = 255
- Left = 4200
- TabIndex = 18
- Top = 960
- Width = 735
- End
- Begin VB.Label Label5
- BackStyle = 0 'Transparent
- Caption = "涨 跌:"
- ForeColor = &H00000000&
- Height = 255
- Left = 6120
- TabIndex = 17
- Top = 960
- Width = 975
- End
- Begin VB.Label Label10
- BackStyle = 0 'Transparent
- Caption = "日 期:"
- ForeColor = &H00000000&
- Height = 255
- Left = 120
- TabIndex = 16
- Top = 1680
- Width = 855
- End
- Begin VB.Label Label4
- BackStyle = 0 'Transparent
- Caption = "日耗量:"
- ForeColor = &H00000000&
- Height = 255
- Left = 4200
- TabIndex = 15
- Top = 480
- Width = 735
- End
- Begin VB.Label Label1
- Caption = "物料代码:"
- ForeColor = &H00000000&
- Height = 255
- Left = 120
- TabIndex = 14
- Top = 480
- Width = 855
- End
- End
- Begin MSComctlLib.StatusBar sbr
- Align = 2 'Align Bottom
- Height = 375
- Left = 0
- TabIndex = 1
- Top = 6405
- Width = 8565
- _ExtentX = 15108
- _ExtentY = 661
- _Version = 393216
- BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
- NumPanels = 1
- BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
- EndProperty
- EndProperty
- End
- Begin VB.Frame Frame1
- Caption = "物料列表"
- ForeColor = &H00000000&
- Height = 3135
- Left = 120
- TabIndex = 2
- Top = 3120
- Width = 8295
- Begin MSComctlLib.ImageList ImList2
- Left = 480
- Top = 1200
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 32
- ImageHeight = 32
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 5
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmStock.frx":08CA
- Key = "Add"
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmStock.frx":11A4
- Key = "Edit"
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmStock.frx":1A7E
- Key = "Save"
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmStock.frx":2358
- Key = "Del"
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "frmStock.frx":2C32
- Key = "Exit"
- EndProperty
- EndProperty
- End
- Begin MSFlexGridLib.MSFlexGrid grid
- Bindings = "frmStock.frx":350C
- Height = 2775
- Left = 120
- TabIndex = 24
- Top = 240
- Width = 8055
- _ExtentX = 14208
- _ExtentY = 4895
- _Version = 393216
- Cols = 1
- FixedCols = 0
- BackColor = 16777215
- ForeColor = 16711680
- BackColorFixed = -2147483624
- BackColorSel = 16744576
- ForeColorSel = 16777215
- BackColorBkg = 16777215
- GridColor = 0
- FillStyle = 1
- GridLinesFixed = 1
- SelectionMode = 1
- AllowUserResizing= 3
- End
- End
- End
- Attribute VB_Name = "frmMaterial"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Public dbs As Database
- Public filename As String
- Public rec As Recordset
- Public rec1 As Recordset
- Public xg As Boolean
- Dim TotalRecord As Integer
- Private Sub comDate_Click()
- MonthView1.Visible = True
- End Sub
- Private Sub Form_Load()
- Dim MaterialType As Variant
- MaterialType = Array("甲等", "乙等")
- For i = 0 To 1
- Combo1.AddItem MaterialType(i)
- Next i
- filename = App.Path & "dbmaterialinfo2007.mdb"
- Set dbs = OpenDatabase(filename)
- Set rec = dbs.OpenRecordset("物料信息变化表")
- Set rec1 = dbs.OpenRecordset("物料信息表")
- D1.DatabaseName = filename
-
- Tlbar.Buttons(2).Enabled = False
- Tlbar.Buttons(3).Enabled = False
- Tlbar.Buttons(5).Enabled = False
- AllDisEnabled
- Combo1.Enabled = False
- MonthView1.Visible = False
- comDate.Enabled = False
-
- D1.RecordSource = "SELECT 物料信息变化表.ID ,物料信息变化表.Code as 物料代码,Name as 物料名称,Last as 昨日金额,Today as 今日金额,Volume as 日耗量,[Volume Price] as 日均额,Change as 涨跌,TypeName as 物料类型,Inventory as 库存,Day as 日期 FROM 物料信息变化表,物料信息表,物料类型信息表 WHERE 物料信息变化表.Code=物料信息表.Code and 物料信息表.TypeId=物料类型信息表.ID ORDER BY 物料信息变化表.ID"
- D1.Refresh
- grid.ColWidth(0) = 300
- rec.MoveLast
- TotalRecord = rec.RecordCount
- rec.MoveFirst
- sbr.Panels(1).Text = " 共 :" & TotalRecord & "条记录"
- End Sub
- Private Sub grid_Click()
- If grid.Row = 0 Then Exit Sub
- txtCode.Text = grid.TextMatrix(grid.Row, 1)
- txtName.Text = grid.TextMatrix(grid.Row, 2)
- txtLast.Text = grid.TextMatrix(grid.Row, 3)
- txtToday.Text = grid.TextMatrix(grid.Row, 4)
- txtVol.Text = grid.TextMatrix(grid.Row, 5)
- txtVolPrice.Text = grid.TextMatrix(grid.Row, 6)
- txtChange.Text = grid.TextMatrix(grid.Row, 7)
- txtInventory.Text = grid.TextMatrix(grid.Row, 9)
- txtDate.Text = grid.TextMatrix(grid.Row, 10)
-
- AllDisEnabled
- comDate.Enabled = False
- If grid.TextMatrix(grid.Row, 8) = "甲等" Then
- Combo1.ListIndex = 0
- Else
- Combo1.ListIndex = 1
- End If
-
-
- Tlbar.Buttons(3).Enabled = True
- Tlbar.Buttons(5).Enabled = False
- Combo1.Enabled = False
- End Sub
- Private Sub MonthView1_DateClick(ByVal DateClicked As Date)
- txtDate.Text = MonthView1.Value
- MonthView1.Visible = False
- End Sub
- Private Sub Tlbar_ButtonClick(ByVal Button As MSComctlLib.Button)
-
- Select Case Button.key
- Case "Add"
- add
- Case "Save"
- save
- Case "Del"
- If txtCode.Text = "" Then Exit Sub
- r = MsgBox("确定要删除【" & txtName.Text & "】?(Y/N)", vbQuestion + vbOKCancel + vbDefaultButton1, "自动配料系统")
- If r = 1 Then
-
- dbs.Execute "DELETE * FROM " & " [物料信息变化表] WHERE Code='" & grid.TextMatrix(grid.Row, 2) & "'"
-
- D1.Refresh
- add
-
- If Not D1.Recordset.EOF Then
- D1.Recordset.MoveLast
- End If
-
- TotalRecord = D1.Recordset.RecordCount
- sbr.Panels(1).Text = " 共 :" & TotalRecord & "条记录。"
- End If
- Clear
-
- Case "Edit"
- Edit
- Case "Exit"
- Unload Me
- dbs.Close
-
- End Select
- End Sub
- Private Sub add()
- AllEnabled
- AllClear
- comDate.Enabled = True
- txtCode.SetFocus
- xg = False
- Tlbar.Buttons(5).Enabled = True
- Combo1.Enabled = True
- End Sub
- Private Sub save()
- D1.DatabaseName = filename
- Set rec = dbs.OpenRecordset("物料信息变化表")
- Set rec1 = dbs.OpenRecordset("物料信息表")
- If Trim(txtCode.Text) = "" Or Trim(txtLast.Text) = "" Or Trim(txtName.Text) = "" & _
- "" Or Trim(txtToday.Text) = "" & _
- "" Or Trim(txtVolPrice.Text) = "" Or Trim(txtDate.Text) = "" Or Val(txtDate.Text) < #1/1/100# Or Val(txtDate.Text) > #12/31/9999# Then
- r = MsgBox("数据非法,不能保存!", 0 + 16, "自动配料系统")
- Exit Sub
- End If
-
-
- If xg = False Then
- rec.AddNew
- rec.Fields("Code") = txtCode.Text
- rec.Fields("Last") = Val(txtLast.Text)
- rec.Fields("Volume") = Val(txtVol.Text)
- rec.Fields("Today") = Val(txtToday.Text)
- rec.Fields("Change") = Val(txtChange.Text)
- rec.Fields("Volume Price") = Val(txtVolPrice.Text)
- rec.Fields("Inventory") = Val(txtInventory.Text)
- rec.Fields("Day") = txtDate.Text
- rec.Update
-
- rec1.Index = "PrimaryKey"
- rec1.Seek "=", txtCode.Text
- If rec1.NoMatch Then
- rec1.AddNew
- rec1.Fields("Code") = txtCode.Text
- rec1.Fields("Name") = txtName.Text
- rec1.Fields("TypeId") = Combo1.ListIndex + 1
- rec1.Update
- End If
- D1.Refresh
- If Not D1.Recordset.EOF Then
- D1.Recordset.MoveLast
- End If
- TotalRecord = D1.Recordset.RecordCount
- sbr.Panels(1).Text = " 共 :" & TotalRecord & "条记录。"
-
- Else
- rec.Index = "PrimaryKey"
- rec.Seek "=", grid.TextMatrix(grid.Row, 0)
- rec.Edit
- rec.Fields("Code") = txtCode.Text
- rec.Fields("Last") = Val(txtLast.Text)
- rec.Fields("Volume") = Val(txtVol.Text)
- rec.Fields("Today") = txtToday.Text
- rec.Fields("Change") = Val(txtChange.Text)
- rec.Fields("Volume Price") = Val(txtVolPrice.Text)
- rec.Update
-
- rec1.Index = "PrimaryKey"
- rec1.Seek "=", txtCode.Text
- If Not rec1.NoMatch Then
- rec1.Edit
- rec1.Fields("Code") = txtCode.Text
- rec1.Fields("Name") = txtName.Text
- rec1.Fields("TypeId") = Combo1.ListIndex + 1
- rec1.Update
- End If
- D1.Refresh
- End If
- Clear
- End Sub
- Private Sub txt_Change(Index As Integer)
- Tlbar.Buttons(5).Enabled = True
- End Sub
- Private Sub Edit()
- xg = True
- AllEnabled
- Tlbar.Buttons(5).Enabled = True
- Combo1.Enabled = True
- comDate.Enabled = True
- End Sub
- Private Sub Clear()
- AllClear
- AllDisEnabled
- Tlbar.Buttons(3).Enabled = False
- Tlbar.Buttons(5).Enabled = False
- Combo1.Enabled = False
- comDate.Enabled = False
- End Sub
- Private Sub AllClear()
- txtCode.Text = ""
- txtLast.Text = ""
- txtName.Text = ""
- txtVol.Text = ""
- txtToday.Text = ""
- txtChange.Text = ""
- txtVolPrice.Text = ""
- txtInventory.Text = ""
- End Sub
- Private Sub AllDisEnabled()
- txtCode.Enabled = False
- txtLast.Enabled = False
- txtDate.Enabled = False
- txtVol.Enabled = False
- txtName.Enabled = False
- txtToday.Enabled = False
- txtChange.Enabled = False
- txtVolPrice.Enabled = False
- txtInventory.Enabled = False
- End Sub
- Private Sub AllEnabled()
- txtCode.Enabled = True
- txtLast.Enabled = True
- txtDate.Enabled = True
- txtName.Enabled = True
- txtVol.Enabled = True
- txtToday.Enabled = True
- txtChange.Enabled = True
- txtVolPrice.Enabled = True
- txtInventory.Enabled = True
- End Sub
- Private Sub txtDate_LostFocus()
- If Trim(txtDate.Text) = "" Then
- MsgBox "请输入日期!", 48, "提示"
- Text3.SetFocus
- Else
- If Not IsDate(txtDate.Text) Then
- MsgBox "请输入日期型格式!", 48, "提示"
- txtDate.SetFocus
- Else
- txtDate.Text = Format(txtDate.Text, "yyyy-mm-dd")
- End If
- End If
- End Sub