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

📄 form2.frm

📁 主要是实现超市管理系统中条形码的串口编程
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   "name"
         Caption         =   "商品名称"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column02 
         DataField       =   "price"
         Caption         =   "价格"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column03 
         DataField       =   "number"
         Caption         =   "数量"
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      SplitCount      =   1
      BeginProperty Split0 
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
         BeginProperty Column02 
         EndProperty
         BeginProperty Column03 
         EndProperty
      EndProperty
   End
   Begin MSCommLib.MSComm MSComm1 
      Left            =   0
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      DTREnable       =   -1  'True
      RThreshold      =   1
      InputMode       =   1
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Sbuf As String
Dim InByte() As Byte

Dim con As New ADODB.Connection

Private Sub Command6_Click() '结帐
   
'---------------------------------------------------------------
' 计算购买物品的总价格
'---------------------------------------------------------------
   Dim i As Single
   Dim s As Single
  
 

      Adodc1.Recordset.MoveFirst
     '   i = Adodc1.Recordset.Fields(2)
     ' s = s + i
       Do While Not Adodc1.Recordset.EOF
       
       i = Adodc1.Recordset.Fields("price")
       s = s + i
       Adodc1.Recordset.MoveNext
        Loop

      Label2.Caption = s
'---------------------------------------------------------------
 '更新库存
'----------------------------------------------------------------

   Dim code1 As String
   Dim intTmp As Integer
   Adodc1.Recordset.MoveFirst
  
   Do While Not Adodc1.Recordset.EOF
   
   code1 = Adodc1.Recordset.Fields("code")
 
    
     Adodc2.RecordSource = "select * from store where 条码 =" & " '" & code1 & " '"
     Adodc2.Refresh
     intTmp = Adodc2.Recordset.RecordCount
     intTmp = Val(Adodc2.Recordset("库存")) - 1
     Adodc2.Recordset("库存") = intTmp
 '    Adodc1.Recordset.Update (3, 库存-1)
     Adodc2.Recordset.Update
     Adodc2.Refresh

     
     Adodc1.Recordset.MoveNext
   
   Loop
    
 End Sub

Private Sub Command7_Click() '找余
    Dim money As Currency
    money = Val(Text2.Text)
    Label6.Caption = money - Label2.Caption
    MsgBox "你共付金额:" & money & "元,找零:" & Label6.Caption & "元!", vbInformation, "找零"
        
    con.BeginTrans
  con.Execute "delete from  cursale"
  con.CommitTrans
  Adodc1.Refresh
    
End Sub


Private Sub Form_Load()
On Error Resume Next

    Adodc2.CommandType = adCmdText
    Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\store.mdb;Persist Security Info=False"
    Adodc2.RecordSource = "select * from store"
    Adodc2.Refresh
    
    Adodc1.CommandType = adCmdText
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\store.mdb;Persist Security Info=False"
    Adodc1.RecordSource = "select * from CurSale"
    Adodc1.Refresh
    
   
    MSComm1.PortOpen = True
    
    If Adodc1.Recordset.EOF = False Then
        Adodc1.Recordset.MoveFirst
        Do While Not Adodc1.Recordset.EOF
            Adodc1.Recordset.Delete
            Adodc1.Recordset.Update
            Adodc1.Refresh
            Adodc1.Recordset.MoveNext
        Loop
    End If
    
    Adodc1.Refresh
  con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\store.mdb;Persist Security Info=False"
  con.Open
End Sub


Private Sub MSComm1_OnComm()

 Dim str As String
Dim i%

Dim txt02 As Integer
Dim txt03 As Integer

Dim txtData As String
Dim txtSum As String

InByte = MSComm1.Input

For i = LBound(InByte) To UBound(InByte)

    Select Case Hex(InByte(i))
        Case Hex(2)
            Sbuf = Sbuf & "("
        Case Hex(3)
            Sbuf = Sbuf & ")"
        Case Hex(6)
        Case Else
            Sbuf = Sbuf & Chr(InByte(i))
    End Select

Next i

i = Len(Sbuf)
If i > 500 Then Sbuf = ""

txt02 = InStr(1, Sbuf, "(")
txt03 = InStr(1, Sbuf, ")")
i = txt03 - txt02
Select Case i
    Case 14
        txtData = Mid(Sbuf, txt02 + 1, 13)
        'txtSum = Mid(Sbuf, txt03 + 1, 2)
        'If SumCmd(txtData) = txtSum Then
            'recTxtX = txtData
            'Sbuf = Right(Sbuf, Len(Sbuf) - txt03)
            Text1.Text = txtData
            
           Adodc2.RecordSource = "select 条码,商品名称,价格 from store where 条码=" & " '" & Text1.Text & " '"
           Adodc2.Refresh

           If Adodc2.Recordset.RecordCount <= 0 Then
                MsgBox "该商品不在库中,请加入数据库!", 16, "提示"
                frmAdd.Show
                frmAdd.Label1.Caption = Text1.Text
                Exit Sub
           End If
           Adodc1.RecordSource = "select * from  CurSale where code ='" & Text1.Text & "'"
           Adodc1.Refresh
           
           Adodc1.Recordset.AddNew
           Adodc1.Recordset("code") = Text1.Text
           Adodc1.Recordset("name") = Adodc2.Recordset.Fields("商品名称")
           Adodc1.Recordset("price") = Adodc2.Recordset.Fields("价格")
           Adodc1.Recordset("number") = 1
           Adodc1.Recordset.Update
            Adodc1.RecordSource = "select * from  CurSale"
            Adodc1.Refresh
            Adodc1.Refresh
            Adodc1.Refresh
            Adodc1.Refresh
            Adodc1.Recordset.MoveLast
            Sbuf = ""
        'End If
    Case Else
End Select
Exit Sub



End Sub


⌨️ 快捷键说明

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