?? frmaddgood.frm
字號:
VERSION 5.00
Begin VB.Form FrmAddGood
BorderStyle = 3 'Fixed Dialog
Caption = "商品信息添加"
ClientHeight = 6495
ClientLeft = 45
ClientTop = 330
ClientWidth = 6465
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 6495
ScaleWidth = 6465
ShowInTaskbar = 0 'False
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 3600
TabIndex = 15
Top = 5400
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 1680
TabIndex = 14
Top = 5400
Width = 1095
End
Begin VB.Frame Frame1
Caption = "商品信息添加"
Height = 5055
Left = 120
TabIndex = 0
Top = 120
Width = 5895
Begin VB.TextBox txtIntroduction
Height = 1455
Left = 1440
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 13
Top = 3360
Width = 3255
End
Begin VB.TextBox txtStock
Height = 270
Left = 1440
TabIndex = 11
Top = 2760
Width = 1695
End
Begin VB.TextBox txtPrice
Height = 375
Left = 1440
TabIndex = 8
Top = 2040
Width = 1575
End
Begin VB.ComboBox CB_GoodUnit
Height = 300
Left = 1440
TabIndex = 5
Top = 1440
Width = 1215
End
Begin VB.ComboBox CB_GoodClass
Height = 300
Left = 1440
TabIndex = 4
Top = 840
Width = 2535
End
Begin VB.TextBox txtGoodName
Height = 375
Left = 1440
TabIndex = 2
Top = 240
Width = 2535
End
Begin VB.Label Label7
Caption = "商品介紹:"
Height = 495
Left = 240
TabIndex = 12
Top = 3360
Width = 1095
End
Begin VB.Label Label6
Caption = "商品庫存:"
Height = 495
Left = 240
TabIndex = 10
Top = 2760
Width = 1095
End
Begin VB.Label Label5
Caption = "元"
Height = 375
Left = 3120
TabIndex = 9
Top = 2040
Width = 615
End
Begin VB.Label Label4
Caption = "商品單價:"
Height = 495
Left = 240
TabIndex = 7
Top = 2040
Width = 1095
End
Begin VB.Label Label3
Caption = "商品單位:"
Height = 495
Left = 240
TabIndex = 6
Top = 1440
Width = 1095
End
Begin VB.Label Label2
Caption = "商品類別:"
Height = 495
Left = 240
TabIndex = 3
Top = 960
Width = 1095
End
Begin VB.Label Label1
Caption = "商品名稱:"
Height = 495
Left = 240
TabIndex = 1
Top = 360
Width = 1095
End
End
End
Attribute VB_Name = "FrmAddGood"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim sql As String
Dim goodInfoRs As ADODB.Recordset
Dim goodNameRs As ADODB.Recordset
Dim goodClassInfoArray As Variant
If Me.txtGoodName.Text = "" Then
MsgBox "請輸入商品名稱!"
Me.txtGoodName.SetFocus
Exit Sub
End If
If Me.CB_GoodClass.Text = "" Then
MsgBox "請選擇商品類別!"
Exit Sub
End If
If Me.CB_GoodUnit.Text = "" Then
MsgBox "請選擇商品單位信息!"
Exit Sub
End If
If Me.txtPrice.Text = "" Then
MsgBox "請輸入商品單價!"
Me.txtPrice.SetFocus
Exit Sub
End If
If Me.txtStock.Text = "" Then
MsgBox "請輸入商品庫存信息!"
Me.txtStock.SetFocus
Exit Sub
End If
Call check_condatabase
sql = "select goodName from goodInfo where goodName = '" & Me.txtGoodName.Text & "'"
Set goodNameRs = cn.Execute(sql)
If Not goodNameRs.EOF Then
MsgBox "對不起,此商品名稱的信息系統(tǒng)已經(jīng)存在了!"
Exit Sub
End If
goodNameRs.Close
Set goodNameRs = Nothing
sql = "select * from goodInfo"
Set goodInfoRs = New ADODB.Recordset
Set goodInfoRs.ActiveConnection = cn
goodInfoRs.LockType = adLockOptimistic
goodInfoRs.CursorType = adOpenKeyset
goodInfoRs.Open sql
goodInfoRs.AddNew '添加新商品信息
goodInfoRs("goodName") = Me.txtGoodName.Text
goodClassInfoArray = Split(Me.CB_GoodClass.Text, "-")
goodInfoRs("goodClassId") = CInt(goodClassInfoArray(0))
goodInfoRs("goodUnit") = Me.CB_GoodUnit.Text
goodInfoRs("oneGoodPrice") = CCur(Me.txtPrice.Text)
goodInfoRs("stock") = CInt(Me.txtStock.Text)
goodInfoRs("goodIntroduction") = Me.txtIntroduction.Text
goodInfoRs("addTime") = Now
goodInfoRs.Update
MsgBox "商品信息添加成功!"
Me.txtGoodName.Text = ""
Me.CB_GoodClass.Text = ""
Me.CB_GoodUnit.Text = ""
Me.txtPrice.Text = ""
Me.txtStock.Text = ""
Me.txtIntroduction.Text = ""
Me.txtGoodName.SetFocus
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim goodClassRs As ADODB.Recordset '保存所有商品類別的結(jié)果集
Dim goodUnitNameRs As ADODB.Recordset '保存商品單位的結(jié)果集
Dim sql As String '查詢sql
Call check_condatabase '連接數(shù)據(jù)庫
sql = "select unitName from unitName"
Set goodUnitNameRs = cn.Execute(sql)
While Not goodUnitNameRs.EOF
Me.CB_GoodUnit.AddItem goodUnitNameRs("unitName")
goodUnitNameRs.MoveNext
Wend
sql = "select * from goodClass"
Set goodClassRs = cn.Execute(sql)
While Not goodClassRs.EOF
Me.CB_GoodClass.AddItem (goodClassRs("goodClassId") & "-" & goodClassRs("goodClassName"))
goodClassRs.MoveNext
Wend
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -