📄 main_fzgj_addresslist.frm
字号:
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub CmdAdd_Click()
txtName.Text = ""
txtSex.Text = ""
txtEmail.Text = ""
txtPhone.Text = ""
txtMobile.Text = ""
txtPersonNet.Text = "http://"
txtOperation.Text = ""
txtFax.Text = ""
txtDuty.Text = ""
txtDept.Text = ""
txtOffice.Text = ""
txtCompanyName.Text = ""
txtCompanyNet.Text = "http://"
Call txtUnLock
cmdAdd.Enabled = False
cmdUpdata.Enabled = False
cmdDel.Enabled = False
cmdSave.Enabled = True
cmdCancel.Enabled = True
txtName.SetFocus '使控件获得焦点
Adodc1.Recordset.AddNew
End Sub
Private Sub cmdCancel_Click()
Adodc1.Recordset.CancelBatch
txtName.Text = ""
txtSex.Text = ""
txtEmail.Text = ""
txtPhone.Text = ""
txtMobile.Text = ""
txtPersonNet.Text = ""
txtOperation.Text = ""
txtFax.Text = ""
txtDuty.Text = ""
txtDept.Text = ""
txtOffice.Text = ""
txtCompanyName.Text = ""
txtCompanyNet.Text = ""
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdUpdata.Enabled = False
cmdDel.Enabled = False
cmdAdd.Enabled = True
Call txtLock
End Sub
Private Sub cmdDel_Click()
If MsgBox("确定要删除当前记录吗?", vbOKCancel + vbQuestion, "提示") = vbOK Then
Adodc1.Recordset.Delete
End If
End Sub
Private Sub CmdEnd_Click()
Unload Me
End Sub
Private Sub cmdFind_Click()
Adodc1.RecordSource = "select * from tbS_address where 姓名 like '" & txtFind.Text & "%'"
Adodc1.Refresh
End Sub
Private Sub cmdsave_Click()
If txtName = "" Then
MsgBox "姓名不能为空!", vbOKOnly + vbInformation, "提示"
txtName.SetFocus '使控件获得焦点
Exit Sub
End If
Adodc1.Recordset.Fields(1).Value = txtName.Text
Adodc1.Recordset.Fields(2).Value = txtSex.Text
Adodc1.Recordset.Fields(3).Value = txtEmail.Text
Adodc1.Recordset.Fields(4).Value = txtPhone.Text
Adodc1.Recordset.Fields(5).Value = txtMobile.Text
Adodc1.Recordset.Fields(6).Value = txtPersonNet.Text
Adodc1.Recordset.Fields(7).Value = txtOperation.Text
Adodc1.Recordset.Fields(8).Value = txtFax.Text
Adodc1.Recordset.Fields(9).Value = txtDuty.Text
Adodc1.Recordset.Fields(10).Value = txtDept.Text
Adodc1.Recordset.Fields(11).Value = txtOffice.Text
Adodc1.Recordset.Fields(12).Value = txtCompanyName.Text
Adodc1.Recordset.Fields(13).Value = txtCompanyNet.Text
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.RecordSource = "select * from tbS_address"
Adodc1.Refresh
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdUpdata.Enabled = False
cmdDel.Enabled = False
cmdAdd.Enabled = True
cmdAdd.SetFocus '使控件获得焦点
Call txtLock
End Sub
Private Sub cmdUpdata_Click()
cmdAdd.Enabled = False
cmdDel.Enabled = False
cmdSave.Enabled = True
cmdCancel.Enabled = True
Call txtUnLock
End Sub
Private Sub cmdURL_Click()
If txtPersonNet <> "" Then
ShellExecute Me.hWnd, "open", txtPersonNet.Text, 1, 1, 5
End If
End Sub
Private Sub cmdURL2_Click()
If txtCompanyNet.Text <> "" Then
ShellExecute Me.hWnd, "open", txtCompanyNet.Text, 1, 1, 5
End If
End Sub
Private Sub DataGrid1_MouseUp(Button As Integer, Shift As Integer, X As Single, y As Single)
If Button = 2 Then
PopupMenu OP
ElseIf Button = 1 Then
cmdDel.Enabled = True
cmdUpdata.Enabled = True
End If
End Sub
Private Sub DataGrid1_RowColChange(LastRow As Variant, ByVal LastCol As Integer)
txtName.Text = DataGrid1.Columns.Item(1).Text
txtSex.Text = DataGrid1.Columns.Item(2).Text
txtEmail.Text = DataGrid1.Columns.Item(3).Text
txtPhone.Text = DataGrid1.Columns.Item(4).Text
txtMobile.Text = DataGrid1.Columns.Item(5).Text
txtPersonNet.Text = DataGrid1.Columns.Item(6).Text
txtOperation.Text = DataGrid1.Columns.Item(7).Text
txtFax.Text = DataGrid1.Columns.Item(8).Text
txtDuty.Text = DataGrid1.Columns.Item(9).Text
txtDept.Text = DataGrid1.Columns.Item(10).Text
txtOffice.Text = DataGrid1.Columns.Item(11).Text
txtCompanyName.Text = DataGrid1.Columns.Item(12).Text
txtCompanyNet.Text = DataGrid1.Columns.Item(13).Text
If txtName = "" Then
txtCompanyNet.Text = "http://"
txtPersonNet.Text = "http://"
End If
End Sub
Private Sub Del_Click()
cmdDel.Enabled = True
cmdUpdata.Enabled = False
cmdAdd.Enabled = False
cmdCancel.Enabled = True
cmdSave.Enabled = True
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = PublicStr
Adodc1.RecordSource = "select * from tbS_address"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
cmdSave.Enabled = False
cmdCancel.Enabled = False
cmdUpdata.Enabled = False
cmdDel.Enabled = False
cmdAdd.Enabled = True
Call txtLock
End Sub
Private Sub txtCompanyName_GotFocus()
txtCompanyName.BackColor = &HFFC0FF
End Sub
Private Sub txtCompanyName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtCompanyName_LostFocus()
txtCompanyName.BackColor = &H80000018
End Sub
Private Sub txtCompanyNet_GotFocus()
txtCompanyNet.BackColor = &HFFC0FF
End Sub
Private Sub txtCompanyNet_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtCompanyNet_LostFocus()
txtCompanyNet.BackColor = &H80000018
End Sub
Private Sub txtDept_GotFocus()
txtDept.BackColor = &HFFC0FF
End Sub
Private Sub txtDept_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtDept_LostFocus()
txtDept.BackColor = &H80000018
End Sub
Private Sub txtDuty_GotFocus()
txtDuty.BackColor = &HFFC0FF
End Sub
Private Sub txtDuty_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtDuty_LostFocus()
txtDuty.BackColor = &H80000018
End Sub
Private Sub txtEmail_GotFocus()
txtEmail.BackColor = &HFFC0FF
End Sub
Private Sub txtEmail_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtEmail_LostFocus()
txtEmail.BackColor = &H80000018
End Sub
Private Sub txtFax_GotFocus()
txtFax.BackColor = &HFFC0FF
End Sub
Private Sub txtFax_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtFax_LostFocus()
txtFax.BackColor = &H80000018
End Sub
Private Sub txtMobile_GotFocus()
txtMobile.BackColor = &HFFC0FF
End Sub
Private Sub txtMobile_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtMobile_LostFocus()
txtMobile.BackColor = &H80000018
End Sub
Private Sub txtName_GotFocus()
txtName.BackColor = &HFFC0FF
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtName_LostFocus()
txtName.BackColor = &H80000018
End Sub
Private Sub txtOffice_GotFocus()
txtOffice.BackColor = &HFFC0FF
End Sub
Private Sub txtOffice_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtOffice_LostFocus()
txtOffice.BackColor = &H80000018
End Sub
Private Sub txtOperation_GotFocus()
txtOperation.BackColor = &HFFC0FF
End Sub
Private Sub txtOperation_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtOperation_LostFocus()
txtOperation.BackColor = &H80000018
End Sub
Private Sub txtPersonNet_GotFocus()
txtPersonNet.BackColor = &HFFC0FF
End Sub
Private Sub txtPersonNet_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtPersonNet_LostFocus()
txtPersonNet.BackColor = &H80000018
End Sub
Private Sub txtPhone_GotFocus()
txtPhone.BackColor = &HFFC0FF
End Sub
Private Sub txtPhone_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtPhone_LostFocus()
txtPhone.BackColor = &H80000018
End Sub
Private Sub txtSex_GotFocus()
txtSex.BackColor = &HFFC0FF
End Sub
Private Sub txtSex_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then SendKeys "{TAB}", True
End Sub
Private Sub txtSex_LostFocus()
txtSex.BackColor = &H80000018
End Sub
Private Sub Updata_Click()
cmdUpdata.Enabled = True
cmdDel.Enabled = False
cmdAdd.Enabled = False
cmdCancel.Enabled = True
cmdSave.Enabled = True
End Sub
Sub txtLock()
txtName.Enabled = False
txtSex.Enabled = False
txtEmail.Enabled = False
txtPhone.Enabled = False
txtMobile.Enabled = False
txtPersonNet.Enabled = False
txtOperation.Enabled = False
txtFax.Enabled = False
txtDuty.Enabled = False
txtDept.Enabled = False
txtOffice.Enabled = False
txtCompanyName.Enabled = False
txtCompanyNet.Enabled = False
End Sub
Sub txtUnLock()
txtName.Enabled = True
txtSex.Enabled = True
txtEmail.Enabled = True
txtPhone.Enabled = True
txtMobile.Enabled = True
txtPersonNet.Enabled = True
txtOperation.Enabled = True
txtFax.Enabled = True
txtDuty.Enabled = True
txtDept.Enabled = True
txtOffice.Enabled = True
txtCompanyName.Enabled = True
txtCompanyNet.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -