📄 frmgoodinfomanage.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FrmGoodInfoManage
BorderStyle = 3 'Fixed Dialog
Caption = "商品信息管理"
ClientHeight = 6570
ClientLeft = 45
ClientTop = 330
ClientWidth = 7725
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 6570
ScaleWidth = 7725
ShowInTaskbar = 0 'False
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 3360
Top = 6240
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=StockDB"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "StockDB"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = $"FrmGoodInfoManage.frx":0000
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Frame Frame3
Caption = "商品信息查询"
Height = 735
Left = 120
TabIndex = 14
Top = 5400
Width = 7455
Begin VB.CommandButton Command1
Caption = "查询"
Height = 255
Left = 5640
TabIndex = 19
Top = 240
Width = 975
End
Begin VB.ComboBox CB_QueryClass
Height = 300
Left = 3960
TabIndex = 18
Top = 240
Width = 1335
End
Begin VB.TextBox txtQueryName
Height = 375
Left = 1200
TabIndex = 16
Top = 240
Width = 1455
End
Begin VB.Label Label8
Caption = "商品类别:"
Height = 255
Left = 3000
TabIndex = 17
Top = 360
Width = 975
End
Begin VB.Label Label7
Caption = "商品名称:"
Height = 255
Left = 240
TabIndex = 15
Top = 360
Width = 1455
End
End
Begin VB.Frame Frame2
Caption = "商品详细信息"
Height = 1695
Left = 120
TabIndex = 2
Top = 3600
Width = 7455
Begin VB.CommandButton Command3
Caption = "删除"
Height = 255
Left = 3840
TabIndex = 21
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "更新"
Height = 255
Left = 2400
TabIndex = 20
Top = 1320
Width = 1095
End
Begin VB.TextBox txtStock
Height = 350
Left = 5880
TabIndex = 13
Top = 720
Width = 1095
End
Begin VB.TextBox txtPrice
Height = 350
Left = 3360
TabIndex = 10
Top = 705
Width = 975
End
Begin VB.TextBox txtGoodUnitName
Height = 350
Left = 1080
TabIndex = 8
Top = 720
Width = 975
End
Begin VB.ComboBox CB_GoodClassName
Height = 300
Left = 3840
TabIndex = 6
Top = 240
Width = 1695
End
Begin VB.TextBox txtGoodName
Height = 350
Left = 1080
TabIndex = 4
Top = 225
Width = 1455
End
Begin VB.Line Line1
X1 = 0
X2 = 7440
Y1 = 1200
Y2 = 1200
End
Begin VB.Label Label6
Caption = "商品库存:"
Height = 255
Left = 4920
TabIndex = 12
Top = 840
Width = 975
End
Begin VB.Label Label5
Caption = "元"
Height = 375
Left = 4440
TabIndex = 11
Top = 840
Width = 735
End
Begin VB.Label Label4
Caption = "商品单价:"
Height = 375
Left = 2400
TabIndex = 9
Top = 840
Width = 1335
End
Begin VB.Label Label3
Caption = "商品单位:"
Height = 375
Left = 120
TabIndex = 7
Top = 840
Width = 1095
End
Begin VB.Label Label2
Caption = "商品类别:"
Height = 375
Left = 2880
TabIndex = 5
Top = 355
Width = 975
End
Begin VB.Label Label1
Caption = "商品名称:"
Height = 375
Left = 120
TabIndex = 3
Top = 360
Width = 1215
End
End
Begin VB.Frame Frame1
Caption = "商品信息浏览"
Height = 3615
Left = 120
TabIndex = 0
Top = 0
Width = 7455
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "FrmGoodInfoManage.frx":00E1
Height = 3135
Left = 120
TabIndex = 1
Top = 240
Width = 7215
_ExtentX = 12726
_ExtentY = 5530
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "FrmGoodInfoManage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
querySql = "select goodName as 商品名称,goodClassName as 商品类别,goodUnit as 商品单位,oneGoodPrice as 商品单价,stock as 商品库存,goodIntroduction as 商品介绍 from goodInfo,goodClass where goodClass.goodClassId = goodInfo.goodClassId"
If Me.txtQueryName.Text <> "" Then
querySql = querySql & " and goodName like '%" & Me.txtQueryName.Text & "%'"
End If
If Me.CB_QueryClass.Text <> "" Then
querySql = querySql & " and goodClassName = '" & Me.CB_QueryClass.Text & "'"
End If
Me.Adodc1.RecordSource = querySql
Me.Adodc1.Refresh
Me.DataGrid1.ReBind
End Sub
Private Sub Command2_Click()
Dim updateSql As String
Dim querySql As String
Dim oldGoodName As String '保存原来的商品名称
Dim goodClassId As Integer '保存商品类别编号信息
Dim vbResult As VbMsgBoxResult
vbResult = MsgBox("真的决定更新当前记录信息吗?", vbOKCancel, "更新提示")
If vbResult = vbOK Then
oldGoodName = Me.Adodc1.Recordset.Fields("商品名称") '取得该商品原来的名称
goodClassId = getClassIdByName(Me.CB_GoodClassName.Text) '取得新的商品类别信息
updateSql = "update goodInfo set goodName = '" & Me.txtGoodName.Text & "',goodClassId = " & goodClassId & ",goodUnit = '" & Me.txtGoodUnitName.Text & "',oneGoodPrice = " & Me.txtPrice.Text & ",stock = " & Me.txtStock.Text & " where goodName = '" & oldGoodName & "'"
Call check_condatabase
cn.Execute (updateSql)
MsgBox "商品信息更新成功!"
querySql = "select goodName as 商品名称,goodClassName as 商品类别,goodUnit as 商品单位,oneGoodPrice as 商品单价,stock as 商品库存,goodIntroduction as 商品介绍 from goodInfo,goodClass where goodClass.goodClassId = goodInfo.goodClassId"
If Me.txtQueryName.Text <> "" Then
querySql = querySql & " and goodName like '%" & Me.txtQueryName.Text & "%'"
End If
If Me.CB_QueryClass.Text <> "" Then
querySql = querySql & " and goodClassName = '" & Me.CB_QueryClass.Text & "'"
End If
Me.Adodc1.RecordSource = querySql
Me.Adodc1.Refresh
Me.DataGrid1.ReBind
End If
End Sub
Private Sub Command3_Click()
Dim vbResult As VbMsgBoxResult
Dim deleteGoodName As String
Dim delteSql As String
If Not Me.Adodc1.Recordset.BOF And Not Me.Adodc1.Recordset.EOF Then
vbResult = MsgBox("真的决定要删除当前的记录信息吗?", vbOKCancel)
If vbResult = vbOK Then
' Me.Adodc1.Recordset.Delete
deleteGoodName = Me.Adodc1.Recordset.Fields("商品名称")
deleteSql = "delete from goodInfo where goodName = '" & deleteGoodName & "'"
Call check_condatabase
cn.Execute (deleteSql)
MsgBox "商品信息删除成功!"
End If
querySql = "select goodName as 商品名称,goodClassName as 商品类别,goodUnit as 商品单位,oneGoodPrice as 商品单价,stock as 商品库存,goodIntroduction as 商品介绍 from goodInfo,goodClass where goodClass.goodClassId = goodInfo.goodClassId"
If Me.txtQueryName.Text <> "" Then
querySql = querySql & " and goodName like '%" & Me.txtQueryName.Text & "'%"
End If
If Me.CB_QueryClass.Text <> "" Then
querySql = querySql & " and goodClassName = '" & Me.CB_QueryClass.Text & "'"
End If
Me.Adodc1.RecordSource = querySql
Me.Adodc1.Refresh
Me.DataGrid1.ReBind
Else
MsgBox "对不起,不存在商品信息供删除!"
End If
End Sub
Private Sub DataGrid1_Click()
Me.txtGoodName.Text = Me.Adodc1.Recordset.Fields("商品名称")
Me.CB_GoodClassName.Text = Me.Adodc1.Recordset.Fields("商品类别")
Me.txtGoodUnitName.Text = Me.Adodc1.Recordset.Fields("商品单位")
Me.txtPrice.Text = Me.Adodc1.Recordset.Fields("商品单价")
Me.txtStock.Text = Me.Adodc1.Recordset.Fields("商品库存")
End Sub
Private Sub Form_Load()
Dim goodClassRs As ADODB.Recordset
Call check_condatabase
Set goodClassRs = cn.Execute("select goodClassName from goodClass")
While Not goodClassRs.EOF
Me.CB_GoodClassName.AddItem goodClassRs("goodClassName")
Me.CB_QueryClass.AddItem goodClassRs("goodClassName")
goodClassRs.MoveNext
Wend
End Sub
'Download by http://www.codefans.net
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -