⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmxiaoshou.frm

📁 商品进销存软件
💻 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 + -