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

📄 frmcontactman.frm

📁 vb做的数据库 客户管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "0"
         ForeColor       =   &H000000FF&
         Height          =   180
         Left            =   8520
         TabIndex        =   12
         Top             =   240
         Width           =   90
      End
      Begin VB.Label lblSel 
         Alignment       =   1  'Right Justify
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "0"
         ForeColor       =   &H000000FF&
         Height          =   180
         Left            =   8520
         TabIndex        =   11
         Top             =   720
         Width           =   90
      End
      Begin VB.Label Label7 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "客户名称"
         Height          =   180
         Left            =   480
         TabIndex        =   9
         Top             =   240
         Width           =   720
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "关键字查询"
         Height          =   180
         Left            =   300
         TabIndex        =   8
         Top             =   720
         Width           =   900
      End
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   375
      Left            =   120
      Top             =   5760
      Visible         =   0   'False
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   661
      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
End
Attribute VB_Name = "FrmContactMan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim SearchStr As String
Dim TmpSource As String

Private Sub Refresh_Contact(ByVal TmpSearch As Boolean)
  lblTotal = MyContact.CountContact
  
  TmpSource = "SELECT c.Id,c.CName AS 联系人,c.Sex AS 性别," _
        + "c.Office AS 联系电话," _
        + "c.Memo1 AS 其他," + "c.Input_date AS 修改日期,c.input_time AS 修改时间,c.CustId,s.CustName as 所在单位" _
        + " FROM Contact c,Types t,Customer s " _
        + " WHERE c.TitleId=t.Id And c.CustId=s.CustId"

  '客户名称
  If Trim(dc_Customer.Text) <> "" Then
    TmpSource = TmpSource + " And c.CustId=" + Trim(dc_Customer.BoundText)
  End If
  
  If TmpSearch = True Then
    TmpSource = TmpSource + " And (c.CName LIKE '%" + SearchStr _
              + "%' Or t.TypeName LIKE '%" + SearchStr _
              + "%' Or c.Sex LIKE '%" + SearchStr _
              + "%' Or c.Office LIKE '%" + SearchStr + "%')"
  End If
  
  TmpSource = TmpSource + " ORDER BY c.CName"
  
  Adodc1.ConnectionString = Conn
  Adodc1.RecordSource = TmpSource
  Adodc1.Refresh
  Set DataGrid1.DataSource = Adodc1
  lblSel = Adodc1.Recordset.RecordCount
  DataGrid1.Columns(0).Width = 0
  DataGrid1.Columns(1).Width = 1000
  DataGrid1.Columns(2).Width = 600
  DataGrid1.Columns(3).Width = 1200
  DataGrid1.Columns(4).Width = 1000
  DataGrid1.Columns(5).Width = 1300
  DataGrid1.Columns(6).Width = 1400
  DataGrid1.Columns(7).Width = 1000
  DataGrid1.Columns(8).Width = 1000


End Sub

Private Sub Check1_Click()
  If Check1.Value = 1 Then
    dc_Customer.Enabled = False
    dc_Customer.Text = ""
    txtSearch = ""
    Cmd_Add.Enabled = False
  Else
    dc_Customer.Enabled = True
    Cmd_Add.Enabled = True
  End If
  Refresh_Contact (False)
End Sub

Private Sub Cmd_Add_Click()
  If Len(Trim(dc_Customer.Text)) = 0 Then
    MsgBox "请选择客户名称"
    Exit Sub
  End If

  FrmContactEdit.Modify = False
  FrmContactEdit.OriCustId = dc_Customer.BoundText()
  FrmContactEdit.lbl_CustName = Trim(dc_Customer.Text)
  FrmContactEdit.ComboSex.ListIndex = 0
  FrmContactEdit.Show 1
  Refresh_Contact (False)
End Sub

Private Sub Cmd_Del_Click()
  If Adodc1.Recordset.EOF = True Then
    MsgBox "请选择记录"
    Exit Sub
  End If
  
  If MsgBox("是否删除当前记录?", vbYesNo, "确认") = vbYes Then
    Call MyContact.Delete(Adodc1.Recordset.Fields(0))
    Refresh_Contact (False)
  End If
End Sub

Private Sub Cmd_Search_Click()
  If txtSearch = "" Then
    MsgBox "请输入要查找的字符串"
    Exit Sub
  End If
  
  SearchStr = MakeStr(txtSearch)
  Refresh_Contact (True)
End Sub

Private Sub Cmd_Back_Click()
  Unload Me
End Sub

Private Sub Cmd_Modi_Click()
  If Adodc1.Recordset.EOF = True Then
    MsgBox "请选择记录"
    Exit Sub
  End If

  '从客户单位中提取数据
  FrmContactEdit.OriCustId = Adodc1.Recordset.Fields(7)
  FrmContactEdit.lbl_CustName = Trim(Adodc1.Recordset.Fields(8))
  '从客户联系人中提取
  FrmContactEdit.OriCtId = Adodc1.Recordset.Fields(0)
  '联系人
  FrmContactEdit.txtName = Trim(Adodc1.Recordset.Fields(1))
  '性别
  FrmContactEdit.ComboSex = Trim(Adodc1.Recordset.Fields(2))
'  '职务
'  FrmContactEdit.dc_Title.Text = Trim(Adodc1.Recordset.Fields(3))
  '单位电话
  FrmContactEdit.txtOffice = Trim(Adodc1.Recordset.Fields(3))
  
  '其他
  FrmContactEdit.txtMemo = Trim(Adodc1.Recordset.Fields(4))
  FrmContactEdit.Modify = True
  FrmContactEdit.Show 1
  Refresh_Contact (False)
End Sub

Private Sub dc_Customer_Click(Area As Integer)
  Refresh_Contact (False)
End Sub

Private Sub Form_Load()
  '装入客户信息
  AdoCust.ConnectionString = Conn
  AdoCust.RecordSource = "SELECT * FROM Customer ORDER BY CustName"
  AdoCust.Refresh
  Set dc_Customer.RowSource = AdoCust
  dc_Customer.ListField = "CustName"
  dc_Customer.BoundColumn = "CustId"
  Check1.Value = 1
  dc_Customer.Enabled = False
  Cmd_Add.Enabled = False
  Refresh_Contact (False)
End Sub

⌨️ 快捷键说明

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