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

📄 products.frm

📁 一套收银系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      IconSize        =   2
      SHOWF           =   -1  'True
      BSTYLE          =   0
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Search :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000D&
      Height          =   195
      Index           =   2
      Left            =   4470
      TabIndex        =   16
      Top             =   3960
      Width           =   615
   End
   Begin VB.Label lblcount 
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   225
      Left            =   11610
      TabIndex        =   14
      Top             =   3990
      Width           =   1815
   End
   Begin VB.Shape Shape3 
      BorderColor     =   &H80000009&
      FillColor       =   &H00FFFFFF&
      Height          =   15
      Index           =   0
      Left            =   2760
      Top             =   540
      Width           =   6030
   End
   Begin VB.Shape Shape2 
      BorderWidth     =   2
      Height          =   15
      Index           =   0
      Left            =   2760
      Top             =   540
      Width           =   6030
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Quantity  :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   195
      Index           =   6
      Left            =   120
      TabIndex        =   9
      Top             =   2100
      Width           =   780
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Unit Price  :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   195
      Index           =   7
      Left            =   120
      TabIndex        =   8
      Top             =   2460
      Width           =   825
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Selling Price  :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   195
      Index           =   8
      Left            =   120
      TabIndex        =   7
      Top             =   2820
      Width           =   990
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Reorder Point  :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   195
      Index           =   9
      Left            =   120
      TabIndex        =   6
      Top             =   3180
      Width           =   1140
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Product ID  :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   195
      Index           =   0
      Left            =   120
      TabIndex        =   5
      Top             =   1020
      Width           =   915
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Description  :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   195
      Index           =   1
      Left            =   120
      TabIndex        =   4
      Top             =   1740
      Width           =   945
   End
   Begin VB.Label lblLabels 
      AutoSize        =   -1  'True
      BackStyle       =   0  'Transparent
      Caption         =   "Category Type :"
      BeginProperty Font 
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00800000&
      Height          =   195
      Index           =   2
      Left            =   120
      TabIndex        =   3
      Top             =   1380
      Width           =   1185
   End
End
Attribute VB_Name = "Products"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim autoProd As New ADODB.Recordset
Dim Prod As New ADODB.Recordset
Dim ls As ListItem
Private Sub btnAdd_Click()
Call autoProdId
Call unlocking
Call clearing
btnSave.Enabled = True
btnCancel.Enabled = True
btnAdd.Enabled = False
End Sub
Private Sub btnCancel_Click()
btnAdd.Enabled = True
btnSave.Enabled = False
btnDelete.Enabled = False
btnEdit.Enabled = False
btnEdit.Caption = "&Edit"
Call Cleartext(txtProduct, 7)
End Sub
Private Sub btnDelete_Click()
Dim rsDelete As New ADODB.Recordset
If rsDelete.State = 1 Then Set rsDelete = Nothing

rsDelete.Open "SELECT * from [Product] where [Product Id]='" & txtProduct(0).Text & "'", con, adOpenDynamic, adLockPessimistic

    With rsDelete
    
        If Not .EOF Then
        
            ans = MsgBox("Are you sure do you want delete this one record?", vbCritical + vbYesNo, "Delete?")
            
                If ans = vbYes Then
                
                    .Delete
                    .Requery
                    .Close
                    Call txtSearch_Change
                    btnAdd.Enabled = True
                    btnEdit.Enabled = False
                    btnDelete.Enabled = False
                    Call clearing
                    
                End If
        
        Else
            MsgBox "This Record is already Deleted!", vbExclamation + vbOKOnly
                    Call clearing
        End If
    
    End With

End Sub
Private Sub btnEdit_Click()
If btnEdit.Caption = "&Edit" Then
   btnEdit.Caption = "&Update"
   btnCancel.Enabled = True
   Call unlocking
   btnAdd.Enabled = False
   btnSave.Enabled = False
   btnDelete.Enabled = False
Else: btnEdit.Caption = "&Update"
btnEdit.Caption = "&Edit"

Dim rsProd As New ADODB.Recordset

If rsProd.State = 1 Then Set rsProd = Nothing

rsProd.Open "SELECT * from [Product] where [Product ID] ='" & txtProduct(0).Text & "'", con, adOpenDynamic, adLockPessimistic
   
   With rsProd
       
     If Not TxtBoxIsEmpty(txtProduct, 7) Then
        
        con.BeginTrans
     
        For i = 0 To 6
            
            .Fields(i) = txtProduct(i).Text
            
        Next i
        
        .Update
        .Requery
        
        con.CommitTrans
        
        .Close
        Call txtSearch_Change
        btnEdit.Enabled = False
        btnAdd.Enabled = True
      Else
            MsgBox "Please Complete Data!", vbExclamation + vbOKCancel
      
      End If
     
   End With
   
Set rsProd = Nothing

End If
End Sub

Private Sub btnSave_Click()
Dim rsProd As New ADODB.Recordset

If rsProd.State = 1 Then Set rsProd = Nothing

rsProd.Open "SELECT * from [Product] where [Product ID] ='" & txtProduct(0).Text & "'", con, adOpenDynamic, adLockPessimistic
   
   With rsProd
       
     If .EOF Then
   
        con.BeginTrans
        .AddNew
        For i = 0 To 6
            
            .Fields(i) = txtProduct(i).Text
            
        Next i
        .Update
        .Requery
        con.CommitTrans
        .Close
        Call txtSearch_Change
        Call clearing
        Call locking
        btnAdd.Enabled = True
        btnSave.Enabled = False
      Else
      
            MsgBox "Duplicate Found Can't Save", vbInformation + vbOKOnly
        
      End If
   
   End With
   
Set rsProd = Nothing
End Sub
Private Sub Form_Load()

If Prod.State = 1 Then Set Prod = Nothing

    Prod.Open "SELECT * from Product", con, adOpenDynamic, adLockPessimistic
                     dpProd
                            
Me.Width = 13905
Me.Height = 4800
Me.Top = 0
End Sub
Function autoProdId()

Randomize
txtProduct(0).Text = Round(Rnd() * 999999) & txtProduct(0).Text + Chr(Round(Rnd() * 25) + 65)

End Function
Function locking()
For i = 0 To 6
    txtProduct(i).locked = True
Next i
End Function
Function unlocking()
For i = 0 To 6
    txtProduct(i).locked = False
Next i
End Function
Function clearing()
For i = 1 To 6
    txtProduct(i).Text = ""
    Next i
End Function
Private Sub btnsearch_Click()
CategoryList.Show
End Sub

Private Sub lv1_DblClick()
btnEdit.Enabled = True
btnDelete.Enabled = True
btnCancel.Enabled = True
btnSave.Enabled = False
txtProduct(0).Text = lv1.SelectedItem.Text
txtProduct(1).Text = lv1.SelectedItem.SubItems(1)
txtProduct(2).Text = lv1.SelectedItem.SubItems(2)
txtProduct(3).Text = lv1.SelectedItem.SubItems(3)
txtProduct(4).Text = lv1.SelectedItem.SubItems(4)
txtProduct(5).Text = lv1.SelectedItem.SubItems(5)
txtProduct(6).Text = lv1.SelectedItem.SubItems(6)
End Sub
Private Sub txtProduct_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then

    If Index = 1 Then
        txtProduct(1).Text = UCase(txtProduct(1).Text)
        txtProduct(3).SetFocus
    End If
    
    If Index = 3 Then
        SendKeys "{Home}+{End}"
        txtProduct(4).SetFocus
    End If
        
    If Index = 4 Then
        txtProduct(4).Text = CStr(Format(txtProduct(4).Text, "####.#0"))
        SendKeys "{Home}+{End}"
        txtProduct(5).SetFocus
    End If
    
    If Index = 5 Then
        txtProduct(5).Text = CStr(Format(txtProduct(5).Text, "####.#0"))
        SendKeys "{Home}+{End}"
        txtProduct(6).SetFocus
    End If
    
    If Index = 6 Then
       If Not btnSave.Enabled = False Then
       End If
    End If


    
End If
End Sub
Private Sub txtProduct_KeyPress(Index As Integer, KeyAscii As Integer)

If Index = 3 Or Index = 4 Or Index = 5 Or Index = 6 Then

    Select Case KeyAscii
    
        Case Asc(0) To Asc(9)
        Case Str("8")
        
    Case Else
            KeyAscii = 0
    End Select

End If
End Sub
Function dpProd()
Do While Not Prod.EOF

    Set ls = lv1.ListItems.Add(, , Prod.Fields(0))
        
        ls.SubItems(1) = Prod.Fields(1)
        ls.SubItems(2) = Prod.Fields(2)
        ls.SubItems(3) = Prod.Fields(3)
        ls.SubItems(4) = Prod.Fields(4)
        ls.SubItems(5) = Prod.Fields(5)
        ls.SubItems(6) = Prod.Fields(6)
        Prod.MoveNext
    

Loop

    lblcount.Caption = Str(Prod.RecordCount) + " record(s) found"
Set Prod = Nothing
End Function
Private Sub txtSearch_Change()

If Prod.State = 1 Then Set Prod = Nothing

calther = "SELECT * from [Product] where [Description] like '%" & Trim(txtSearch) & "%'"

            Prod.Open calther, con, adOpenKeyset, adLockOptimistic
                
                
                   lv1.ListItems.Clear

                        dpProd
End Sub

⌨️ 快捷键说明

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