📄 商品销售信息.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmXS
'Download by http://www.codefans.net
BorderStyle = 1 'Fixed Single
Caption = "商品销售"
ClientHeight = 4065
ClientLeft = 45
ClientTop = 330
ClientWidth = 7770
Icon = "商品销售信息.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
Picture = "商品销售信息.frx":0442
ScaleHeight = 4065
ScaleWidth = 7770
Begin VB.CommandButton cmdAdd
Caption = "添加记录(&A)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1846
TabIndex = 15
Top = 3360
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存记录(&S)"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3346
TabIndex = 14
Top = 3360
Width = 1215
End
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "关闭(&E)"
CausesValidation= 0 'False
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4846
TabIndex = 13
Top = 3360
Width = 1215
End
Begin VB.TextBox txtJE
Enabled = 0 'False
Height = 300
Left = 5265
TabIndex = 12
Top = 2400
Width = 1575
End
Begin MSComCtl2.DTPicker DTdate
Height = 300
Left = 1905
TabIndex = 10
Top = 2400
Width = 1455
_ExtentX = 2566
_ExtentY = 529
_Version = 393216
CalendarBackColor= 16761024
CalendarTitleBackColor= 12648447
Format = 28180481
CurrentDate = 38034
End
Begin VB.TextBox txtJG
Height = 300
Left = 5265
TabIndex = 8
Top = 1800
Width = 1575
End
Begin VB.TextBox txtNumber
Height = 300
Left = 1905
TabIndex = 6
Top = 1800
Width = 1455
End
Begin VB.ComboBox cboType
Height = 300
ItemData = "商品销售信息.frx":3541
Left = 5265
List = "商品销售信息.frx":354B
TabIndex = 4
Text = "请选择"
Top = 1200
Width = 1575
End
Begin VB.ComboBox cboName
Height = 300
ItemData = "商品销售信息.frx":355B
Left = 1905
List = "商品销售信息.frx":355D
TabIndex = 1
Text = "请选择"
Top = 1200
Width = 1455
End
Begin VB.Line Line1
BorderColor = &H00800000&
BorderWidth = 2
Index = 1
X1 = 0
X2 = 7800
Y1 = 3000
Y2 = 3000
End
Begin VB.Line Line1
BorderColor = &H00800000&
BorderWidth = 2
Index = 0
X1 = 0
X2 = 7800
Y1 = 840
Y2 = 840
End
Begin VB.Label Label7
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "销售金额:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 180
Left = 4215
TabIndex = 11
Top = 2400
Width = 975
End
Begin VB.Label Label6
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "销售日期:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 180
Left = 705
TabIndex = 9
Top = 2400
Width = 975
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "销售单价:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 180
Left = 4215
TabIndex = 7
Top = 1800
Width = 975
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "销售数量:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 180
Left = 705
TabIndex = 5
Top = 1800
Width = 975
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "销售类型:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 180
Left = 4215
TabIndex = 3
Top = 1200
Width = 975
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "商品名称:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 180
Left = 705
TabIndex = 2
Top = 1200
Width = 975
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "商品销售信息"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 700
Underline = -1 'True
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 360
Left = 2745
TabIndex = 0
Top = 120
Width = 2250
End
End
Attribute VB_Name = "frmXS"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim RS As Recordset
Dim sql As String
Dim RSkc As Recordset
Private Sub KJZT() '设定控件的可用状态
cboName.Enabled = ZJ
cboType.Enabled = ZJ
txtJG.Enabled = ZJ
txtNumber.Enabled = ZJ
DTdate.Enabled = ZJ
' txtJE.Enabled = ZJ
cmdSave.Enabled = ZJ
cmdAdd.Enabled = Not ZJ
cmdExit.Enabled = Not ZJ
End Sub
Private Sub cboName_Validate(Cancel As Boolean)
If cboName.Text = "" Or cboName.Text = "请选择" Then
Cancel = True
MsgBox "请选择商品"
End If
End Sub
Private Sub cboType_Validate(Cancel As Boolean)
If cboType.Text = "" Or cboType.Text = "请选择" Then
Cancel = True
MsgBox "请选择商品销售类型"
End If
End Sub
Private Sub cmdAdd_Click()
ZJ = True
KJZT
cboName.SetFocus
cmdExit.Enabled = True
cboName.Text = "请选择"
cboType.Text = "请选择"
txtJG = ""
txtJE = ""
txtNumber = ""
DTdate.Value = Date
RS.AddNew
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim Icode As String
'当销售发生时更新库存商品的数量
sql = "select * from 库存表 where 商品名称='" & cboName.Text & "'"
Set RSkc = Db.OpenRecordset(sql)
'将销售数量与库存数量进行比较
If RSkc.Fields("库存数量").Value < val(txtNumber.Text) Then
MsgBox "库存数量不足,该商品的库存数量为" & RSkc.Fields("库存数量")
txtNumber.SetFocus
Exit Sub
End If
Icode = RSkc.Fields("商品编号")
RSkc.Edit
RSkc.Fields("库存数量") = RSkc.Fields("库存数量").Value - val(txtNumber.Text)
RSkc.Update
RSkc.Close
'将销售记录写入表“销售单”
RS.Fields("code") = Icode
RS.Fields("count") = val(txtNumber.Text)
RS.Fields("outdate") = DTdate.Value
RS.Fields("price") = val(txtJG.Text)
RS.Fields("type") = cboType.Text
RS.Update
'重新设定控件的可用状态
ZJ = False
KJZT
End Sub
Private Sub Form_Load()
Me.Top = MDIForm1.Top + 1200
Me.Left = MDIForm1.Left + 1800
Set Db = OpenDatabase(App.Path + "\db1.mdb")
Set RS = Db.OpenRecordset("库存表")
Do While Not RS.EOF
cboName.AddItem RS.Fields("商品名称")
RS.MoveNext
Loop
DTdate.Value = Date
ZJ = False
KJZT
Set RS = Db.OpenRecordset("销售单")
End Sub
Private Sub txtJG_Change() '计算销售金额
If txtNumber <> "" And txtJG <> "" Then
txtJE.Text = val(txtNumber) * val(txtJG)
Else
txtJE = ""
End If
End Sub
Private Sub txtJG_Validate(Cancel As Boolean)
If val(txtJG.Text) <= 0 Then
Cancel = True
MsgBox "销售单价必须大于零"
End If
End Sub
Private Sub txtNumber_Change() '计算销售金额
If txtNumber <> "" And txtJG <> "" Then
txtJE.Text = val(txtNumber) * val(txtJG)
Else
txtJE = ""
End If
End Sub
Private Sub txtNumber_Validate(Cancel As Boolean)
If val(txtNumber.Text) <= 0 Then
Cancel = True
MsgBox "销售数量必须大于零"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -