?? frmxiaoshou.frm
字號:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form frmxiaoshou
Caption = "銷售登記"
ClientHeight = 6375
ClientLeft = 60
ClientTop = 450
ClientWidth = 11640
LinkTopic = "Form1"
ScaleHeight = 6375
ScaleWidth = 11640
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Caption = "銷售登記"
Height = 5055
Left = 120
TabIndex = 4
Top = 120
Width = 11415
Begin VB.TextBox TextXS
Height = 270
Index = 1
Left = 1920
TabIndex = 22
Top = 1440
Width = 1575
End
Begin VB.TextBox TextXS
Height = 270
Index = 0
Left = 1920
TabIndex = 12
Top = 360
Width = 1575
End
Begin VB.TextBox TextXS
Height = 270
Index = 2
Left = 1920
TabIndex = 11
ToolTipText = "輸入數據需為數值"
Top = 1800
Width = 1575
End
Begin VB.ComboBox Combo3
Height = 300
ItemData = "frmxiaoshou.frx":0000
Left = 1920
List = "frmxiaoshou.frx":000A
TabIndex = 10
Text = "零售"
Top = 720
Width = 1575
End
Begin VB.ComboBox Combo4
Height = 300
Left = 1920
TabIndex = 9
Text = "Combo4"
Top = 1080
Width = 2775
End
Begin VB.TextBox TextXS
Enabled = 0 'False
Height = 270
Index = 3
Left = 1920
TabIndex = 8
Top = 2520
Width = 1575
End
Begin VB.ComboBox Combo5
Height = 300
ItemData = "frmxiaoshou.frx":001A
Left = 1920
List = "frmxiaoshou.frx":002A
TabIndex = 7
Text = "現金"
Top = 2160
Width = 1575
End
Begin VB.TextBox TextXS
Height = 1575
Index = 4
Left = 1920
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 5
Top = 3240
Width = 6375
End
Begin MSComCtl2.DTPicker DTPickersale
Height = 255
Left = 1920
TabIndex = 6
Top = 2880
Width = 2175
_ExtentX = 3836
_ExtentY = 450
_Version = 393216
Format = 184942593
CurrentDate = 38518
End
Begin VB.Label Label
Caption = "銷售編號:"
Height = 255
Index = 0
Left = 720
TabIndex = 21
Top = 360
Width = 1335
End
Begin VB.Label Label
Caption = "銷售方式:"
Height = 255
Index = 1
Left = 720
TabIndex = 20
Top = 720
Width = 1335
End
Begin VB.Label Label
Caption = "商品名稱:"
Height = 255
Index = 3
Left = 720
TabIndex = 19
Top = 1080
Width = 1335
End
Begin VB.Label Label
Caption = "售價:"
Height = 255
Index = 4
Left = 720
TabIndex = 18
Top = 1440
Width = 1335
End
Begin VB.Label Label
Caption = "數量:"
Height = 255
Index = 5
Left = 720
TabIndex = 17
Top = 1800
Width = 1335
End
Begin VB.Label Label
Caption = "結賬方式:"
Height = 255
Index = 6
Left = 720
TabIndex = 16
Top = 2160
Width = 1335
End
Begin VB.Label Label
Caption = "數額:"
Height = 255
Index = 7
Left = 720
TabIndex = 15
Top = 2520
Width = 1335
End
Begin VB.Label Label
Caption = "日期:"
Height = 255
Index = 10
Left = 720
TabIndex = 14
Top = 2880
Width = 1335
End
Begin VB.Label Label
Caption = "備注:"
Height = 255
Index = 11
Left = 720
TabIndex = 13
Top = 3240
Width = 1335
End
End
Begin VB.Frame Frame8
Caption = "操作"
Height = 975
Left = 120
TabIndex = 0
Top = 5280
Width = 11415
Begin VB.CommandButton Command6
Caption = "保存"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 1200
TabIndex = 3
Top = 240
Width = 2535
End
Begin VB.CommandButton Command7
Caption = "取消"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 7680
TabIndex = 2
Top = 240
Width = 2535
End
Begin VB.CommandButton cmdChange
Caption = "修改與刪除"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 4680
TabIndex = 1
Top = 240
Width = 2295
End
End
End
Attribute VB_Name = "frmxiaoshou"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub cmdChange_Click()
frmCHSale.Show
End Sub
Private Sub Combo4_Change()
Dim saleway As String
Dim spname As String
saleway = Trim(Combo3.Text)
spname = Trim(Combo4.Text)
TextXS(1).Text = spjg(saleway, spname)
End Sub
Private Sub Command6_Click()
Dim i As Integer
For i = 0 To 3
If TextXS(i).Text = "" Then
MsgBox "數據輸入不完整,請確認數據輸入完整", vbExclamation, "系統提示"
Exit Sub
End If
Next
Dim strSqlId As String
Dim rssqlid As ADODB.Recordset
strSqlId = "select 銷售編號 from 銷售表 where 銷售編號= '" & Trim(TextXS(0).Text) & "'"
Set rssqlid = ExeSQL(strSqlId)
If Not rssqlid.EOF Then
MsgBox "此編號已經使用,請更換編號", vbExclamation + vbOKOnly, "系統提示"
Exit Sub
End If
Dim enough As Integer
enough = isEnough(Trim(Combo4.Text))
If enough = 0 Then '判斷庫存是否足夠
MsgBox "該商品庫存數量已經不夠,請增加該商品數量", vbExclamation, "系統提示"
Call Cleartxt
Exit Sub
End If
Dim sqlsale As String
sqlsale = "insert into 銷售表(銷售編號,銷售方式,商品編號,售價,數量,結賬方式,數額,日期,備注) "
sqlsale = sqlsale & "values('" & Trim(TextXS(0).Text) & "','" & Combo3.Text & "','" & spid(Combo4.Text) & "'," & Val(TextXS(1).Text) & "," & Val(TextXS(2).Text) & ",'" & Combo5.Text & "'," & Val(TextXS(3).Text) & ",'" & DTPickersale.Value & "','" & TextXS(4).Text & "')"
ExeSQL (sqlsale)
Call subtractKC
MsgBox "銷售記錄登記成功", vbInformation, "系統提示"
Call Cleartxt
Exit Sub
End Sub
Private Sub Cleartxt()
Dim i As Integer
For i = 1 To 4
TextXS(i).Text = ""
Next
End Sub
Public Sub subtractKC() '銷售后,減少庫存商品數量
Dim rskc As ADODB.Recordset
Dim sqlkc As String
sqlkc = "select 數量 from 庫存表 where 商品名稱='" & Trim(Combo4.Text) & "'"
Set rskc = ExeSQL(sqlkc)
rskc.Fields("數量") = Val(rskc.Fields("數量")) - Val(TextXS(2).Text)
rskc.Update
rskc.Close
Set rskc = Nothing
End Sub
Public Function isEnough(ByVal spname As String) As Integer '判斷庫存中商品數量是否足夠的函數
Dim rskc As ADODB.Recordset
Dim sqlkc As String
sqlkc = "select 數量 from 庫存表 where 商品名稱='" & spname & "'"
Set rskc = ExeSQL(sqlkc)
If Val(rskc.Fields("數量")) > 0 Then '當小于等于零時,返回0,庫存不足
If Val(rskc.Fields("數量")) >= Val(TextXS(2).Text) Then
isEnough = 1
Else
isEnough = 0
End If
Else
isEnough = 0
End If
rskc.Close
Set rskc = Nothing
End Function
Private Sub Form_Load()
Call spjg(Trim(Combo3.Text), Trim(Combo4.Text))
Call loadSP(Me.Combo4)
Me.DTPickersale.Value = Now()
End Sub
Private Sub loadSP(combo As ComboBox) '加載商品名稱的過程
On Error GoTo ErrorHandler
Dim rssp As ADODB.Recordset
Dim sqlsp As String
sqlsp = "select 商品名稱 from 商品表"
Set rssp = ExeSQL(sqlsp)
combo.Clear
Do While Not rssp.EOF
combo.AddItem (rssp.Fields(0))
rssp.MoveNext
Loop
combo.ListIndex = 0
rssp.Close
Set rssp = Nothing
Exit Sub
ErrorHandler:
MsgBox "錯誤號:" & Err.Number & vbCrLf & "錯誤內容:系統基本信息設置不完整,請添加商品名稱", vbExclamation + vbOKOnly, "其他錯誤!"
End Sub
Private Sub TextXS_Change(Index As Integer)
If Combo5.Text = "現金" Then
TextXS(3).Text = Val(TextXS(1).Text) * Val(TextXS(2).Text)
Else
TextXS(3).Text = Val(TextXS(2).Text)
End If
End Sub
Public Function spjg(ByVal saleway As String, ByVal spname As String) As Integer '返回商品價格
Dim sqlspjg As String
Dim rsspjg As ADODB.Recordset
If saleway = "零售" Then
sqlspjg = "select 零售價 from 商品表 where 商品名稱='" & spname & "'"
Else
sqlspjg = "select 批發價 from 商品表 where 商品名稱='" & spname & "'"
End If
Set rsspjg = ExeSQL(sqlspjg)
spjg = rsspjg.Fields(0)
rsspjg.Close
Set rsspjg = Nothing
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -