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

📄 browseproductdialog.frm

📁 VB编写的简单销售管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "单价"
         Height          =   195
         Left            =   2400
         TabIndex        =   28
         Top             =   960
         Width           =   360
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "库存量"
         Height          =   195
         Left            =   240
         TabIndex        =   26
         Top             =   960
         Width           =   540
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "产品类别"
         Height          =   195
         Left            =   2160
         TabIndex        =   24
         Top             =   600
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "产品说明"
         Height          =   195
         Left            =   120
         TabIndex        =   22
         Top             =   600
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "产品编号"
         Height          =   195
         Left            =   2160
         TabIndex        =   20
         Top             =   240
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "产品名称"
         Height          =   195
         Left            =   120
         TabIndex        =   18
         Top             =   240
         Width           =   720
      End
   End
   Begin VB.Frame ProductFrame 
      Caption         =   "产品编号"
      Height          =   3615
      Left            =   0
      TabIndex        =   2
      Top             =   0
      Width           =   1455
      Begin VB.ListBox List1 
         Height          =   3180
         Left            =   120
         TabIndex        =   3
         Top             =   240
         Width           =   1215
      End
   End
   Begin VB.CommandButton CancelButton 
      Caption         =   "取消"
      Height          =   375
      Left            =   5160
      TabIndex        =   1
      Top             =   3240
      Width           =   975
   End
   Begin VB.CommandButton OKButton 
      Caption         =   "确定"
      Height          =   375
      Left            =   4080
      TabIndex        =   0
      Top             =   3240
      Width           =   975
   End
End
Attribute VB_Name = "BrowseProductDialog"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim MyDB As Database
Dim MyRecord As Recordset
Dim TempStr As String

Private Sub CancelButton_Click()
    Unload Me
End Sub

Private Sub Command1_Click()
    If frmLogin.IsAdmin = False Then
        MsgBox "一般用户不具备修改权限!"
        Exit Sub
    End If
    If List1.SelCount = 0 Then
        MsgBox "请选定一种产品 !"
        Exit Sub
    End If
    Text1.Enabled = True
    Text3.Enabled = True
    Text4.Enabled = True
    Text5.Enabled = True
    Text6.Enabled = True
    Command1.Enabled = False
    Command2.Enabled = False
End Sub

Private Sub Command2_Click()
    TempStr = "DELETE FROM 产品表 WHERE ProductID='" & Text2.Text & "'"
    MyDB.Execute TempStr
    MsgBox "成功删除产品 " & Text2.Text & " !"
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    List1.RemoveItem List1.ListIndex
    Command2.Enabled = False
End Sub

Private Sub Data1_Reposition()
    If Not (Data1.Recordset.EOF And Data1.Recordset.BOF) Then
        Data2.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
        Data2.RecordSource = "select * from 客户表 where CustomerID='" & Data1.Recordset("CustomerID") & "'"
        Data2.Refresh
        Data3.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
            Data3.RecordSource = "select * from 雇员表 where EmployeeID='" & Data1.Recordset("EmployeeID") & "'"
        Data3.Refresh
    Else
        Text8.Text = ""
        Text9.Text = ""
    End If
End Sub

Private Sub Form_Load()
    Text7.DataField = "OrderID"
    Text8.DataField = "CompanyTitle"
    Text9.DataField = "Name"
    Text10.DataField = "OrderDate"
    Text11.DataField = "OrderAmount"
    Text12.DataField = "DeliveryDate"
    Set MyDB = OpenDatabase(VB.App.Path + "\MySampleDB.mdb", False, False)
    Set MyRecord = MyDB.OpenRecordset("产品表")
    MyRecord.Index = "PrimaryKey"
    Do While Not MyRecord.EOF
        List1.AddItem MyRecord.Fields("ProductID")
        MyRecord.MoveNext
    Loop
End Sub

Private Sub Form_Unload(Cancel As Integer)
    MyRecord.Close
    MyDB.Close
End Sub

Private Sub List1_Click()
    MyRecord.Index = "PrimaryKey"
    MyRecord.Seek "=", List1.Text
    If MyRecord.NoMatch Then
        MsgBox "没有编号为" + List1.Text + "的产品!"
    Else
        Text1.Text = MyRecord.Fields("Product")
        Text2.Text = List1.Text
        Text3.Text = MyRecord.Fields("Statement")
        Text4.Text = MyRecord.Fields("Category")
        Text5.Text = MyRecord.Fields("Quantity")
        Text6.Text = MyRecord.Fields("PerPrice")
        Data1.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
        Data1.RecordSource = "select * from 订单表 where ProductID='" & List1.Text & "'"
        Data1.Refresh
        If Not (Data1.Recordset.EOF And Data1.Recordset.BOF) Then
            Command2.Enabled = False
            Data2.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
            Data2.RecordSource = "select * from 客户表 where CustomerID='" & Data1.Recordset("CustomerID") & "'"
            Data2.Refresh
            Data3.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
            Data3.RecordSource = "select * from 雇员表 where EmployeeID='" & Data1.Recordset("EmployeeID") & "'"
            Data3.Refresh
        Else
            If frmLogin.IsAdmin = True Then Command2.Enabled = True
            Text8.Text = ""
            Text9.Text = ""
        End If
    End If
End Sub

Private Sub OKButton_Click()
    If Command1.Enabled = True Then
        Unload Me
    Else
        If Text1.Text = "" Then
            MsgBox "请输入 产品名称 !"
            Exit Sub
        End If
        If Text3.Text = "" Then
            MsgBox "请输入 产品说明 !"
            Exit Sub
        End If
        If Text4.Text = "" Then
            MsgBox "请输入 产品类别 !"
            Exit Sub
        End If
        If Text5.Text = "" Then
            MsgBox "请输入 库存量 !"
            Exit Sub
        End If
        If Not IsNumeric(Text5.Text) Then
            MsgBox "库存量 请输入 数字 !"
            Exit Sub
        End If
        If Text6.Text = "" Then
            MsgBox "请输入 单价 !"
            Exit Sub
        End If
        If Not IsNumeric(Text6.Text) Then
            MsgBox "单价 请输入 数字 !"
            Exit Sub
        End If
                
        TempStr = "UPDATE 产品表 SET Product='" & Text1.Text & "',Statement='" & Text3.Text & _
                        "',Category='" & Text4.Text & "',Quantity=" & Val(Text5.Text) & ",PerPrice=" _
                        & Val(Text6.Text) & " WHERE ProductID='" & Text2.Text & "'"
        MyDB.Execute TempStr
        MsgBox "成功修改客户" & Text2.Text & "!"
        Text1.Enabled = False
        Text3.Enabled = False
        Text4.Enabled = False
        Text5.Enabled = False
        Text6.Enabled = False
        Command1.Enabled = True
        Command2.Enabled = True
    End If
End Sub

⌨️ 快捷键说明

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