?? mainfrm.frm
字號:
Left = 3360
TabIndex = 26
Top = 1200
Width = 735
End
Begin VB.Label Label17
Caption = "OICQ號"
Height = 255
Index = 0
Left = 3360
TabIndex = 25
Top = 1800
Width = 735
End
Begin VB.Label Label5
Caption = "民 族"
Height = 255
Left = -74655
TabIndex = 24
Top = 3480
Width = 735
End
Begin VB.Label Label7
Caption = "身份證 號 碼*"
Height = 375
Left = -74640
TabIndex = 23
Top = 3960
Width = 735
End
Begin VB.Label Label2
Caption = "性 別"
Height = 255
Left = -74655
TabIndex = 22
Top = 1680
Width = 735
End
Begin VB.Label Label3
Caption = "籍 貫"
Height = 255
Left = -74655
TabIndex = 21
Top = 2280
Width = 735
End
Begin VB.Label Label4
Caption = "生 日"
Height = 255
Left = -74655
TabIndex = 18
Top = 2880
Width = 735
End
End
Begin VB.Menu 文件
Caption = "文件(&F)"
Begin VB.Menu 預(yù)覽住戶
Caption = "預(yù)覽住戶(&P)"
End
Begin VB.Menu 退出系統(tǒng)
Caption = "退出系統(tǒng)(&E)"
End
End
Begin VB.Menu 編輯
Caption = "編輯(&E)"
Begin VB.Menu 添加住戶
Caption = "添加住戶(&A)"
End
Begin VB.Menu 刪除住戶
Caption = "刪除住戶(&D)"
End
Begin VB.Menu 修改住戶
Caption = "修改住戶(&M)"
End
Begin VB.Menu 查詢住戶
Caption = "查詢住戶(&S)"
End
End
Begin VB.Menu 視圖
Caption = "視圖(&V)"
Begin VB.Menu 基本資料
Caption = "基本資料(&B)"
End
Begin VB.Menu 聯(lián)絡(luò)資料
Caption = "聯(lián)絡(luò)資料(&T)"
End
Begin VB.Menu 其它資料
Caption = "其它資料(&Q)"
End
Begin VB.Menu 總攬全局
Caption = "總攬全局(&A)"
End
End
Begin VB.Menu 幫助
Caption = "幫助(&H)"
Begin VB.Menu 關(guān)于本系統(tǒng)
Caption = "關(guān)于本系統(tǒng)(&A)"
End
Begin VB.Menu 聯(lián)系我們
Caption = "聯(lián)系我們(&C)"
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim IsAdd As Boolean
Private Function OpenDB() As Boolean
On Error GoTo err
Dim Pathstr As String
Pathstr = App.Path + "\db2.mdb"
Set Mdata = Workspaces(0).OpenDatabase(Pathstr)
Set Mrec = Mdata.OpenRecordset("MP")
OpenDB = True
Exit Function
err:
OpenDB = False
End Function
Private Sub ShutDB()
Mrec.Close
Mdata.Close
End Sub
Public Sub ShowA()
Text(0).Text = Mrec!姓名 & ""
Text(1).Text = Mrec!性別 & ""
Text(2).Text = Mrec!籍貫 & ""
Text(3).Text = Mrec!生日 & ""
Text(4).Text = Mrec!民族 & ""
Text(5).Text = Mrec!身份證號碼 & ""
Text(6).Text = Mrec!住宅電話 & ""
Text(7).Text = Mrec!手機(jī)號碼 & ""
Text(8).Text = Mrec!傳真號碼 & ""
Text(9).Text = Mrec!家庭住址 & ""
Text(10).Text = Mrec!E_mail & ""
Text(11).Text = Mrec!網(wǎng)址 & ""
Text(12).Text = Mrec!單位電話 & ""
Text(13).Text = Mrec!傳呼號碼 & ""
Text(14).Text = Mrec!OICQ & ""
Text(15).Text = Mrec!小靈通 & ""
Text(16).Text = Mrec!公司地址 & ""
Text(17).Text = Mrec!備注 & ""
End Sub
Private Sub GetField()
Mrec!姓名 = Text(0).Text & ""
Mrec!性別 = Text(1).Text & ""
Mrec!籍貫 = Text(2).Text & ""
Mrec!生日 = Text(3).Text & ""
Mrec!民族 = Text(4).Text & ""
Mrec!身份證號碼 = Text(5).Text & ""
Mrec!住宅電話 = Text(6).Text & ""
Mrec!手機(jī)號碼 = Text(7).Text & ""
Mrec!傳真號碼 = Text(8).Text & ""
Mrec!家庭住址 = Text(9).Text & ""
Mrec!E_mail = Text(10).Text & ""
Mrec!網(wǎng)址 = Text(11).Text & ""
Mrec!單位電話 = Text(12).Text & ""
Mrec!傳呼號碼 = Text(13).Text & ""
Mrec!OICQ = Text(14).Text & ""
Mrec!小靈通 = Text(15).Text & ""
Mrec!公司地址 = Text(16).Text & ""
Mrec!備注 = Text(17).Text & ""
End Sub
Private Sub ShowMP()
'顯示全部記錄,至list1
List1.Clear
Dim i As Long
If Mrec.RecordCount = 0 Then Exit Sub
Mrec.MoveFirst
'添加標(biāo)簽名稱
List1.AddItem StrAdjust("姓名", 6, True) + _
StrAdjust("身份證號碼", 19, True) + _
StrAdjust("家庭住址", 10, True) + _
StrAdjust("住宅電話 ", 10, True) + _
StrAdjust("公司地址", 10, True) + _
StrAdjust("單位電話 ", 10, True) + _
StrAdjust("備注", 10, True)
'顯示每一條記錄
For i = 1 To Mrec.RecordCount
List1.AddItem StrAdjust(Mrec!姓名 + "", 6, True) + _
StrAdjust(Mrec!身份證號碼 + "", 19, True) + _
StrAdjust(Mrec!家庭住址 + "", 10, True) + _
StrAdjust(Mrec!住宅電話 + "", 10, True) + _
StrAdjust(Mrec!公司地址 + "", 10, True) + _
StrAdjust(Mrec!單位電話 + "", 10, True) + _
StrAdjust(Mrec!備注, 10, True)
Mrec.MoveNext
Next
Mrec.MoveFirst
End Sub
Private Sub Form_Load()
OpenDB
If Mrec.RecordCount > 0 Then
ShowA
ShowMP
End If
End Sub
'控件組
Private Sub Command1_Click() '添加住戶
Dim i As Integer
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = True
For i = 0 To 17
Text(i).Text = ""
Text(i).Locked = False '打開文本框
Next
IsAdd = True '如果是添加新記錄操作,IsAdd=真;編輯Edit操作 IsAdd=假
Text(0).SetFocus
'mrec.AddNew
End Sub
Private Sub Command2_Click() '住戶修改
Dim i As Integer
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Command8.Enabled = True
For i = 0 To 17
Text(i).Locked = False
Next
IsAdd = False '如果是添加新記錄操作,IsAdd=真;編輯Edit操作 IsAdd=假
Text(0).SetFocus
End Sub
Private Sub Command3_Click() '刪除住戶
Command8.Enabled = True
If Mrec.RecordCount = 0 Then
MsgBox "已經(jīng)沒有數(shù)據(jù)可刪除了!!!", , "錯誤!"
Exit Sub
End If
If MsgBox("您確定要刪除當(dāng)前住戶嗎?", vbQuestion + vbYesNo, "提示") = vbYes Then
Mrec.Delete
Mrec.MoveFirst
ShowA
ShowMP
End If
End Sub
Private Sub Command4_Click() '住戶保存
Dim i As Integer
If IsAdd Then '如果是true,加入新記錄
Mrec.AddNew
GetField '自定義函數(shù)
Else
Mrec.Edit '如果是false,則
GetField
End If
Mrec.Update
Mrec.MoveFirst
ShowA
ShowMP
For i = 0 To 17
Text(i).Locked = True
Next
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = False
End Sub
Private Sub Command5_Click() 'next
Command8.Enabled = False
If Mrec.RecordCount = 0 Then
Command5.Enabled = False
Command6.Enabled = False
Else
Mrec.MoveNext
If Mrec.EOF Then
Mrec.MoveLast
Command5.Enabled = False
Else
Command5.Enabled = True
Command6.Enabled = True
End If
ShowA
End If
End Sub
Private Sub Command6_Click() 'previous
Command8.Enabled = False
If Mrec.RecordCount = 0 Then
Command5.Enabled = False
Command6.Enabled = False
Else
Mrec.MovePrevious
If Mrec.BOF Then
Mrec.MoveFirst
Command6.Enabled = False
Else
Command5.Enabled = True
Command6.Enabled = True
End If
ShowA
End If
End Sub
Private Sub Command7_Click()
frminquire.Show
End Sub
Private Sub Command8_Click()
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Command8.Enabled = False
End Sub
Private Sub Command9_Click()
frmrela.Show
End Sub
Private Sub Text_KeyPress(Index As Integer, KeyAscii As Integer)
Dim t As Integer
If Chr(KeyAscii) = Chr(13) Then
t = (Index + 1) Mod 18
Text(t).SetFocus
'用t判斷顯示第幾頁
If t >= 0 And t <= 5 Then SSTab1.Tab = 0
If t > 5 And t <= 16 Then SSTab1.Tab = 1
If t > 16 Then SSTab1.Tab = 2
End If
End Sub
Private Sub 聯(lián)系我們_Click()
ShellExecute 0&, vbNullString, "MailTo:mengxin@eyou.com", vbNullString, vbNullString, vbNormalFocus
End Sub
'菜單文件
Private Sub 預(yù)覽住戶_Click()
SSTab1.Tab = 3
End Sub
Private Sub 退出系統(tǒng)_Click()
End
End Sub
'菜單編輯
Private Sub 添加住戶_Click()
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Dim i As Integer
For i = 0 To 17
Text(i).Locked = False
Text(i).Text = ""
Next
Text(0).SetFocus
End Sub
Private Sub 刪除住戶_Click()
If Mrec.RecordCount = 0 Then
MsgBox "已經(jīng)沒有數(shù)據(jù)可刪除了!!!", , "錯誤!"
Exit Sub
End If
If MsgBox("您確定要刪除當(dāng)前住戶嗎?", vbQuestion + vbYesNo, "提示") = vbYes Then
Mrec.Delete
Mrec.MoveFirst
ShowA
ShowMP
End If
End Sub
Private Sub 修改住戶_Click()
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
Dim i As Integer
For i = 0 To 17
Text(i).Locked = False
Next
Text(0).SetFocus
End Sub
Private Sub 查詢住戶_Click()
frminquire.Show
End Sub
'菜單視圖
Private Sub 基本資料_Click()
SSTab1.Tab = 0
End Sub
Private Sub 聯(lián)絡(luò)資料_Click()
SSTab1.Tab = 1
End Sub
Private Sub 其它資料_Click()
SSTab1.Tab = 2
End Sub
Private Sub 總攬全局_Click()
SSTab1.Tab = 3
End Sub
'菜單幫助
Private Sub 關(guān)于本系統(tǒng)_Click()
Dim HH As String, Blank As String
'字符串中間加chr(13)+chr(10),回車,換行
HH = Chr(13) + Chr(10)
MsgBox Blank + HH + "常駐人口管理系統(tǒng) V1.0 + " + _
HH + HH + "開發(fā)工具:Visual Basic 6.0" + HH + HH + _
"制作人:王俏" + HH + HH + HH + _
"Email:mengxin0839@eyou.com" + HH + _
"qq:17795025", vbOKOnly, "關(guān)于本系統(tǒng)...."
'frmshow.
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -