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

📄 frmbooksale.frm

📁 因为不同的排序方法适应不同的应用环境和要求
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmBookSale 
   Caption         =   "图书销售"
   ClientHeight    =   4545
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6030
   LinkTopic       =   "Form1"
   ScaleHeight     =   4545
   ScaleWidth      =   6030
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame3 
      Caption         =   "付款信息"
      Height          =   3135
      Left            =   3600
      TabIndex        =   14
      Top             =   1320
      Width           =   2415
      Begin VB.CommandButton cmdAll 
         Caption         =   "结帐"
         Height          =   495
         Left            =   1320
         TabIndex        =   24
         Top             =   2400
         Width           =   855
      End
      Begin VB.CommandButton cmdOK 
         Caption         =   "计算"
         Height          =   495
         Left            =   240
         TabIndex        =   23
         Top             =   2400
         Width           =   855
      End
      Begin VB.TextBox txtrepay 
         Height          =   270
         Left            =   960
         Locked          =   -1  'True
         TabIndex        =   22
         Top             =   1680
         Width           =   1335
      End
      Begin VB.TextBox txtpay 
         Height          =   270
         Left            =   960
         TabIndex        =   20
         Top             =   1200
         Width           =   1335
      End
      Begin VB.TextBox txtsell 
         Height          =   270
         Left            =   960
         Locked          =   -1  'True
         TabIndex        =   18
         Top             =   720
         Width           =   1335
      End
      Begin VB.TextBox txtnumber 
         Height          =   270
         Left            =   960
         TabIndex        =   16
         Text            =   "1"
         Top             =   360
         Width           =   1335
      End
      Begin VB.Label Label10 
         Caption         =   "应 找 还:"
         Height          =   255
         Left            =   120
         TabIndex        =   21
         Top             =   1680
         Width           =   855
      End
      Begin VB.Label Label9 
         Caption         =   "客户付款:"
         Height          =   255
         Left            =   120
         TabIndex        =   19
         Top             =   1200
         Width           =   855
      End
      Begin VB.Label Label8 
         Caption         =   "应 付 款:"
         Height          =   255
         Left            =   120
         TabIndex        =   17
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label7 
         Caption         =   "书 数 量:"
         Height          =   255
         Left            =   120
         TabIndex        =   15
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "书籍信息"
      Height          =   3135
      Left            =   120
      TabIndex        =   3
      Top             =   1320
      Width           =   3375
      Begin VB.TextBox txtprice 
         Height          =   270
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   13
         Top             =   2040
         Width           =   1455
      End
      Begin VB.TextBox txtdiscount 
         Height          =   270
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   11
         Top             =   1680
         Width           =   1455
      End
      Begin VB.TextBox txtsale 
         Height          =   270
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   9
         Top             =   1320
         Width           =   1455
      End
      Begin VB.TextBox txtbookname 
         Height          =   270
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   7
         Top             =   720
         Width           =   1935
      End
      Begin VB.TextBox txtbookno 
         Height          =   270
         Left            =   840
         Locked          =   -1  'True
         TabIndex        =   5
         Top             =   360
         Width           =   1935
      End
      Begin VB.Label Label6 
         Caption         =   "出售价:"
         Height          =   255
         Left            =   120
         TabIndex        =   12
         Top             =   2040
         Width           =   735
      End
      Begin VB.Label Label5 
         Caption         =   "打  折:"
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   1680
         Width           =   735
      End
      Begin VB.Label Label4 
         Caption         =   "单  价:"
         Height          =   255
         Left            =   120
         TabIndex        =   8
         Top             =   1320
         Width           =   735
      End
      Begin VB.Label Label3 
         Caption         =   "书  名:"
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   720
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "书  号:"
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   360
         Width           =   735
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "请输入书号"
      Height          =   1095
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5775
      Begin VB.TextBox Text1 
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   15
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   615
         Left            =   360
         TabIndex        =   1
         Top             =   240
         Width           =   4095
      End
      Begin VB.Label Label1 
         Caption         =   "按回车"
         BeginProperty Font 
            Name            =   "新宋体"
            Size            =   15
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   4680
         TabIndex        =   2
         Top             =   360
         Width           =   975
      End
   End
End
Attribute VB_Name = "frmBookSale"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
   Dim Money As Double
      
Private Sub cmdAll_Click()
txtrepay.Text = (Val(txtpay.Text) - Money) & "元" '应还金额
     If Val(txtrepay.Text) < 0 Then '如果客户所付钱不够
     MsgBox "客户所付的金额不够!请提醒对方补钱"
      Exit Sub
      End If
      If rs.State <> 0 Then '如果记录集不是关闭
      rs.Close
     End If
     cmdAll.Enabled = False '结帐按钮不可用
      Money = 0
Text1.Text = ""
End Sub

Private Sub cmdOK_Click()
If rs("Quantity").Value < Val(txtnumber.Text) Then   '如果库存数量不够
       MsgBox "rs('BookName').Value & ", " 书的库存数量不够!", vbOKOnly, "警告"
       Exit Sub
End If
       txtsell.Text = Val(txtprice.Text) * Val(txtnumber.Text) & "元"
     Money = Money + Val(txtprice.Text) * Val(txtnumber.Text)
     txtpay.Text = ""
    txtrepay.Text = ""
     cmdOK.Enabled = False '计算按钮不可用
    cmdAll.Enabled = True '结帐按钮可用

con.Execute "update BookRecord set Quantity=Quantity - " & Val(txtnumber.Text) _
  & "  where BookNo='" & txtbookno.Text & "'"
  '在bookSale表中添加记录
'   con.Execute "insert into BookSale (Sn,Account,SaleDate,SumMoney) values('" & "111" & "'," & Date & "," & Text1.Text & "," & Val(txtsale.Text) * Val(txtnumber.Text) & ")"
  '在salesdetail表中添加记录
'  con.Execute "insert into SalesDetail" _
'  & "(Sn,Account,BookNo,BookName,SalePrice,Quantity,Discount)" _
'  & "values('" & "111" & "','" & username & "','" & txtbookno.Text _
'   & "','" & txtbookname.Text & "'," & Val(txtprice.Text) & "," _
'   & Val(txtnumber.Text) & "," & Val(txtdiscount.Text) & ")"
   
'   con.Execute "insert into SalesDetail values('" & strnum & "','" _
'             & username & "','" & txtsale(0).Text & "','" & txtsale(1).Text & "'," & Val(txtsale(4).Text) & "," _
'             & Val(txtsale(5).Text) & "," & Val(txtsale(3).Text) & ")"

End Sub

Private Sub Form_Load()
    Set con = New ADODB.Connection
con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=图书销售系统;"
Set rs = New ADODB.Recordset
        cmdOK.Enabled = False '计算按钮不可用
        cmdAll.Enabled = False '结帐按钮不可用

End Sub


Private Sub Text1_KeyPress(KeyAscii As Integer)
'        If rs.State <> 0 Then   '如果记录集不是关闭
'           rs.Close
'       End If
    If KeyAscii = 13 Then   '如果是按下回车键
Set con = New ADODB.Connection
con.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=图书销售系统;"
Set rs = New ADODB.Recordset
    rs.Open "select BookNo,BookName,SalesPrice,Discount,Quantity,(SalesPrice * Discount*0.1)as price from BookRecord where BookNo='" _
      & Text1.Text & "'", con
     '填充数据到文本框
     If rs.EOF = True Then '如果没有该书
      MsgBox "没有该书!"
      Exit Sub
    End If
   '  填充表字段的值到各文本框
      
      txtbookno.Text = rs("BookNo").Value
      txtbookname.Text = rs("BookName").Value
      txtsale.Text = rs("SalesPrice").Value
       txtdiscount.Text = rs("Discount").Value
       txtprice.Text = rs("price").Value
       cmdOK.Enabled = True '计算按钮可用
       cmdAll.Enabled = False '结帐按钮不可用
      End If
      Exit Sub
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -