📄 vb6a.tmp
字号:
Private Sub cmdtable_Click()
frmTableZh.Show
End Sub
Private Sub DataGrid4_Click()
End Sub
Private Sub Form_Load()
Dim X0 As Long
Dim Y0 As Long
'让窗体居中
X0 = Screen.Width
Y0 = Screen.Height
X0 = (X0 - Me.Width) / 2
Y0 = (Y0 - Me.Height) / 2
Me.Move X0, Y0
frmB1.Width = 12960
frmB1.Height = 7110
cmdsave.Enabled = False
cmdcancel.Enabled = False
'设置显示记录条数的Text2不可写
Text16.Enabled = False
Combo1.ListIndex = 0
'设置网格不可写
DataGrid1.AllowAddNew = False
DataGrid1.AllowDelete = False
DataGrid1.AllowUpdate = False
Select Case SSTab1.Tab
Case 0
'如果不是查询显示,则显示第一条记录
If query = False Then
'在from_laod()方法中打开住户信息表
'如果rs_count rs_client 当前状态是打开的,则先关闭之
If rs_count.State = adStateOpen Then
rs_count.Close
End If
If rs_client.State = adStateOpen Then
rs_client.Close
End If
'计算总共数据条数
Dim sqlcount As String
Dim MsgText As String
sqlcount = "select count(*) from zh"
Set rs_count = ExecuteSQL(sqlcount, MsgText)
If rs_count.EOF Then
Text16.Text = 0
Else
Text16.Text = rs_count.Fields(0)
End If
Dim sql_client As String
sql_client = "select * from zh"
rs_client.CursorLocation = adUseClient '?????????????
Set rs_client = ExecuteSQL(sql_client, MsgText)
'如果当前client表中有数据则显示第一条数据
If Not rs_client.EOF And Not rs_client.BOF Then
For i = 0 To 12
Text1(i).Text = rs_client.Fields(i)
Next i
If rs_client.Fields(13) = "男" Then
Combo1.ListIndex = 0
Else
Combo1.ListIndex = 1
End If
End If
'如果是查询显示则相应sql语句为查询语句
ElseIf query = True Then
If rs_client.State = adStateOpen Then
rs_client.Close
End If
If rs_count.State = adStateOpen Then
rs_count.Close
End If
'计算找到的条数
Dim sqlquerycount As String
'Dim MsgText As String
sqlquerycount = "select count(*) from zh " & sqlqc
Set rs_count = ExecuteSQL(sqlquerycount, MsgText)
If rs_count.EOF Then
Text16.Text = 0
Else
Text16.Text = rs_count.Fields(0)
End If
Dim sqlquery As String
'Dim MsgText As String
sqlquery = "select * from zh " & sqlqc
rs_client.CursorLocation = adUseClient
Set rs_client = ExecuteSQL(txtSQL, MsgText)
'没有找到符合条件的记录
If rs_client.EOF Then
MsgBox "没有找到符合条件的记录", vbOKOnly + vbInformation, "注意"
For i = 0 To 12
Text1(i).Text = ""
Next i
cmdedit.Enabled = False
cmddel.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdf.Enabled = False
cmdp.Enabled = False
cmdn.Enabled = False
cmdl.Enabled = False
cmdtable.Enabled = False
'找到符合条件的记录
Else
cmdedit.Enabled = True
cmddel.Enabled = True
cmdsave.Enabled = True
cmdcancel.Enabled = True
cmdf.Enabled = True
cmdp.Enabled = True
cmdn.Enabled = True
cmdl.Enabled = True
cmdtable.Enabled = True
For i = 0 To 12
Text1(i).Text = rs_client.Fields(i)
Next i
If rs_client.Fields(13) = "男" Then
Combo1.ListIndex = 0
Else
Combo1.ListIndex = 1
End If
End If
End If
'设置各个text框不可写
For i = 0 To 12
Text1(i).Enabled = False
Next i
'先设置ComboBox的默认值及不可改
Combo1.Enabled = False
Case 1
'需要设置除关闭按钮外的所有按钮不可用
cmdadd.Enabled = False
cmdedit.Enabled = False
cmddel.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdf.Enabled = False
cmdp.Enabled = False
cmdn.Enabled = False
cmdl.Enabled = False
cmdq.Enabled = False
cmdtable.Enabled = False
'设置显示记录条数的Frame为不可见
Frame4.Visible = False
Dim sqlwy As String
'Dim MsgText As String
sqlwy = "select * from wysf where 住户姓名 = '" & Text1(1).Text & " ' order by 年份,月份"
rs_wuye.CursorLocation = adUseClient
Set rs_wuye = ExecuteSQL(sqlwy, MsgText)
Set DataGrid1.DataSource = rs_wuye
DataGrid1.Refresh
Case 2
'需要设置除关闭按钮外的所有按钮不可用
cmdadd.Enabled = False
cmdedit.Enabled = False
cmddel.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdf.Enabled = False
cmdp.Enabled = False
cmdn.Enabled = False
cmdl.Enabled = False
cmdq.Enabled = False
cmdtable.Enabled = False
'设置显示记录条数的Frame为不可见
Frame4.Visible = False
Dim sqlw As String
Dim sqlp As String
Dim sqlg As String
'Dim MsgText As String
'显示水表数据
sqlw = "select 年份,月份,本月用量,本月费用,本月数据,本月抄表日期,本月交费日期" & _
" from sbzl where 住户姓名 = '" & Text1(1).Text & "'"
rs_water.CursorLocation = adUseClient
Set rs_water = ExecuteSQL(sqlw, MsgText)
Set DataGrid2.DataSource = rs_water
DataGrid2.Refresh
'显示电表数据
sqlp = "select 年份,月份,本月用量,本月费用,本月数据,本月抄表日期,本月交费日期" & _
" from dbzl where 住户姓名 = '" & Text1(1).Text & "'"
rs_power.CursorLocation = adUseClient
Set rs_power = ExecuteSQL(sqlp, MsgText)
Set DataGrid3.DataSource = rs_power
DataGrid3.Refresh
'显示气表数据
sqlg = "select 年份,月份,本月用量,本月费用,本月数据,本月抄表日期,本月交费日期" & _
" from qbzl where 住户姓名 = '" & Text1(1).Text & "'"
rs_gas.CursorLocation = adUseClient
Set rs_gas = ExecuteSQL(sqlg, MsgText)
Set DataGrid4.DataSource = rs_gas
DataGrid4.Refresh
End Select
End Sub
Private Sub Form_Unload(Cancel As Integer)
rs_client.Close
rs_count.Close
If rs_wuye.State = adStateOpen Then
rs_wuye.Close
End If
If rs_water.State = adStateOpen Then
rs_water.Close
End If
If rs_power.State = adStateOpen Then
rs_power.Close
End If
If rs_gas.State = adStateOpen Then
rs_gas.Close
End If
'关闭窗口时还需设置query为false,
query = False
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
Select Case SSTab1.Tab
Case 0
'需要设置所有按钮可用
cmdadd.Enabled = True
cmdedit.Enabled = True
cmddel.Enabled = True
cmdsave.Enabled = True
cmdcancel.Enabled = True
cmdf.Enabled = True
cmdp.Enabled = True
cmdn.Enabled = True
cmdl.Enabled = True
cmdq.Enabled = True
cmdtable.Enabled = True
'打开显示总记录条数的显示
Frame4.Visible = True
'如果不是查询显示,则显示第一条记录
If query = False Then
'在from_laod()方法中打开住户信息表
'如果rs_count rs_client 当前状态是打开的,则先关闭之
If rs_count.State = adStateOpen Then
rs_count.Close
End If
If rs_client.State = adStateOpen Then
rs_client.Close
End If
'计算总共数据条数
Dim sqlcount As String
Dim MsgText As String
sqlcount = "select count(*) from zh"
Set rs_count = ExecuteSQL(sqlcount, MsgText)
If rs_count.EOF Then
Text16.Text = 0
Else
Text16.Text = rs_count.Fields(0)
End If
Dim sql_client As String
sql_client = "select * from zh"
rs_client.CursorLocation = adUseClient
Set rs_client = ExecuteSQL(sql_client, MsgText)
'如果当前client表中有数据则显示第一条数据
If Not rs_client.EOF And Not rs_client.BOF Then
For i = 0 To 12
Text1(i).Text = rs_client.Fields(i)
Next i
If rs_client.Fields(13) = "男" Then
Combo1.ListIndex = 0
Else
Combo1.ListIndex = 1
End If
End If
'如果是查询显示则相应sql语句为查询语句
ElseIf query = True Then
If rs_client.State = adStateOpen Then
rs_client.Close
End If
If rs_count.State = adStateOpen Then
rs_count.Close
End If
'计算找到的条数
Dim sqlquerycount As String
sqlquerycount = "select count(*) from Client " & sqlqc
Set rs_count = ExecuteSQL(sqlquerycount, MsgText)
If rs_count.EOF Then
Text16.Text = 0
Else
Text16.Text = rs_count.Fields(0)
End If
Dim sqlquery As String
sqlquery = "select * from Client " & sqlqc
rs_client.CursorLocation = adUseClient
Set rs_client = ExecuteSQL(sqlquery, MsgText)
'没有找到符合条件的记录
If rs_client.EOF Then
MsgBox "没有找到符合条件的记录", vbOKOnly + vbInformation, "注意"
For i = 0 To 12
Text1(i).Text = ""
Next i
'如果是0条记录,需要设置前翻后翻的按钮为不可用
cmdedit.Enabled = False
cmddel.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdf.Enabled = False
cmdp.Enabled = False
cmdn.Enabled = False
cmdl.Enabled = False
cmdtable.Enabled = False
'找到符合条件的记录
Else
cmdedit.Enabled = True
cmddel.Enabled = True
cmdsave.Enabled = True
cmdcancel.Enabled = True
cmdf.Enabled = True
cmdp.Enabled = True
cmdn.Enabled = True
cmdl.Enabled = True
cmdtable.Enabled = True
For i = 0 To 12
Text1(i).Text = rs_client.Fields(i)
Next i
If rs_client.Fields(13) = "男" Then
Combo1.ListIndex = 0
Else
Combo1.ListIndex = 1
End If
End If
End If
'设置各个text框不可写
For i = 0 To 12
Text1(i).Enabled = False
Next i
'先设置ComboBox的默认值及不可改
Combo1.Enabled = False
Case 1
'需要设置除关闭按钮外的所有按钮不可用
cmdadd.Enabled = False
cmdedit.Enabled = False
cmddel.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdf.Enabled = False
cmdp.Enabled = False
cmdn.Enabled = False
cmdl.Enabled = False
cmdq.Enabled = False
cmdtable.Enabled = False
'设置显示记录条数的Frame为不可见
Frame4.Visible = False
If rs_wuye.State = adStateOpen Then
rs_wuye.Close
End If
Dim sqlwy As String
sqlwy = "select * from WuYeFee where 住户姓名 = '" & Text1(1).Text & "'order by 年份,月份"
rs_wuye.CursorLocation = adUseClient
Set rs_wuye = ExecuteSQL(sqlwy, MsgText)
Set DataGrid1.DataSource = rs_wuye
DataGrid1.Refresh
Case 2
'需要设置除关闭按钮外的所有按钮不可用
cmdadd.Enabled = False
cmdedit.Enabled = False
cmddel.Enabled = False
cmdsave.Enabled = False
cmdcancel.Enabled = False
cmdf.Enabled = False
cmdp.Enabled = False
cmdn.Enabled = False
cmdl.Enabled = False
cmdq.Enabled = False
cmdtable.Enabled = False
'设置显示记录条数的Frame为不可见
Frame4.Visible = False
Dim sqlw As String
Dim sqlp As String
Dim sqlg As String
'显示水表数据
sqlw = "select 年份,月份,本月用量,本月费用,本月数据,本月抄表日期,本月交费日期" & _
" from Water where 住户姓名 = '" & Text1(1).Text & "'"
If rs_water.State = adStateOpen Then
rs_water.Close
End If
rs_water.CursorLocation = adUseClient
Set rs_water = ExecuteSQL(sqlw, MsgText)
Set DataGrid2.DataSource = rs_water
DataGrid2.Refresh
'显示电表数据
sqlp = "select 年份,月份,本月用量,本月费用,本月数据,本月抄表日期,本月交费日期" & _
" from Power where 住户姓名 = '" & Text1(1).Text & "'"
If rs_power.State = adStateOpen Then
rs_power.Close
End If
rs_power.CursorLocation = adUseClient
Set rs_power = ExecuteSQL(sqlp, MsgText)
Set DataGrid3.DataSource = rs_power
DataGrid3.Refresh
'显示气表数据
sqlg = "select 年份,月份,本月用量,本月费用,本月数据,本月抄表日期,本月交费日期" & _
" from Gas where 住户姓名 = '" & Text1(1).Text & "'"
If rs_gas.State = adStateOpen Then
rs_gas.Close
End If
rs_gas.CursorLocation = adUseClient
Set rs_gas = ExecuteSQL(sqlg, MsgText)
Set DataGrid4.DataSource = rs_gas
DataGrid4.Refresh = sqlg
DataGrid4.Refresh
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -