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

📄 browsecustomerdialog.frm

📁 VB编写的简单销售管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         Left            =   120
         TabIndex        =   32
         Top             =   2040
         Width           =   360
      End
      Begin VB.Label Label13 
         AutoSize        =   -1  'True
         Caption         =   "单位地址"
         Height          =   195
         Left            =   120
         TabIndex        =   30
         Top             =   1320
         Width           =   720
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         Caption         =   "传真"
         Height          =   195
         Left            =   2400
         TabIndex        =   15
         Top             =   960
         Width           =   360
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         Caption         =   "邮编"
         Height          =   195
         Left            =   120
         TabIndex        =   13
         Top             =   960
         Width           =   360
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "电话"
         Height          =   195
         Left            =   2400
         TabIndex        =   11
         Top             =   600
         Width           =   360
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         Caption         =   "联系人"
         Height          =   195
         Left            =   120
         TabIndex        =   9
         Top             =   600
         Width           =   540
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "编号"
         Height          =   195
         Left            =   2400
         TabIndex        =   7
         Top             =   240
         Width           =   360
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "单位"
         Height          =   195
         Left            =   120
         TabIndex        =   5
         Top             =   240
         Width           =   360
      End
   End
   Begin VB.Frame CustomerFrame 
      Caption         =   "客户编号"
      Height          =   4935
      Left            =   0
      TabIndex        =   2
      Top             =   0
      Width           =   1575
      Begin VB.ListBox List1 
         Height          =   4545
         Left            =   120
         TabIndex        =   3
         Top             =   240
         Width           =   1335
      End
   End
   Begin VB.CommandButton CancelButton 
      Caption         =   "取消"
      Height          =   375
      Left            =   5280
      TabIndex        =   1
      Top             =   4560
      Width           =   975
   End
   Begin VB.CommandButton OKButton 
      Caption         =   "确认"
      Height          =   375
      Left            =   4200
      TabIndex        =   0
      Top             =   4560
      Width           =   975
   End
End
Attribute VB_Name = "BrowseCustomerDialog"
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
    Text13.Enabled = True
    Text14.Enabled = True
    Command1.Enabled = False
    Command2.Enabled = False
End Sub

Private Sub Command2_Click()
    TempStr = "DELETE FROM 客户表 WHERE CustomerID='" & Text2.Text & "'"
    MyDB.Execute TempStr
    MsgBox "成功删除客户 " & Text2.Text & " !"
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text13.Text = ""
    Text14.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 EmployeeID='" & Data1.Recordset("EmployeeID") & "'"
        Data2.Refresh
        Data3.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
        Data3.RecordSource = "select * from 产品表 where ProductID='" & Data1.Recordset("ProductID") & "'"
        Data3.Refresh
    Else
        Text8.Text = ""
        Text9.Text = ""
    End If
End Sub

Private Sub Form_Load()
    Text7.DataField = "OrderID"
    Text8.DataField = "Name"
    Text9.DataField = "Product"
    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("CustomerID")
        MyRecord.MoveNext
    Loop
End Sub

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

Private Sub List1_Click()
    Command1.Enabled = True
    MyRecord.Index = "PrimaryKey"
    MyRecord.Seek "=", List1.Text
    If MyRecord.NoMatch Then
        MsgBox "没有编号为" + List1.Text + "的客户!"
    Else
        Text1.Text = MyRecord.Fields("CompanyTitle")
        Text2.Text = List1.Text
        Text3.Text = MyRecord.Fields("LinkMan")
        Text4.Text = MyRecord.Fields("Phone")
        Text5.Text = MyRecord.Fields("PostCode")
        Text6.Text = MyRecord.Fields("Fax")
        Text13.Text = MyRecord.Fields("Address")
        If Not IsNull(MyRecord.Fields("Memo")) Then
            Text14.Text = MyRecord.Fields("Memo")
        Else
            Text14.Text = ""
        End If
        Data1.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
        Data1.RecordSource = "select * from 订单表 where CustomerID='" & 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 EmployeeID='" & Data1.Recordset("EmployeeID") & "'"
            Data2.Refresh
            Data3.DatabaseName = VB.App.Path + "\MySampleDB.mdb"
            Data3.RecordSource = "select * from 产品表 where ProductID='" & Data1.Recordset("ProductID") & "'"
            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 Text6.Text = "" Then
            MsgBox "请输入 传真 !"
            Exit Sub
        End If
        If Text13.Text = "" Then
            MsgBox "请输入 单位地址 !"
            Exit Sub
        End If
                
        TempStr = "UPDATE 客户表 SET CompanyTitle='" & Text1.Text & "',LinkMan='" & Text3.Text & _
                        "',Phone='" & Text4.Text & "',PostCode='" & Text5.Text & "',Fax='" _
                        & Text6.Text & "',Memo='" & Text14.Text & "',Address='" & Text13.Text & _
                        "' WHERE CustomerID='" & Text2.Text & "'"
        MyDB.Execute TempStr
        MsgBox "成功修改客户" & Text2.Text & "!"
        Text1.Enabled = False
        Text3.Enabled = False
        Text4.Enabled = False
        Text5.Enabled = False
        Text6.Enabled = False
        Text13.Enabled = False
        Text14.Enabled = False
        Command1.Enabled = True
        Command2.Enabled = True
    End If
End Sub

⌨️ 快捷键说明

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