📄 frm_khfw_khts.frm
字号:
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 705
Left = 0
TabIndex = 0
Top = 0
Width = 5955
_ExtentX = 10504
_ExtentY = 1244
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 = "关闭"
Key = "close"
ImageIndex = 7
EndProperty
EndProperty
BorderStyle = 1
End
End
Attribute VB_Name = "Frm_Khfw_Khts"
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 i As Integer
Dim mybookmar
Dim Mystr As String '定义字符串变量
Dim Myrs As New ADODB.Recordset
Sub view_data()
If Adodc1.Recordset.RecordCount > 0 Then
Text1(0).Text = Dgr_Khts.Columns(0)
Cbx_Khmc.Text = Dgr_Khts.Columns(1)
Text1(1).Text = Dgr_Khts.Columns(2)
Text1(2).Text = Dgr_Khts.Columns(3)
Text1(3).Text = Dgr_Khts.Columns(4)
Dtp_Tsrq.Value = Dgr_Khts.Columns(5)
Text1(4).Text = Dgr_Khts.Columns(6)
Cbx_Myd.Text = Dgr_Khts.Columns(7)
Text1(5).Text = Dgr_Khts.Columns(8)
Text1(6).Text = Dgr_Khts.Columns(9)
End If
End Sub
Private Sub Cbx_Khmc_GotFocus()
Cbx_Khmc.BackColor = &HFFFF80
End Sub
Private Sub Cbx_Khmc_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text1(1).SetFocus
End Sub
Private Sub Cbx_Khmc_LostFocus()
Cbx_Khmc.BackColor = &HFFFFFF
Myrs.Open "select * from tb_khxx where khxx_mc ='" + Cbx_Khmc.Text + "'", cnn, adOpenKeyset
If Myrs.RecordCount <= 0 Then
MsgBox "请在下拉列表中选择相应的信息!", , "信息提示"
Cbx_Khmc.ListIndex = 0
Cbx_Khmc.SetFocus
Myrs.Close
Exit Sub
End If
Myrs.Close
End Sub
Private Sub Cbx_Myd_GotFocus()
Cbx_Myd.BackColor = &HFFFF80
End Sub
Private Sub Cbx_Myd_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text1(4).SetFocus
End Sub
Private Sub Cbx_Myd_LostFocus()
Cbx_Myd.BackColor = &HFFFFFF
Myrs.Open "select * from tb_Client_khmyd where khmyd_myd='" + Cbx_Myd.Text + "'", cnn, adOpenKeyset
If Myrs.RecordCount <= 0 Then
MsgBox "请在下拉列表中选择相应的信息!", , "信息提示"
Cbx_Myd.ListIndex = 0
Cbx_Myd.SetFocus
Myrs.Close
Exit Sub
End If
Myrs.Close
End Sub
Private Sub Dgr_Khts_Click()
view_data
End Sub
Private Sub Dtp_Fkrq_GotFocus()
Dtp_Fkrq.CalendarBackColor = &HFFFF80
End Sub
Private Sub Dtp_Fkrq_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then Text1(2).SetFocus
End Sub
Private Sub Dtp_Fkrq_LostFocus()
Dtp_Fkrq.CalendarBackColor = &HFFFFFF
End Sub
Private Sub Form_Load()
On Error Resume Next
'连接数据库
Adodc1.ConnectionString = PublicStr
Call Dgr_Title '调用本模块中的过程
tlbState Toolbar1, False '调用公共模块中的自定义过程
Dim rs2 As New ADODB.Recordset '定义数据集对象
rs2.Open "select * from tb_khxx ", cnn, adOpenKeyset '建立数据连接
If rs2.RecordCount > 0 Then '如果记录数大于零
For i = 0 To rs2.RecordCount - 1 '从零到记录数减1作循环
Cbx_Khmc.AddItem Trim(rs2.Fields("khxx_mc")) ' 向添加Cbx_Khmc中添加数据向
rs2.MoveNext '数据记录移至下一条
Next i '循环加一
End If
If Cbx_Khmc.ListCount = 0 Then '如果Cbx_Khmc中的数据项为0
Cbx_Khmc.Text = "" '显示空
Else '否则
Cbx_Khmc.ListIndex = 0 '显示第一条记录
End If
rs2.Close '关闭第一条记录
Dim rs3 As New ADODB.Recordset
rs3.Open "select * from tb_Client_khmyd ", cnn, adOpenKeyset
If rs3.RecordCount > 0 Then
For i = 0 To rs3.RecordCount - 1
Cbx_Myd.AddItem Trim(rs3.Fields("khmyd_myd")) '向Cbx_Myd中添加数据项
rs3.MoveNext
Next i
End If
If Cbx_Myd.ListCount = 0 Then
Cbx_Myd.Text = ""
Else
Cbx_Myd.ListIndex = 0
End If
rs3.Close
Call view_data '显示数据信息
'设置控件状态
For i = 0 To Text1.UBound
Text1(i).Enabled = False
Next i
Dtp_Tsrq.Value = Date
Cbx_Khmc.Enabled = False
Cbx_Myd.Enabled = False
Dtp_Tsrq.Enabled = False
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
sql = ""
End Sub
Sub Dgr_Title() '设置DataGrid控件的标题
Dgr_Khts.Columns(0).Caption = "客户投诉编号"
Dgr_Khts.Columns(1).Caption = "企业名称"
Dgr_Khts.Columns(2).Caption = "投诉人"
Dgr_Khts.Columns(3).Caption = "投诉主题"
Dgr_Khts.Columns(4).Caption = "投诉内容"
Dgr_Khts.Columns(5).Caption = "投诉日期"
Dgr_Khts.Columns(6).Caption = "处理办法"
Dgr_Khts.Columns(7).Caption = "客户满意度"
Dgr_Khts.Columns(8).Caption = "投诉受理人"
Dgr_Khts.Columns(9).Caption = "备注信息"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Frm_Main.Enabled = True
End Sub
Private Sub Text1_GotFocus(Index As Integer)
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)
If KeyCode = vbKeyReturn And Index < 6 Then
If Index = 3 Then
Cbx_Myd.SetFocus
Exit Sub
End If
If Index = 6 Then Exit Sub
Text1(Index + 1).SetFocus
End If
End Sub
Private Sub Text1_LostFocus(Index As Integer)
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_khts order by khts_id", cnn, adOpenStatic
If rs1.RecordCount > 0 Then
rs1.MoveLast
Text1(0) = "TS" + Format(Val(Right(Trim(rs1.Fields("khts_id")), 3)) + 1, "###000") '编号自动加1
Else
Text1(0) = "TS001"
End If
rs1.Close
For i = 1 To Text1.UBound
Text1(i) = ""
Text1(i).Locked = False
Next i
For i = 0 To Text1.UBound
Text1(i).Enabled = True
Next i
Cbx_Khmc.Enabled = True
Cbx_Myd.Enabled = True
Dtp_Tsrq.Value = Date
Cbx_Khmc.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_Khts.Bookmark
For i = 0 To Text1.UBound
Text1(i).Enabled = True
Next i
Cbx_Khmc.Enabled = True
Cbx_Myd.Enabled = True
Else
MsgBox "系统没有要修改的数据!", , "提示窗口"
End If
Case "delete"
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.Delete
' Adodc1.Refresh
For i = 0 To Text1.UBound
Text1(i).Text = ""
Next i
Call view_data
Call Dgr_Title
Else
MsgBox "系统没有要删除的数据!", , "提示窗口"
End If
Case "save"
On Error GoTo SaveErr
If Text1(0).Text = "" Then
MsgBox "系统不允许" & Label1 & "为空!", , "提示窗口"
Exit Sub
End If
If blnAdd = True Then
cnn.Execute ("insert into tb_Client_khts(khts_id,khts_qymc,khts_tsr,khts_tszt,khts_tsnr,khts_tsrq,khts_clbf,khts_khmyd,khts_tsslr,khts_bz) values('" + Text1(0) + _
"','" + Cbx_Khmc.Text + "','" + Text1(1).Text + "','" + Text1(2) + "','" + Text1(3) + "','" + str(Dtp_Tsrq.Value) + "','" + Text1(4) + "','" + Cbx_Myd.Text + "','" + Text1(5) + "','" + Text1(6) + "')")
' Adodc1.Refresh
Adodc1.Refresh
Set Dgr_Khts.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_khts set khts_qymc ='" + Cbx_Khmc.Text + "',khts_tsr ='" + Text1(1).Text + "',khts_tszt='" + Text1(2) + "',khts_tsrq='" + str(Dtp_Tsrq.Value) + "',khts_clbf='" + Text1(4) + "',khts_khmyd='" + Cbx_Myd.Text + "',khts_tsslr='" + Text1(5) + "',khts_bz='" + Text1(6) + "' where khts_id='" + Text1(0).Text + "'")
' Adodc1.Refresh
' Dgr_Khts.Bookmark = mybookmark
Adodc1.Refresh
Set Dgr_Khts.DataSource = Adodc1
Call Dgr_Title
tlbState Toolbar1, False
For i = 1 To Text1.UBound
Text1(i).Locked = True
Next i
End If
Unload Me
Frm_Khfw_Khts.Show 1
Exit Sub
SaveErr:
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"
Tb = "tb_Client_khts"
Mystr = InputBox("请输入要查询的客户投诉编号", "客户投诉查询", "TS001")
rs1.Open "select * from tb_Client_khts where khts_id ='" + Mystr + "'", cnn, adOpenKeyset
If rs1.RecordCount > 0 Then
Text1(0).Text = rs1.Fields(0)
Text1(1).Text = rs1.Fields(2)
Cbx_Khmc.Text = rs1.Fields(1)
Dtp_Tsrq.Value = rs1.Fields(5)
Text1(2).Text = rs1.Fields(3)
Text1(3).Text = rs1.Fields(4)
Cbx_Myd.Text = rs1.Fields(7)
Text1(4).Text = rs1.Fields(6)
Text1(5).Text = rs1.Fields(8)
Text1(6).Text = rs1.Fields(9)
End If
rs1.Close
Case "close"
Unload Me
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -