?? frm_jcxxwh_khmyd.frm
字號(hào):
ButtonWidth = 1138
ButtonHeight = 1191
Appearance = 1
Style = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 9
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = " 增加 "
Key = "add"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "修改"
Key = "modify"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "刪除"
Key = "delete"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "保存"
Key = "save"
ImageIndex = 4
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "取消"
Key = "cancel"
ImageIndex = 5
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "查找"
Key = "find"
ImageIndex = 6
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Enabled = 0 'False
Style = 3
EndProperty
BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "關(guān)閉"
Key = "close"
ImageIndex = 7
EndProperty
EndProperty
BorderStyle = 1
End
End
Attribute VB_Name = "Frm_Jcxxwh_Khmyd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs1 As New ADODB.Recordset
Public blnAdd As Boolean
Dim mybookmark
Dim Mystr As String '定義字符串變量
Sub view_data() '顯示數(shù)據(jù)信息
Dim i As Integer
If Adodc1.Recordset.RecordCount > 0 Then
For i = 0 To Text1.UBound
Text1(i).Text = Dgr_Khmyd.Columns(i)
Next i
End If
End Sub
Private Sub Dgr_Khmyd_Click()
view_data
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = PublicStr
Call Dgr_Title '調(diào)用過程
tlbState Toolbar1, False
Call view_data '調(diào)用過程
'設(shè)置控件狀態(tài)
For i = 0 To Text1.UBound
Text1(i).Enabled = False
Next i
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sql = ""
End Sub
Sub Dgr_Title() '設(shè)置DataGrid控件的標(biāo)題信息
Dgr_Khmyd.Columns(0).Caption = "客戶滿意度編號(hào)"
Dgr_Khmyd.Columns(1).Caption = "客戶滿意度名稱"
Dgr_Khmyd.Columns(2).Caption = "備注信息"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Frm_Main.Enabled = True
End Sub
Private Sub Text1_GotFocus(Index As Integer)
'Text1控件數(shù)組獲得焦點(diǎn)
Text1(Index).BackColor = &HFFFF80
Text1(Index).SelStart = 0
Text1(Index).SelLength = Len(Text1(Index))
End Sub
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
'Text1控件數(shù)據(jù)按回車鍵
If KeyCode = vbKeyReturn And Index < 2 Then
If Index = 2 Then Exit Sub
Text1(Index + 1).SetFocus
End If
End Sub
Private Sub Text1_LostFocus(Index As Integer)
'Text1控件數(shù)據(jù)失去焦點(diǎn)
Text1(Index).BackColor = &HFFFFFF
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.key
Case "add" '添加
blnAdd = True
tlbState Toolbar1, True
rs1.Open "select * from tb_Client_khmyd order by khmyd_id", cnn, adOpenStatic
If rs1.RecordCount > 0 Then
rs1.MoveLast
Text1(0) = "KMYD" + Format(Val(Right(Trim(rs1.Fields("khmyd_id")), 3)) + 1, "###000") '編號(hào)自動(dòng)加1
Else
Text1(0) = "KMYD001"
End If
rs1.Close
For i = 1 To Text1.UBound
Text1(i) = ""
Text1(i).Locked = False
Next i
Text1(1).Enabled = True
Text1(2).Enabled = True
Text1(1).SetFocus
Case "modify" '修改
If Adodc1.Recordset.RecordCount > 0 Then
blnAdd = False
tlbState Toolbar1, True
For i = 1 To Text1.UBound
Text1(i).Locked = False
Next i
view_data
mybookmark = Dgr_Khmyd.Bookmark
Text1(1).Enabled = True
Text1(2).Enabled = True
Else
MsgBox "系統(tǒng)沒有要修改的數(shù)據(jù)!", , "提示窗口"
End If
Case "delete" '刪除
If Adodc1.Recordset.RecordCount > 0 Then
Dim rs2 As New ADODB.Recordset
rs2.Open "select * from tb_Client_khts where khts_khmyd ='" + Adodc1.Recordset.Fields("khmyd_myd") + "' ", cnn, adOpenKeyset
If rs2.RecordCount > 0 Then
MsgBox "該信息正在使用,不能刪除!", , "信息提示"
Exit Sub
Else
Dim rs3 As New ADODB.Recordset
rs3.Open "select * from tb_Client_khfk where khfk_khmyd='" + Adodc1.Recordset.Fields("khmyd_myd") + "'", cnn, adOpenKeyset
If rs3.RecordCount > 0 Then
MsgBox "該信息正在使用,不能刪除!", , "信息提示"
Exit Sub
Else
Adodc1.Recordset.Delete
Adodc1.Refresh
For i = 0 To Text1.UBound
Text1(i).Text = ""
Next i
Call view_data
Call Dgr_Title
End If
End If
Else
MsgBox "系統(tǒng)沒有要?jiǎng)h除的數(shù)據(jù)!", , "提示窗口"
End If
Case "save" '保存
On Error GoTo SaveErr
If Text1(0).Text = "" Then
MsgBox "系統(tǒng)不允許" & Label1 & "為空!", , "提示窗口"
Exit Sub
End If
If blnAdd = True Then '添加新記錄
cnn.Execute ("insert into tb_Client_khmyd(khmyd_id,khmyd_myd,khmyd_bz) values('" + Text1(0) + _
"','" + Text1(1) + "','" + Text1(2) + "')")
'' Adodc1.Refresh
' Unload Me
' Frm_Jcxxwh_Khmyd.Show
Adodc1.Refresh
Set Dgr_Khmyd.DataSource = Adodc1
Call Dgr_Title
tlbState Toolbar1, False
For i = 1 To Text1.UBound
Text1(i).Locked = True
Next i
Else '修改原有記錄
cnn.Execute ("update tb_Client_khmyd set khmyd_myd ='" + Text1(1) + "',khmyd_bz ='" + Text1(2) + "'where khmyd_id='" + Text1(0).Text + "'")
''' Adodc1.Refresh
'' Unload Me
'' Frm_Jcxxwh_Khmyd.Show
Adodc1.Refresh
Set Dgr_Khmyd.DataSource = Adodc1
Call Dgr_Title
Dgr_Khmyd.Bookmark = mybookmark
tlbState Toolbar1, False
For i = 1 To Text1.UBound
Text1(i).Locked = True
Next i
End If
Exit Sub
SaveErr: '出錯(cuò)處理
MsgBox Err.Description, , "信息提示"
Case "cancel" ' 取消
tlbState Toolbar1, False
For i = 1 To Text1.UBound
Text1(i).Locked = True
Next i
Call view_data
Case "find" ' 查詢
Mystr = InputBox("請(qǐng)輸入要查詢的客戶滿意度編號(hào)", "客戶滿意度查詢", "KMYD001")
rs1.Open "select * from tb_Client_khmyd where khmyd_id ='" + Mystr + "'", cnn, adOpenKeyset
If rs1.RecordCount > 0 Then
For i = 0 To rs1.Fields.Count - 1
If rs1.Fields(i) <> "" Then
Text1(i).Text = rs1.Fields(i)
Else
Text1(i).Text = ""
End If
Next i
End If
rs1.Close
Case "close" '關(guān)閉
Unload Me
End Select
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -