📄 frm_yzinfo.frm
字号:
Caption = "房间编号:"
Height = 180
Left = 6615
TabIndex = 7
Top = 315
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "房间号码:"
Height = 180
Left = 4410
TabIndex = 6
Top = 315
Width = 915
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "大楼名称:"
Height = 180
Left = 2325
TabIndex = 5
Top = 360
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "小区名称:"
Height = 180
Left = 150
TabIndex = 4
Top = 360
Width = 900
End
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 780
Top = 330
Width = 3480
_ExtentX = 6138
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.TextBox Text15
Height = 345
Left = 2880
TabIndex = 52
Text = "Text15"
Top = 8805
Width = 795
End
Begin VB.TextBox Text16
Height = 345
Left = 3930
TabIndex = 54
Text = "Text16"
Top = 8790
Width = 870
End
Begin MSAdodcLib.Adodc Adodc3
Height = 345
Left = 405
Top = 8835
Width = 2220
_ExtentX = 3916
_ExtentY = 609
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 1
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = ""
OLEDBString = ""
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
Caption = "Adodc3"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label22
Caption = "Label22"
DataField = "人口编号"
DataSource = "Adodc2"
Height = 270
Left = 1110
TabIndex = 53
Top = 9660
Width = 1830
End
End
Attribute VB_Name = "Frm_yzinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Option Explicit
Dim KeyCode As String
Private Sub CmdSaveYZ_Click()
If Text6.Text = "" Or Text7.Text = "" Or Text8.Text = "" Or Text9.Text = "" Or Text10.Text = "" Or Text12.Text = "" Or Text13.Text = "" Or Text14.Text = "" Or Combo1 = "" Or Combo3 = "" Or DTPicker1 = "" Or DTPicker2 = "" Or DTPicker3 = "" Or DTPicker4 = "" Then
MsgBox "输入信息不允许为空", , "系统提示"
Exit Sub
End If
If Not IsNumeric(Trim(Text13.Text)) Or Not IsNumeric(Trim(Text14.Text)) Then
'IsNumeric 函数返回 Boolean 值,指出表达式的运算结果是否为数。
'Trim 函数返回 Variant (String),其中包含指定字符串的拷贝,没有前导和尾随空白。
MsgBox "请输入正确的信息", , "系统提示"
Exit Sub
End If
Adodc3.RecordSource = "select * from tab_yzinfo where 业主代号='" & Text4.Text & "'"
Adodc3.Refresh
If Adodc3.Recordset.RecordCount > 0 Then
If Text4.Text = Adodc3.Recordset.Fields("业主代号") Then
MsgBox "已有业主信息!", , "系统提示"
Else
If Text4.Text <> Adodc3.Recordset.Fields("业主代号") Then
Set adors = cn.Execute("insert into tab_rkinfo (人口编号,姓名,性别,出生日期,文化程度,与户主关系,籍贯,国籍,婚姻状况,工作单位,职业,职务,职称,家庭电话,单位电话,手机,家庭住址,小区名称,大楼名称,房间号,身份证号,户口所在地,暂住证号,房间编号,备注) values('" & Text15 & "','" & Text6 & "','" & Combo1 & "','" & DTPicker5 & "','" & Combo9 & "','" & "户主" & "','" & Combo5 & "','" & Combo4 & "','" & Combo8 & "','" & Text12 & "','" & Combo6 & "','" & Text18 & "','" & Combo7 & "','" & Text8 & "','" & Text10 & "','" & Text7 & "','" & Text9 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text19 & "','" & Text17 & "','" & Text20 & "','" & Text4 & "','" & Text21 & "') ")
Set adors = cn.Execute("insert into tab_yzinfo values('" & Text5 & "','" & Text6 & "','" & Combo1 & "','" & Text9 & "','" & Text7 & "','" & Text8 & "','" & Text12 & "','" & Text10 & "','" & "身份证" & "','" & Text19 & "','" & DTPicker1 & "','" & DTPicker2 & "','" & DTPicker3 & "','" & DTPicker4 & "','" & Combo3 & "','" & Text13 & "','" & Text14 & "','" & Text4 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "') ")
MsgBox "数据保存成功!", , "系统提示"
End If
End If
Else
' Set adors = cn.Execute("insert into tab_rkinfo (人口编号,姓名,性别,与户主关系,工作单位,单位电话,手机,小区名称,大楼名称,房间号,身份证号,房间编号) values('" & Text15 & "','" & Text6 & "','" & Combo1 & "','" & "户主" & "','" & Text12 & "','" & Text10 & "','" & Text7 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text11 & "','" & Text4 & "') ")
' Set adors = cn.Execute("insert into tab_yzinfo values('" & Text5 & "','" & Text6 & "','" & Combo1 & "','" & Text9 & "','" & Text7 & "','" & Text8 & "','" & Text12 & "','" & Text10 & "','" & Combo2 & "','" & Text11 & "','" & DTPicker1 & "','" & DTPicker2 & "','" & DTPicker3 & "','" & DTPicker4 & "','" & Combo3 & "','" & Text13 & "','" & Text14 & "','" & Text4 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "') ")
Set adors = cn.Execute("insert into tab_rkinfo (人口编号,姓名,性别,出生日期,文化程度,与户主关系,籍贯,国籍,婚姻状况,工作单位,职业,职务,职称,家庭电话,单位电话,手机,家庭住址,小区名称,大楼名称,房间号,身份证号,户口所在地,暂住证号,房间编号,备注) values('" & Text15 & "','" & Text6 & "','" & Combo1 & "','" & DTPicker5 & "','" & Combo9 & "','" & "户主" & "','" & Combo5 & "','" & Combo4 & "','" & Combo8 & "','" & Text12 & "','" & Combo6 & "','" & Text18 & "','" & Text8 & "','" & Combo7 & "','" & Text10 & "','" & Text7 & "','" & Text9 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "','" & Text19 & "','" & Text17 & "','" & Text20 & "','" & Text4 & "','" & Text21 & "') ")
Set adors = cn.Execute("insert into tab_yzinfo values('" & Text5 & "','" & Text6 & "','" & Combo1 & "','" & Text9 & "','" & Text7 & "','" & Text8 & "','" & Text12 & "','" & Text10 & "','" & "身份证" & "','" & Text19 & "','" & DTPicker1 & "','" & DTPicker2 & "','" & DTPicker3 & "','" & DTPicker4 & "','" & Combo3 & "','" & Text13 & "','" & Text14 & "','" & Text4 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "') ")
End If
' Set adors = cn.Execute("update tab_yzinfo ( '" & Text5 & "','" & Text6 & "','" & Combo1 & "','" & Text9 & "','" & Text7 & "','" & Text8 & "','" & Text12 & "','" & Text10 & "','" & Combo2 & "','" & Text11 & "','" & DTPicker1 & "','" & DTPicker2 & "','" & DTPicker3 & "','" & DTPicker4 & "','" & Combo3 & "','" & Text13 & "','" & Text14 & "','" & Text4 & "','" & Text1 & "','" & Text2 & "','" & Text3 & "')")
Adodc2.Refresh
Set DataGrid1.DataSource = Adodc2
End Sub
Private Sub CmdNewCY_Click()
Frm_jtcyinfo.Show '显示添加成员信息窗体
Frm_jtcyinfo.Command1.Enabled = True '设置添加按钮可用
Frm_jtcyinfo.Command2.Enabled = False '设置保存按钮不可用
Frm_jtcyinfo.Command3.Enabled = False '设置修改按钮不可用
End Sub
Private Sub CmdEditCY_Click() '编辑成员信息
Frm_jtcyinfo.Adodc1.RecordSource = "select * from tab_rkinfo where 人口编号 = '" + Label22.Caption + "' "
Frm_jtcyinfo.Adodc1.Refresh
If Frm_jtcyinfo.Adodc1.Recordset.RecordCount > 0 Then
On Error Resume Next
With Frm_jtcyinfo
.Text1.Text = .Adodc1.Recordset.Fields("姓名")
.Combo1.Text = .Adodc1.Recordset.Fields("性别")
.Combo6.Text = .Adodc1.Recordset.Fields("国籍")
.Combo5.Text = .Adodc1.Recordset.Fields("籍贯")
.Combo2.Text = .Adodc1.Recordset.Fields("职业")
.DTPicker1.Value = Adodc1.Recordset.Fields("出生日期")
.Text15.Text = .Adodc1.Recordset.Fields("职务")
.Combo7.Text = .Adodc1.Recordset.Fields("婚姻状况")
.Combo8.Text = .Adodc1.Recordset.Fields("职称")
.Combo4.Text = .Adodc1.Recordset.Fields("与户主关系")
.Text4.Text = .Adodc1.Recordset.Fields("手机")
.Text10.Text = .Adodc1.Recordset.Fields("单位电话")
.Combo3.Text = .Adodc1.Recordset.Fields("文化程度")
.Text11.Text = .Adodc1.Recordset.Fields("家庭电话")
.Text14.Text = .Adodc1.Recordset.Fields("工作单位")
.Text6.Text = .Adodc1.Recordset.Fields("身份证号")
.Text12.Text = .Adodc1.Recordset.Fields("暂住证号")
.Text7.Text = .Adodc1.Recordset.Fields("户口所在地")
.Text13.Text = .Adodc1.Recordset.Fields("家庭住址")
.Text8.Text = .Adodc1.Recordset.Fields("备注")
.Command1.Enabled = False '设置添加按钮不可用
.Command3.Enabled = True '设置修改按钮可用
.Command2.Enabled = False '设置保存按钮不可用
End With
End If
Frm_jtcyinfo.Show
End Sub
Private Sub CmdDeleteCY_Click()
' If MsgBox("确定删除该信息?", 4, "系统提示") = vbYes Then
If Adodc2.Recordset.RecordCount > 0 Then
a = MsgBox("您确定要删除这条数据吗?", vbYesNo)
If a = vbYes Then
If Adodc2.Recordset.Fields("与户主关系") = "户主" Then
Dim myrs As New ADODB.Recordset
myrs.Open "select * from tab_yzinfo where 业主代号 ='" + Adodc2.Recordset.Fields("房间编号") + "'", cn, adOpenKeyset, adLockOptimistic
If myrs.RecordCount > 0 Then
myrs.Delete
myrs.Update
' Unload Me
End If
myrs.Close
' myrs.Open "select * from tab_fwinfo where 房间编号='" + Adodc2.Recordset.Fields("房间编号") + "'", cn, adOpenKeyset, adLockOptimistic
' If myrs.RecordCount > 0 Then
' myrs.Fields("户主姓名") = ""
' myrs.Fields("用途") = ""
' myrs.Fields("房屋状态") = ""
' myrs.Update
'' Unload Me
' End If
Adodc2.RecordSource = "select * from tab_rkinfo"
Adodc2.Recordset.Delete
Adodc2.Recordset.Update
Adodc2.Refresh
' Unload Me
Else
Adodc2.RecordSource = "select * from tab_rkinfo"
Adodc2.Recordset.Delete
Adodc2.Recordset.Update
Adodc2.Refresh
' Unload Me
End If
Else
MsgBox "没有要删除的数据!", , "系统提示"
End If
End If
Adodc2.Refresh
' Me.Refresh
' Unload Me
' Frm_yzinfo.Show
Set DataGrid1.DataSource = Adodc2
End Sub
Private Sub Command5_Click()
Unload Me
Frm_yzinfodj.Show '显示业主信息登记窗体
End Sub
Private Sub Form_Load()
DTPicker1.Value = Date
DTPicker2.Value = Date
DTPicker3.Value = Date
DTPicker4.Value = Date
'自动识别路径
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_wygl.mdb;Persist Security Info=False"
Adodc1.RecordSource = "select * from tab_yzinfo"
Adodc1.Refresh
Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_wygl.mdb;Persist Security Info=False"
Adodc3.RecordSource = "select * from tab_yzinfo"
Adodc2.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db_wygl.mdb;Persist Security Info=False"
Adodc2.RecordSource = "select * from tab_rkinfo order by 人口编号"
Adodc2.Refresh
If Adodc2.Recordset.RecordCount > 0 Then
If Adodc2.Recordset.EOF = False Then
Adodc2.Recordset.MoveLast
Text15.Text = "rk" + Format(Val(Right(Adodc2.Recordset.Fields("人口编号"), 3)) + 1, "###000")
'Format 函数返回 Variant (String),其中含有一个表达式,它是根据格式表达式中的指令来格式化的。
'Val 函数返回包含于字符串内的数字,字符串中是一个适当类型的数值。
'Right 函数返回 Variant (String),其中包含从字符串右边取出的指定数量的字符。
Else
Text15.Text = "rk" + Format(Val(Right(Adodc2.Recordset.Fields("人口编号"), 3)) + 1, "###000")
End If
Else
Text15.Text = "rk" + "001"
End If
Set DataGrid1.DataSource = Adodc2
End Sub
Private Sub Text10_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text11获得焦点
Text11.SetFocus
End If
End Sub
Private Sub Text11_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text12获得焦点
Text12.SetFocus
End If
End Sub
Private Sub Text12_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text13获得焦点
Text13.SetFocus
End If
End Sub
Private Sub Text13_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text14获得焦点
Text14.SetFocus
End If
End Sub
Private Sub Text6_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text7获得焦点
Text7.SetFocus
End If
End Sub
Private Sub Text7_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text8获得焦点
Text8.SetFocus
End If
End Sub
Private Sub Text8_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text9获得焦点
Text9.SetFocus
End If
End Sub
Private Sub Text9_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then '按回车键Text10获得焦点
Text10.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -