frmAddClerk.frm
上传用户:yexiandon
上传日期:2022-07-12
资源大小:895k
文件大小:10k
- VERSION 5.00
- Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
- Begin VB.Form frmAddClerk
- BorderStyle = 3 'Fixed Dialog
- Caption = "职员"
- ClientHeight = 2340
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 5940
- Icon = "frmAddClerk.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 2340
- ScaleWidth = 5940
- ShowInTaskbar = 0 'False
- StartUpPosition = 3 '窗口缺省
- Begin VB.Frame frabaseInfo
- Caption = "基本信息"
- Height = 1635
- Left = 120
- TabIndex = 14
- Top = 120
- Width = 5655
- Begin VB.TextBox txtMobile
- Height = 300
- Left = 3720
- TabIndex = 11
- Top = 1080
- Width = 1695
- End
- Begin VB.TextBox txtZW
- Height = 300
- Left = 3720
- TabIndex = 3
- Top = 345
- Width = 1695
- End
- Begin VB.TextBox txtName
- Height = 300
- Left = 720
- TabIndex = 1
- Top = 300
- Width = 2055
- End
- Begin VB.ComboBox cboDepart
- Height = 300
- ItemData = "frmAddClerk.frx":000C
- Left = 720
- List = "frmAddClerk.frx":000E
- Style = 2 'Dropdown List
- TabIndex = 9
- Top = 1050
- Width = 2055
- End
- Begin VB.ComboBox cboSex
- Height = 300
- ItemData = "frmAddClerk.frx":0010
- Left = 720
- List = "frmAddClerk.frx":001A
- Style = 2 'Dropdown List
- TabIndex = 5
- Top = 675
- Width = 2055
- End
- Begin MSComCtl2.DTPicker dtRZ
- Height = 285
- Left = 3720
- TabIndex = 7
- Top = 720
- Width = 1695
- _ExtentX = 2990
- _ExtentY = 503
- _Version = 393216
- Format = 25559040
- CurrentDate = 39295
- End
- Begin VB.Label Label2
- AutoSize = -1 'True
- Caption = "入职日期"
- Height = 180
- Left = 2880
- TabIndex = 6
- Top = 765
- Width = 720
- End
- Begin VB.Label Label7
- AutoSize = -1 'True
- Caption = "电话"
- Height = 180
- Left = 2880
- TabIndex = 10
- Top = 1140
- Width = 360
- End
- Begin VB.Label Label8
- AutoSize = -1 'True
- Caption = "职务"
- Height = 180
- Left = 2880
- TabIndex = 2
- Top = 390
- Width = 360
- End
- Begin VB.Label Label1
- AutoSize = -1 'True
- Caption = "姓名"
- Height = 180
- Left = 240
- TabIndex = 0
- Top = 360
- Width = 360
- End
- Begin VB.Label Label5
- AutoSize = -1 'True
- Caption = "性别"
- Height = 180
- Left = 240
- TabIndex = 4
- Top = 735
- Width = 360
- End
- Begin VB.Label Label10
- AutoSize = -1 'True
- Caption = "部门"
- Height = 180
- Left = 240
- TabIndex = 8
- Top = 1110
- Width = 360
- End
- End
- Begin VB.CommandButton OKButton
- Caption = "确定"
- Height = 300
- Left = 3480
- TabIndex = 12
- Top = 1920
- Width = 975
- End
- Begin VB.CommandButton CancelButton
- Caption = "取消"
- Height = 300
- Left = 4560
- TabIndex = 13
- Top = 1920
- Width = 975
- End
- End
- Attribute VB_Name = "frmAddClerk"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '****************************************************************************
- '人人为我,我为人人
- '枕善居收藏整理
- '发布日期:2008/01/21
- '描 述:汽车维修管理系统SQL2000版
- '网 站:http://www.Mndsoft.com/ (VB6源码博客)
- '网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
- 'e-mail :Mndsoft@163.com
- 'e-mail :Mndsoft@126.com
- 'OICQ :88382850
- ' 如果您有新的好的代码别忘记给枕善居哦!
- '****************************************************************************
- Option Explicit
- Public mvarViewType As gxcViewType
- Public mvarID As String
- Public OK As Boolean
- '根据对话框的显示方式来确定显示的数据
- Private Sub SetStatus()
- Dim ctl As Control
- Dim intBorderStyle As Integer
- Dim lngbkColor As Long
- Dim boolLocked As Boolean
-
- '默认的文本框风格设置
- intBorderStyle = 1 '3D
- lngbkColor = &H80000009
- boolLocked = False
- OKButton.Visible = True
- CancelButton.Caption = "取消"
- Select Case mvarViewType
- Case vtadd '添加客户
- OKButton.Caption = "确定"
- Me.Caption = "添加职员"
- SetDefaultValue
- Case vtModify '修改客户信息
- OKButton.Caption = "保存"
- Me.Caption = "修改职员信息"
- SetDefaultValue g_Conn.Execute("Select * from Clerk WHERE clkID=" & GetID(mvarID))
- Case vtinfo '查看客户信息
- '只读的文本框风格设置
- intBorderStyle = 0 '3D
- lngbkColor = &H8000000F
- boolLocked = True
- OKButton.Visible = False
- CancelButton.Caption = "关闭"
- Me.Caption = "查看职员信息"
- SetDefaultValue g_Conn.Execute("Select * from Clerk where clkID=" & GetID(mvarID))
- Case Else
- End Select
-
- '根据显示状态不同设置文本框风格
- For Each ctl In Controls
- If (TypeOf ctl Is TextBox) Then
- ctl.BorderStyle = intBorderStyle
- ctl.BackColor = lngbkColor
- ctl.Locked = boolLocked
- ElseIf (TypeOf ctl Is ComboBox) Or _
- (TypeOf ctl Is DTPicker) Or _
- (TypeOf ctl Is CheckBox) Or _
- (TypeOf ctl Is Slider) Then
- ctl.Enabled = Not boolLocked
- End If
- Next
-
- End Sub
- Public Sub AllClientsTypeToCombo(ByRef cbo As ComboBox)
- '传入参数为客户的集合类与列表框
- Dim i As Long
- Dim objTypes As New Recordset
- cbo.Clear '清除当前的列表内容
- Set objTypes = g_Conn.Execute("Select DepartId,Dname from Depart")
- For i = 1 To objTypes.RecordCount
- '将每个“客户”都加入到该列表中,调用了单独的函数,没有全部做到这
- '个函数中,为什么呢?参看AddClientToLvw函数
- Call cbo.AddItem(objTypes(1), i - 1)
- cbo.ItemData(i - 1) = objTypes(0)
- objTypes.MoveNext
- Next i
- End Sub
- Private Sub CancelButton_Click()
- OK = True
- Unload Me
- End Sub
- Private Sub Form_Load()
- SetStatus
- OK = False
- End Sub
- Private Sub SetDefaultValue(Optional objClient As ADODB.Recordset)
- Dim ctl As Control
- Dim i As Integer
-
- '添加所有的客户类型到组合框
- AllClientsTypeToCombo cboDepart
- If objClient Is Nothing Then Exit Sub
- For i = 0 To cboDepart.ListCount - 1
- If cboDepart.ItemData(i) = objClient("clkDepart") Then
- cboDepart.ListIndex = i '客户类型Id
- Exit For
- End If
- Next i
-
- If objClient Is Nothing Then
- For Each ctl In Controls
- If TypeOf ctl Is TextBox Then
- ctl.Text = ""
- End If
- Next
- Else
- With objClient
- txtName.Text = .Fields("clkName")
- cboSex.ListIndex = IIf(.Fields("clkSex") = Male, 0, 1) '性别
- txtMobile.Text = .Fields("clkTel") '手机
- txtZW.Text = .Fields("clkZW") '宅电
- End With
- End If
- End Sub
- Private Sub OKButton_Click()
- Dim ErrMsg As String
- Select Case mvarViewType
- Case vtadd '添加客户
- ' SaveData
- If ExistByName("Clerk", "clkName", txtName) Then
- If MsgBox("职员姓名已经存在,确认继续保存吗?", vbQuestion + vbYesNo + _
- vbDefaultButton2) = vbNo Then Exit Sub
- End If
- If Chk Then If RunSql("insert into clerk(clkName,clkSex,clkDepart,clkZw,clkInDate,clkTel) " & _
- "Values('" & txtName & "','" & cboSex.ListIndex & "','" & cboDepart.ItemData(cboDepart.ListIndex) & _
- "','" & txtZW & "','" & Format(dtRZ, "YYYY-MM-DD") & _
- "','" & txtMobile & "')", ErrMsg) Then Else MsgBox "未知错误!" Else Exit Sub
- Case vtModify '修改客户信息
- ' ModiData
- If ExistByValueID("Clerk", "clkID", GetID(mvarID), "clkName", txtName) Then
- If MsgBox("职员姓名已经存在,确认继续保存吗?", vbQuestion + vbYesNo + _
- vbDefaultButton2) = vbNo Then Exit Sub
- End If
- If Chk Then If RunSql("Update Clerk set clkName='" & txtName & "',clkSex='" & cboSex.ListIndex & _
- "',clkDepart='" & cboDepart.ItemData(cboDepart.ListIndex) & "',clkZw='" & txtZW & _
- "',clkInDate='" & Format(dtRZ, "YYYY-MM-DD") & "',clkTel='" & txtMobile & "' where clkID=" & _
- GetID(mvarID), ErrMsg) Then Else MsgBox "未知错误!" Else Exit Sub
- Case Else
- End Select
- OK = True
- Unload Me
- End Sub
- Private Function Chk() As Boolean
- If Trim(txtName) = "" Then
- MsgBox "姓名不能为空!"
- Chk = False
- Exit Function
- ElseIf cboSex = "" Then
- MsgBox "性别不能为空!"
- Chk = False
- Exit Function
- ElseIf cboDepart = "" Then
- MsgBox "部门不能为空!"
- Chk = False
- Exit Function
- End If
- Chk = True
- End Function