📄 form7.frm
字号:
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2007/12/24
'描 述:商务名片及客户资料管理系统 Ver 1.73
'网 站: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
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
Text1.SetFocus
Exit Sub
End If
If Len(Trim(Text2.Text)) < 7 Then
MsgBox "员工的号码的长度不够,最低不能低于7位啊!", vbInformation, "号码错误"
Exit Sub
End If
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(MdbPath)
Set rs = db.OpenRecordset("select * from mycom")
rs.AddNew
rs!姓名 = Trim(Text1.Text)
rs!手机号码 = Trim(Text2.Text)
rs.Update
Dim Db2 As Database
Dim rs2 As Recordset
Set Db2 = OpenDatabase(MdbPath)
Set rs2 = db.OpenRecordset("select * from mycom order by id desc")
If rs2.RecordCount = 0 Then
Text1.SetFocus
Else
rs2.MoveLast
rs2.MoveFirst
Me.MSFlexGrid1.Rows = rs2.RecordCount + 1
Me.MSFlexGrid1.TextMatrix(0, 0) = "ID"
Me.MSFlexGrid1.TextMatrix(0, 1) = "姓名"
Me.MSFlexGrid1.TextMatrix(0, 2) = "随身电话"
Dim i As Integer
For i = 1 To rs.RecordCount
Me.MSFlexGrid1.TextMatrix(i, 0) = rs2!id
Me.MSFlexGrid1.TextMatrix(i, 1) = rs2!姓名
Me.MSFlexGrid1.TextMatrix(i, 2) = rs2!手机号码
rs2.MoveNext
Next i
End If
Me.Text1.Text = ""
Me.Text2.Text = ""
End Sub
Private Sub Command2_Click()
Dim db As Database
Dim rs As Recordset
Dim ming As String
Set db = OpenDatabase(MdbPath)
Set rs = db.OpenRecordset("select * from mycom where id =" & Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 0))
If rs.RecordCount > 0 Then
ming = rs!姓名
If MsgBox("将要把员工(" & ming & ")给删除吗?该操作将不可恢复。请谨慎。", vbQuestion + vbYesNo + vbDefaultButton2, "删除本单位员工") = vbYes Then
rs.Delete
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
MsgBox "删除操作完毕!", vbInformation, "完毕"
Me.MSFlexGrid1.Clear
LoadYuangong
End If
End If
End Sub
Private Sub Command3_Click()
If Len(Trim(Text3.Text)) <> 6 Then
MsgBox "软件设定的邮政编码位数为6位,请仔细填写。", vbCritical
Text3.SetFocus
Exit Sub
End If
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(MdbPath)
Set rs = db.OpenRecordset("select * from proset")
If rs.RecordCount = 0 Then
rs.AddNew
rs!yb = Trim(Text3.Text)
rs.Update
MsgBox "本地邮政编码设置成功!", vbInformation, "更改邮编"
ElseIf rs.RecordCount = 1 Then
rs.MoveFirst
rs.Edit
rs!yb = Trim(Text3.Text)
rs.Update
MsgBox "本地邮政编码设置成功!", vbInformation, "更改邮编"
End If
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
Private Sub Command4_Click()
If Trim(Text4.Text) = "" Then
MsgBox "员工标志量丢失,无法写入数据库。", vbCritical
Exit Sub
End If
If Trim(Text5.Text) = "" Then
MsgBox "员工名称为空,无法写入数据库。"
Exit Sub
End If
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(MdbPath)
Set rs = db.OpenRecordset("select * from mycom where id =" & Trim(Me.Text4.Text))
If rs.RecordCount > 0 Then
rs.MoveLast
rs.MoveLast
End If
If rs.RecordCount = 1 Then
rs.Edit
rs!姓名 = Trim(Text5.Text)
rs!手机号码 = Trim(Text6.Text)
rs.Update
rs.Close
db.Close
MsgBox "更改完成!", vbInformation
Me.MSFlexGrid1.Clear
LoadYuangong
Exit Sub
End If
If rs.RecordCount > 1 Then
MsgBox "数据库中的员工的标志量存在重复,无法确定将要修改的员工,可能是数据库紊乱导致的,请和软件提供者联系。", vbCritical
rs.Close
db.Close
ElseIf rs.RecordCount = 0 Then
MsgBox "数据库中没有找到这个标志量所代表的员工,无法确定将要修改的员工,可能是数据库紊乱导致的,或该员工信息已经被删除,请和软件提供者联系。", vbCritical
rs.Close
db.Close
End If
End Sub
Private Sub Form_Load()
Me.Icon = MDIForm1.Icon
HookWheel Me.hwnd '用于支持鼠标滚轮
Me.BackColor = FormBackColor: Me.Frame1.BackColor = Me.BackColor: Me.Frame2.BackColor = Me.BackColor
Me.MSFlexGrid1.ColWidth(0) = 500
Me.MSFlexGrid1.ColWidth(1) = 800
Me.MSFlexGrid1.ColWidth(2) = 2000
Me.Frame3.BackColor = Me.BackColor
Me.MSFlexGrid1.RowHeight(0) = 300
Me.MSFlexGrid1.BackColorFixed = 16777178
Me.MSFlexGrid1.BackColorBkg = MsFlexGridBackColorBkgValue
Me.Height = 5640
Me.Width = 7245
Me.Text1.Text = ""
Me.Text2.Text = ""
LoadYuangong
End Sub
Private Sub LoadYuangong()
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase(MdbPath)
Set rs = db.OpenRecordset("select * from mycom order by 姓名")
If rs.RecordCount = 0 Then
Else
rs.MoveLast
rs.MoveFirst
Me.MSFlexGrid1.Rows = rs.RecordCount + 1
Me.MSFlexGrid1.TextMatrix(0, 0) = "ID"
Me.MSFlexGrid1.TextMatrix(0, 1) = "姓名"
Me.MSFlexGrid1.TextMatrix(0, 2) = "随身电话"
Dim i As Integer
For i = 1 To rs.RecordCount
Me.MSFlexGrid1.TextMatrix(i, 0) = rs!id
Me.MSFlexGrid1.TextMatrix(i, 1) = rs!姓名
Me.MSFlexGrid1.TextMatrix(i, 2) = rs!手机号码
rs.MoveNext
Next i
End If
Me.Caption = "设置本单位的员工名单" & "(共" & rs.RecordCount & "位)"
Set rs = db.OpenRecordset("select * from proset")
If rs.RecordCount = 0 Then
rs.AddNew
rs!yb = ""
rs.Update
rs.MoveFirst
End If
If IsNull(rs!yb) = False Then
Text3.Text = Trim(rs!yb)
End If
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
End Sub
Private Sub Form_Resize()
On Error GoTo a1
Me.Height = 5640
Me.Width = 7245
Exit Sub
a1:
End Sub
Private Sub Form_Unload(Cancel As Integer)
AllBaiFangShow = False
End Sub
Private Sub MSFlexGrid1_GotFocus()
Set CtlWheel = MSFlexGrid1 '用于设定支持鼠标滚轮
End Sub
Private Sub MSFlexGrid1_LostFocus()
Set CtlWheel = Nothing '用于设定取消鼠标滚轮的支持
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
UnHookWheel Me.hwnd '卸载鼠标滚轮的支持
End Sub
Private Sub MSFlexGrid1_SelChange()
If Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 0) = "" Then
Exit Sub
End If
If Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 0) = "ID" Then
Exit Sub
End If
Text4.Text = Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 0))
Text5.Text = Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 1))
Text6.Text = Trim(Me.MSFlexGrid1.TextMatrix(Me.MSFlexGrid1.RowSel, 2))
End Sub
Private Sub Text1_GotFocus()
SendKeys "{end}"
End Sub
Private Sub Text2_GotFocus()
SendKeys "{end}"
End Sub
Private Sub Text3_GotFocus()
SendKeys "{end}"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -