📄 frm_jtcyjinfo.frm
字号:
Left = 4605
TabIndex = 36
Top = 345
Width = 540
End
Begin VB.Label Label19
AutoSize = -1 'True
Caption = "职务:"
Height = 180
Left = 4620
TabIndex = 34
Top = 750
Width = 540
End
Begin VB.Label Label18
AutoSize = -1 'True
Caption = "与户主关系:"
Height = 180
Left = 5520
TabIndex = 32
Top = 1140
Width = 1080
End
Begin VB.Label Label17
AutoSize = -1 'True
Caption = "文化程度:"
Height = 180
Left = 5700
TabIndex = 30
Top = 1530
Width = 900
End
Begin VB.Label Label16
AutoSize = -1 'True
Caption = "工作单位:"
Height = 180
Left = 2580
TabIndex = 28
Top = 1980
Width = 900
End
Begin VB.Label Label15
AutoSize = -1 'True
Caption = "家庭住址:"
Height = 180
Left = 3165
TabIndex = 21
Top = 2835
Width = 900
End
Begin VB.Label Label14
AutoSize = -1 'True
Caption = "暂住证号:"
Height = 180
Left = 3165
TabIndex = 20
Top = 2430
Width = 900
End
Begin VB.Label Label13
AutoSize = -1 'True
Caption = "家庭电话:"
Height = 180
Left = 285
TabIndex = 19
Top = 2010
Width = 900
End
Begin VB.Label Label12
AutoSize = -1 'True
Caption = "单位电话:"
Height = 180
Left = 2595
TabIndex = 18
Top = 1605
Width = 900
End
Begin VB.Label Label11
AutoSize = -1 'True
Caption = "职称:"
Height = 180
Left = 2595
TabIndex = 17
Top = 1185
Width = 540
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "职业:"
Height = 180
Left = 2595
TabIndex = 16
Top = 780
Width = 540
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "性别:"
Height = 180
Left = 2595
TabIndex = 15
Top = 345
Width = 540
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "备 注:"
Height = 180
Left = 270
TabIndex = 8
Top = 3240
Width = 900
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "户口所在地:"
Height = 180
Left = 105
TabIndex = 7
Top = 2805
Width = 1080
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "身份证号:"
Height = 180
Left = 285
TabIndex = 6
Top = 2400
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "电 话:"
Height = 180
Left = 285
TabIndex = 5
Top = 4005
Width = 900
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "手 机:"
Height = 180
Left = 285
TabIndex = 4
Top = 1635
Width = 900
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "婚姻状况:"
Height = 180
Left = 285
TabIndex = 3
Top = 1200
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "出生日期:"
Height = 180
Left = 285
TabIndex = 2
Top = 765
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "姓 名:"
Height = 180
Left = 315
TabIndex = 1
Top = 360
Width = 900
End
End
End
Attribute VB_Name = "Frm_jtcyinfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click() '添加
'清空文本框
Text1 = ""
Text4 = ""
Text6 = ""
Text7 = ""
Text8 = ""
Text10 = ""
Text11 = ""
Text12 = ""
Text13 = ""
Text14 = ""
Text15.Text = ""
Text1.SetFocus
Adodc1.RecordSource = "select * from tab_rkinfo order by 人口编号"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then '如果记录数大于零
If Adodc1.Recordset.EOF = False Then
Adodc1.Recordset.MoveLast
Text2.Text = "rk" + Format(Val(Right(Adodc1.Recordset.Fields("人口编号"), 3)) + 1, "###000")
Else
Text2.Text = "rk" + Format(Val(Right(Adodc1.Recordset.Fields("人口编号"), 3)) + 1, "###000")
'Format 函数返回 Variant (String),其中含有一个表达式,它是根据格式表达式中的指令来格式化的。
'Val 函数返回包含于字符串内的数字,字符串中是一个适当类型的数值。
'Right 函数返回 Variant (String),其中包含从字符串右边取出的指定数量的字符。
End If
Else
Text2.Text = "rk" + "001"
End If
Command2.Enabled = True '保存按钮可用
Command1.Enabled = False '添加按钮不可用
Command3.Enabled = False
End Sub
Private Sub Command2_Click() '保存
If Text1 = "" Or Text4 = "" Or Text6 = "" Or Text7 = "" Or Text8 = "" Or Text10 = "" Or Text11 = "" Or Text12 = "" Or Text13 = "" Or Text14 = "" Or Text15.Text = "" Or Combo1 = "" Or Combo2 = "" Or Combo5 = "" Or Combo6 = "" Or Combo7 = "" Or Combo8 = "" Or DTPicker1.Value = "" Then
MsgBox "输入信息不允许为空!", , "系统提示"
Exit Sub
' End If
Adodc1.RecordSource = "select * from tab_rkinfo where 人口编号='" + Text2.Text + "'"
' If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.Fields("姓名") = 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.Update
Adodc1.Refresh
MsgBox "数据保存成功!", , "系统提示"
Unload Me
Else
Set adors = cn.Execute("insert into tab_rkinfo values('" & Text2 & "','" & Text1 & "','" & Combo1 & "','" & DTPicker1 & "','" & Combo3 & "','" & Combo4 & "','" & Combo5 & "','" & Combo6 & "','" & Combo7 & "','" & Text14 & "','" & Combo2 & "','" & Text15 & "','" & Combo8 & "','" & Text11 & "','" & Text10 & "','" & Text4 & "','" & Text13 & "','" & Frm_yzinfo.Text1 & "','" & Frm_yzinfo.Text2 & "','" & Frm_yzinfo.Text3 & "','" & Text6 & "','" & Text7 & "','" & Text12 & "','" & Frm_yzinfo.Text4 & "','" & Text8 & "') ")
' Set adors = cn.Execute("update tab_rkinfo set(人口编号='" & Text2 & "',姓名='" & Text1 & "',姓别='" & Combo1 & "',出生日期='" & DTPicker1 & "',文化程序='" & Combo3 & "',与户主关系='" & Combo4 & "',籍贯='" & Combo5 & "',国籍='" & Combo6 & "',婚姻状况='" & Combo7 & "',工作单位='" & Text14 & "',职业='" & Combo2 & "',职务='" & Text15 & "',职称='" & Combo8 & "',家庭电话='" & Text11 & "',单位电话='" & Text10 & "',手机='" & Text4 & "',家庭住址='" & Text13 & "',小区名称='" & Frm_yzinfo.Text1 & "',大楼名称='" & Frm_yzinfo.Text2 & "',房间号='" & Frm_yzinfo.Text3 & "',身份证号='" & Text6 & "',户口所在地='" & Text7 & "',暂住证号='" & Text12 & "',房间编号='" & Frm_yzinfo.Text4 & "',备注='" & Text8 & "') ")
MsgBox "数据保存成功!", , "系统提示"
Adodc1.Refresh
Unload Me
cn.Close
End If
Frm_yzinfo.Adodc2.Refresh
Set Frm_yzinfo.DataGrid1.DataSource = Frm_yzinfo.Adodc2
Unload Me
Frm_yzinfo.Show
End Sub
Private Sub Command3_Click() '修改按钮
Command1.Enabled = False '设置添加按钮不可用
Command2.Enabled = False '设置保存按钮可用
Text1.SetFocus '设置焦点
cn.Execute "update tab_rkinfo set 姓名='" & Text1 & "',性别='" & Combo1 & "',出生日期='" & DTPicker1 & "',文化程度='" & Combo3 & "',与户主关系='" & Combo4 & "',籍贯='" & Combo5 & "',国籍='" & Combo6 & "',婚姻状况='" & Combo7 & "',工作单位='" & Text14 & "',职业='" & Combo2 & "',职务='" & Text15 & "',职称='" & Combo8 & "',家庭电话='" & Text11 & "',单位电话='" & Text10 & "',手机='" & Text4 & "',家庭住址='" & Text13 & "',小区名称='" & Frm_yzinfo.Text1 & "',大楼名称='" & Frm_yzinfo.Text2 & "',房间号='" & Frm_yzinfo.Text3 & "',身份证号='" & Text6 & "',户口所在地='" & Text7 & "',暂住证号='" & Text12 & "',房间编号='" & Frm_yzinfo.Text4 & "',备注='" & Text8 & "'where 人口编号='" & Text2 & "'"
MsgBox "数据修改成功!", , "系统提示"
Adodc1.RecordSource = "select * from tab_rkinfo"
Adodc1.Refresh
Set Frm_yzinfo.DataGrid1.DataSource = Adodc1
Unload Me
End Sub
Private Sub Form_Load()
DTPicker1.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_rkinfo"
Adodc1.Refresh
Command2.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -