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

📄 frmcustman.frm

📁 酒店管理系统 基于VB和SQL的一个很好的程序 可以实现酒店的日常管理工作
💻 FRM
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form FrmCustMan 
   Caption         =   "编辑客户信息"
   ClientHeight    =   6225
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10140
   Icon            =   "FrmCustMan.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   6225
   ScaleWidth      =   10140
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton Cmd_Close 
      Caption         =   "关 闭"
      Height          =   495
      Left            =   7223
      MouseIcon       =   "FrmCustMan.frx":0CCA
      MousePointer    =   99  'Custom
      TabIndex        =   11
      Top             =   5520
      Width           =   1215
   End
   Begin VB.CommandButton Cmd_Del 
      Caption         =   "删 除"
      Height          =   495
      Left            =   5383
      MouseIcon       =   "FrmCustMan.frx":0FD4
      MousePointer    =   99  'Custom
      TabIndex        =   10
      Top             =   5520
      Width           =   1215
   End
   Begin VB.CommandButton Cmd_Modi 
      Caption         =   "修 改"
      Height          =   495
      Left            =   3543
      MouseIcon       =   "FrmCustMan.frx":12DE
      MousePointer    =   99  'Custom
      TabIndex        =   9
      Top             =   5520
      Width           =   1215
   End
   Begin VB.CommandButton Cmd_Add 
      Caption         =   "添 加"
      Height          =   495
      Left            =   1703
      MouseIcon       =   "FrmCustMan.frx":15E8
      MousePointer    =   99  'Custom
      TabIndex        =   8
      Top             =   5520
      Width           =   1215
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   330
      Left            =   4920
      Top             =   960
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   582
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   8
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSDataGridLib.DataGrid DataGrid1 
      Height          =   4215
      Left            =   120
      TabIndex        =   7
      Top             =   1080
      Width           =   9855
      _ExtentX        =   17383
      _ExtentY        =   7435
      _Version        =   393216
      AllowUpdate     =   0   'False
      HeadLines       =   1
      RowHeight       =   15
      BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ColumnCount     =   2
      BeginProperty Column00 
         DataField       =   ""
         Caption         =   ""
         BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
            Type            =   0
            Format          =   ""
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   2052
            SubFormatType   =   0
         EndProperty
      EndProperty
      BeginProperty Column01 
         DataField       =   ""
         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 
         MarqueeStyle    =   3
         BeginProperty Column00 
         EndProperty
         BeginProperty Column01 
         EndProperty
      EndProperty
   End
   Begin VB.Frame Frame1 
      Height          =   855
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   9855
      Begin VB.CommandButton Cmd_Search 
         Caption         =   "查询"
         Height          =   255
         Left            =   9120
         TabIndex        =   6
         Top             =   323
         Width           =   615
      End
      Begin VB.TextBox txtSearch 
         Height          =   270
         Left            =   6120
         TabIndex        =   5
         Top             =   315
         Width           =   2895
      End
      Begin VB.ComboBox ComboSearch 
         Height          =   300
         ItemData        =   "FrmCustMan.frx":18F2
         Left            =   4560
         List            =   "FrmCustMan.frx":1905
         Style           =   2  'Dropdown List
         TabIndex        =   4
         Top             =   300
         Width           =   1335
      End
      Begin VB.ComboBox ComboType 
         Height          =   300
         ItemData        =   "FrmCustMan.frx":1947
         Left            =   1320
         List            =   "FrmCustMan.frx":1949
         Style           =   2  'Dropdown List
         TabIndex        =   2
         Top             =   300
         Width           =   1335
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         Caption         =   "查询条件"
         Height          =   180
         Left            =   3480
         TabIndex        =   3
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "客户类别"
         Height          =   180
         Left            =   240
         TabIndex        =   1
         Top             =   360
         Width           =   720
      End
   End
End
Attribute VB_Name = "FrmCustMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim OriType As String

Private Sub Loadtype()
  Dim i As Integer
  i = 0
  '读取客户类别到数组Arr_CustType()中
  MyCust.Loadtype
  ComboType.Clear
  '依次把数组Arr_CustType()中的数据添加到ComboType组合框中
  i = 0
  Do While Arr_CustType(i) <> ""
    ComboType.AddItem Arr_CustType(i)
    i = i + 1
  Loop
  '设置ComboType的显示值,
  If OriType = "" Then
    '如果没有原值,则显示第1条记录值
    If ComboType.ListCount > 0 Then
      ComboType.ListIndex = 0
    End If
  Else
    '将显示值恢复为原有数据
    If InCombo(OriType, ComboType) = True Then
      ComboType.Text = OriType
    Else
      If ComboType.ListCount > 0 Then
        ComboType.ListIndex = 0
      End If
    End If
  End If
End Sub

Private Sub Refresh_Customer()
  Dim TmpSource As String '保存SQL语句的变量
  
  '设置查询语句,WHERE CustType='" + Trim(ComboType.Text) + "'"
  '表示根据当前选择的客户类别选择客户记录
  TmpSource = "SELECT Idtype As 证件类型, CustId As 证件编号, CustName As 客户姓名," _
      + " OrgName As 客户单位, Sex As 性别, CustFrom As 国籍户籍, CustLevel As 客户等级," _
      + " Job As 职务, Office As 单位电话, Mobile As 移动电话, Home As 家庭电话, " _
      + " Address As 家庭住址, Postcode As 邮政编码 FROM Customer" _
      + " WHERE CustType='" + Trim(ComboType.Text) + "'"
  'ComboSearch组合框中定义了查询的条件,ComboSearch.ListIndex=0时显示指定客户类别下所有记录
  'ComboSearch.ListIndex>0时,需要指定查询条件
  Select Case ComboSearch.ListIndex
    Case 1 '按单位查询
      TmpSource = TmpSource + " And OrgName LIKE '%" + Trim(txtSearch) + "%'"
    Case 2 '按姓名查询
      TmpSource = TmpSource + " And CustName LIKE '%" + Trim(txtSearch) + "%'"
    Case 3 '按地址查询
      TmpSource = TmpSource + " And Address LIKE '%" + Trim(txtSearch) + "%'"
    Case 4 '按电话查询
      TmpSource = TmpSource + " And (Office LIKE '%" + Trim(txtSearch) + "%' OR" _
                + " Mobile LIKE '%" + Trim(txtSearch) + "%' OR Home LIKE '%" _
                + Trim(txtSearch) + "%')"
  End Select
  
  '设置ADO控件的数据源
  Adodc1.ConnectionString = Conn
  Adodc1.RecordSource = TmpSource
  Adodc1.Refresh
  Set DataGrid1.DataSource = Adodc1
  DataGrid1.Columns(0).Width = 1000  '证件类型
  DataGrid1.Columns(1).Width = 1000
  DataGrid1.Columns(2).Width = 1000  '客户姓名
  DataGrid1.Columns(3).Width = 1000
  DataGrid1.Columns(4).Width = 600  '性别
  DataGrid1.Columns(5).Width = 1300  '国籍户籍
  DataGrid1.Columns(6).Width = 1000  '客户等
  DataGrid1.Columns(7).Width = 1000  '职务
  DataGrid1.Columns(8).Width = 1000  '单位电话
  DataGrid1.Columns(9).Width = 1000  '移动电话
  DataGrid1.Columns(10).Width = 1000  '家庭电话
End Sub

Private Sub Cmd_Add_Click()
  '保存原客户类别
  OriType = ComboType.Text
  '对FrmCustEdit窗体对象进行初始化
  With FrmCustEdit
  .Option1.Value = True
  .ComboIdtype.ListIndex = 0
  .ComboLevel.ListIndex = 0
  .Modify = False
  .Show 1
  End With
  '因为删除客户可能导致客户类别变化,需要重新装入客户类别
  Loadtype
  '刷新显示
  Refresh_Customer
End Sub

Private Sub Cmd_Close_Click()
  Unload Me
End Sub

Private Sub Cmd_Del_Click()
  '判断是否选择了要删除的记录
  If Adodc1.Recordset.EOF = True Then
    MsgBox "请选择要删除的记录"
    Exit Sub
  End If
  '保存原客户类别
  OriType = ComboType.Text
  '要求用户确认删除
  If MsgBox("是否删除当前记录", vbYesNo, "请确认") = vbYes Then
    MyCust.Delete (Adodc1.Recordset.Fields(1))
    Refresh_Customer
  End If
  '因为删除客户可能导致客户类别变化,需要重新装入客户类别
  Loadtype
End Sub

Private Sub Cmd_Modi_Click()
  '判断是否选择了要修改的记录
  If Adodc1.Recordset.EOF = True Then
    MsgBox "请选择要修改的记录"
    Exit Sub
  End If
  '保存原客户类别
  OriType = ComboType.Text
  '对FrmCustEdit窗体对象进行初始化
  With FrmCustEdit
  .ComboCustType.Text = ComboType.Text  '客户类别
  .txtOrgName = Trim(Adodc1.Recordset.Fields(3))  '客户单位
  .txtName = Trim(Adodc1.Recordset.Fields(2)) '姓名
  If Trim(Adodc1.Recordset.Fields(4)) = "男" Then '性别
    .Option1.Value = True
  Else
    .Option2.Value = True
  End If
  If Trim(Adodc1.Recordset.Fields(5)) <> "" Then
    .txtFrom = Trim(Adodc1.Recordset.Fields(5)) '国籍户籍
  End If
  '客户等级
  If InCombo(Trim(Adodc1.Recordset.Fields(6)), .ComboLevel) = True Then
    .ComboLevel = Trim(Adodc1.Recordset.Fields(6))
  End If
  '证件类型
  If InCombo(Trim(Adodc1.Recordset.Fields(0)), .ComboIdtype) = True Then
    .ComboIdtype = Trim(Adodc1.Recordset.Fields(0))
  End If
  '证件编号
  .OriCustId = Trim(Adodc1.Recordset.Fields(1))
  .txtCustId = Trim(Adodc1.Recordset.Fields(1))
  '邮政编码
  If Trim(Adodc1.Recordset.Fields(12)) <> "" Then
    .txtPostcode = Trim(Adodc1.Recordset.Fields(12))
  End If
  '通信地址
  If Trim(Adodc1.Recordset.Fields(11)) <> "" Then
    .txtAddr = Trim(Adodc1.Recordset.Fields(11))
  End If
  '单位电话
  If Trim(Adodc1.Recordset.Fields(8)) <> "" Then
    .txtOffice = Trim(Adodc1.Recordset.Fields(8))
  End If
  '移动电话
  If Trim(Adodc1.Recordset.Fields(9)) <> "" Then
    .txtMobile = Trim(Adodc1.Recordset.Fields(9))
  End If
  '家庭电话
  If Trim(Adodc1.Recordset.Fields(10)) <> "" Then
    .txtHome = Trim(Adodc1.Recordset.Fields(10))
  End If
  '职务
  If Trim(Adodc1.Recordset.Fields(7)) <> "" Then
    .txtJob = Trim(Adodc1.Recordset.Fields(7))
  End If
  '设置修改状态
  .Modify = True
  .Show 1
  End With
  '因为删除客户可能导致客户类别变化,需要重新装入客户类别
  Loadtype
  '刷新显示
  Refresh_Customer
End Sub

Private Sub Cmd_Search_Click()
  Refresh_Customer
End Sub

Private Sub ComboSearch_Click()
  If ComboSearch.ListIndex = 0 Then
    '选择显示全部内容时,将查询文本框和按钮隐藏
    txtSearch = ""
    txtSearch.Visible = False
    Cmd_Search.Visible = False
  Else
    '选择显示指定查询结果时,将查询文本框和按钮设置为可见
    txtSearch.Visible = True
    Cmd_Search.Visible = True
  End If
End Sub

Private Sub ComboType_Click()
  Refresh_Customer
End Sub

Private Sub Form_Load()
  '装入客户类别数据
  Loadtype
  '设置查询条件
  ComboSearch.ListIndex = 0
  
  '设置数据源的查询条件,并刷新显示
  Refresh_Customer
End Sub

Private Sub txtSearch_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    Refresh_Customer
  End If
End Sub

⌨️ 快捷键说明

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