📄 frmpeople.frm
字号:
Text9.SetFocus
ret.Close
cnn.Close
Else
If Text10.Text = "" Then
MsgBox "请输入与户主关系", , "警告"
Text10.SetFocus
Else
If Text10.Text = "户主" Then
MsgBox "户主已存在,请重新输入", , "警告" '禁止添加重复户主
Text10.Text = ""
Text10.SetFocus
Else
If Text1.Text = "" Then
MsgBox "请输入身份证号", , "警告"
Text1.SetFocus
Else '检查身份证号是否重复
tidcard = Trim(Text1.Text)
Set cnn = New ADODB.Connection
Set ret = New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\data\db.mdb" + ";Persist Security Info=False;"
local_db = "select 身份证号 from 人口表" + _
" where 人口表.身份证号=" + "'" + tidcard + "'"
ret.Open local_db, cnn
If Not (ret.BOF And ret.EOF) Then
MsgBox "此身份证号已存在,不能重复添加", , "警告"
Text1.Text = ""
Text1.SetFocus
ret.Close
cnn.Close
Else
If Option1.Value = False And Option2.Value = False Then
MsgBox "请选择性别", , "警告"
Else
If Text2.Text = "" Then
MsgBox "请输入民族", , "警告"
Text2.SetFocus
Else
If Text3.Text = "" Then
MsgBox "请输入籍贯", , "警告"
Text3.SetFocus
Else
If Combo2.Text = "" Or Combo3.Text = "" Or Combo4.Text = "" _
Or Combo4.Text = "-" Then
MsgBox "请选择出生日期", , "警告"
Else
If Text4.Text = "" Then
MsgBox "请输入出生地", , "警告"
Text4.SetFocus
Else
If Combo1.Text = "" Then
MsgBox "请选择文化程度", , "警告"
Else
If Option4.Value = False And Option3.Value = False Then
MsgBox "请选择婚姻状况", , "警告"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
'添加新人口
If Text9.Text <> "" And Text10.Text <> "" And Text1.Text <> "" And (Option1.Value = True Or Option2.Value = True) _
And Text2.Text <> "" And Text3.Text <> "" And (Combo2.Text <> "" Or Combo3.Text <> "" Or Combo4.Text <> "" _
Or Combo4.Text <> "-") And Text4.Text <> "" And Combo1.Text <> "" And (Option4.Value = True Or Option3.Value = True) Then
'声明变量
Dim p_xingming As String
Dim p_idcard As String
Dim p_guanxi As String
Dim p_xingbie As String
Dim p_chushengdi As String
Dim p_mingzu As String
Dim p_jiguan As String
Dim p_chushengriqi As String
Dim p_wenhua As String
Dim p_hunyin As String
Dim p_work As String
Dim p_zhiye As String
Dim p_huhao As String
Dim p_qrriqi As String
Dim p_qrdidian As String
'为各项赋值
p_xingming = Trim(Text9.Text)
p_idcard = Trim(Text1.Text)
p_guanxi = Trim(Text10.Text)
If Option1.Value = True Then
p_xingbie = Option1.Caption
End If
If Option2.Value = True Then
p_xingbie = Option2.Caption
End If
p_chushengdi = Trim(Text4.Text)
p_mingzu = Trim(Text2.Text)
p_jiguan = Trim(Text3.Text)
p_chushengriqi = Combo2.Text & Combo3.Text & Combo4.Text
p_wenhua = Combo1.Text
If Option3.Value = True Then
p_hunyin = Option3.Caption
End If
If Option4.Value = True Then
p_hunyin = Option4.Caption
End If
p_work = Trim(Text6.Text)
p_zhiye = Trim(Text5.Text)
p_huhao = Label2.Caption & Label3.Caption & Label4.Caption
If Text7.Text = "" Then
Label23.Enabled = False
p_qrriqi = ""
Else
Label23.Enabled = True
p_qrriqi = Label23.Caption
End If
p_qrdidian = Trim(Text7.Text)
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\data\db.mdb" + ";Persist Security Info=False;" '连接数据库
local_db = "insert into 人口表(姓名,身份证号,与户主关系,性别,出生地,民族,籍贯,出生日期,文化程度,婚姻状况,工作单位,职业,户号,迁入日期,何地迁入)" + _
" values(" + "'" + p_xingming + "'," + "'" + p_idcard + "'," + "'" + p_guanxi + "'," + "'" + p_xingbie + "'," + "'" + p_chushengdi + "'," + "'" + p_mingzu + "'," + _
"'" + p_jiguan + "'," + "'" + p_chushengriqi + "'," + "'" + p_wenhua + "'," + "'" + p_hunyin + "'," + "'" + p_work + "'," + "'" + p_zhiye + "'," + _
"'" + p_huhao + "'," + "'" + p_qrriqi + "'," + "'" + p_qrdidian + "')"
cnn.Execute local_db '将数据送入数据库
If flag = 3 Then
MsgBox "您已经成功添加了一个新人口", , "提示"
Unload frmpeople
'初始化主窗口
mainfrm.guanli.Enabled = True
mainfrm.chaxun.Enabled = True
mainfrm.tongji.Enabled = True
If userid = "admin" Then
mainfrm.xitong.Enabled = True
mainfrm.bdb.Enabled = True
Else
mainfrm.xitong.Enabled = False
mainfrm.bdb.Enabled = False
End If
mainfrm.Command1.Enabled = True
mainfrm.Command2.Enabled = True
mainfrm.Command3.Enabled = True
If userid = "admin" Then
mainfrm.Command4.Enabled = True
Else
mainfrm.Command4.Enabled = False
End If
flag = 0
Else
MsgBox "您已经成功添加了一个新人口" + Chr(13) + "您可以继续在此户籍中添加人口" + Chr(13) + "也可以点击退出按钮完成创建", , "提示"
'初始化窗口
Unload frmpeople
frmpeople.Show
Label2.Caption = tyhuhao1
Label4.Caption = tyhuhao2
Text9.Locked = False
Text10.Locked = False
Command4.Enabled = False
Command6.Enabled = True
Command1.Enabled = False
Text9.Text = ""
Text10.Text = ""
Label6.Visible = True
Label8.Visible = True
Command3.Visible = False '重叠放置两个重置按钮,通过变换属性用于不同页面
Command3.Enabled = False
Command7.Visible = True
Command7.Enabled = True
End If
End If
End Sub
Private Sub Command7_Click() '重置
'初始化窗口
Unload frmpeople
frmpeople.Show
frmpeople.Caption = "人口登记表(添加人口)"
Label2.Caption = tyhuhao1
Label4.Caption = tyhuhao2
Text9.Locked = False
Text10.Locked = False
Command4.Enabled = False
Command6.Enabled = True
Command1.Enabled = False
Text9.Text = ""
Text10.Text = ""
Label6.Visible = True
Label8.Visible = True
Command3.Visible = False '重叠放置两个重置按钮,通过变换属性用于不同页面
Command3.Enabled = False
Command7.Visible = True
Command7.Enabled = True
End Sub
Private Sub Command8_Click()
Unload frmpeople
flag = 2
frmpeople.Show
End Sub
Private Sub Command9_Click()
'声明变量
Dim thuhao As String
Dim tidcard As String
Dim tname As String
Dim cnn As New ADODB.Connection
Dim ret As New ADODB.Recordset
Dim local_db As String
thuhao = Label2.Caption & Label3.Caption & Label4.Caption
'检查各项是否为空
If Text9.Text = "" Then
MsgBox "请输入姓名", , "警告"
Text9.SetFocus
Else '检查在同一户籍中是否存在同名人员
tname = Trim(Text9.Text)
Set cnn = New ADODB.Connection
Set ret = New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\data\db.mdb" + ";Persist Security Info=False;"
local_db = "select 姓名 from 人口表" + _
" where 人口表.户号=" + "'" + thuhao + "'" + " and 人口表.姓名=" + "'" + tname + "'"
ret.Open local_db, cnn
If Not (ret.BOF And ret.EOF) Then
MsgBox "此户中已有此人,不能重复添加", , "警告"
Text9.Text = ""
Text9.SetFocus
ret.Close
cnn.Close
Else
If Text10.Text = "" Then
MsgBox "请输入与户主关系", , "警告"
Text10.SetFocus
Else
If Text10.Text = "户主" Then
MsgBox "户主已存在,请重新输入", , "警告" '禁止添加重复户主
Text10.Text = ""
Text10.SetFocus
Else
If Text1.Text = "" Then
MsgBox "请输入身份证号", , "警告"
Text1.SetFocus
Else '检查身份证号是否重复
tidcard = Trim(Text1.Text)
Set cnn = New ADODB.Connection
Set ret = New ADODB.Recordset
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\data\db.mdb" + ";Persist Security Info=False;"
local_db = "select 身份证号 from 人口表" + _
" where 人口表.身份证号=" + "'" + tidcard + "'"
ret.Open local_db, cnn
If Not (ret.BOF And ret.EOF) Then
MsgBox "此身份证号已存在,不能重复添加", , "警告"
Text1.Text = ""
Text1.SetFocus
ret.Close
cnn.Close
Else
If Option1.Value = False And Option2.Value = False Then
MsgBox "请选择性别", , "警告"
Else
If Text2.Text = "" Then
MsgBox "请输入民族", , "警告"
Text2.SetFocus
Else
If Text3.Text = "" Then
MsgBox "请输入籍贯", , "警告"
Text3.SetFocus
Else
If Combo2.Text = "" Or Combo3.Text = "" Or Combo4.Text = "" _
Or Combo4.Text = "-" Then
MsgBox "请选择出生日期", , "警告"
Else
If Text4.Text = "" Then
MsgBox "请输入出生地", , "警告"
Text4.SetFocus
Else
If Combo1.Text = "" Then
MsgBox "请选择文化程度", , "警告"
Else
If Option4.Value = False And Option3.Value = False Then
MsgBox "请选择婚姻状况", , "警告"
Else
If Text7.Text = "" Then
MsgBox "请输入自何地迁入", , "警告"
Text7.SetFocus
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
'添加新人口
If Text9.Text <> "" And Text10.Text <> "" And Text1.Text <> "" And (Option1.Value = True Or Option2.Value = True) _
And Text2.Text <> "" And Text3.Text <> "" And (Combo2.Text <> "" Or Combo3.Text <> "" Or Combo4.Text <> "" _
Or Combo4.Text <> "-") And Text4.Text <> "" And Combo1.Text <> "" And (Option4.Value = True Or Option3.Value = True) And Text7.Text <> "" Then
'声明变量
Dim p_xingming As String
Dim p_idcard As String
Dim p_guanxi As String
Dim p_xingbie As String
Dim p_chushengdi As String
Dim p_mingzu As String
Dim p_jiguan As String
Dim p_chushengriqi As String
Dim p_wenhua As String
Dim p_hunyin As String
Dim p_work As String
Dim p_zhiye As String
Dim p_huhao As String
Dim p_qrriqi As String
Dim p_qrdidian As String
'为各项赋值
p_xingming = Trim(Text9.Text)
p_idcard = Trim(Text1.Text)
p_guanxi = Trim(Text10.Text)
If Option1.Value = True Then
p_xingbie = Option1.Caption
End If
If Option2.Value = True Then
p_xingbie = Option2.Caption
End If
p_chushengdi = Trim(Text4.Text)
p_mingzu = Trim(Text2.Text)
p_jiguan = Trim(Text3.Text)
p_chushengriqi = Combo2.Text & Combo3.Text & Combo4.Text
p_wenhua = Combo1.Text
If Option3.Value = True Then
p_hunyin = Option3.Caption
End If
If Option4.Value = True Then
p_hunyin = Option4.Caption
End If
p_work = Trim(Text6.Text)
p_zhiye = Trim(Text5.Text)
p_huhao = Label2.Caption & Label3.Caption & Label4.Caption
p_qrriqi = Label23.Caption
p_qrdidian = Trim(Text7.Text)
Set cnn = New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path & "\data\db.mdb" + ";Persist Security Info=False;" '连接数据库
local_db = "insert into 人口表(姓名,身份证号,与户主关系,性别,出生地,民族,籍贯,出生日期,文化程度,婚姻状况,工作单位,职业,户号,迁入日期,何地迁入)" + _
" values(" + "'" + p_xingming + "'," + "'" + p_idcard + "'," + "'" + p_guanxi + "'," + "'" + p_xingbie + "'," + "'" + p_chushengdi + "'," + "'" + p_mingzu + "'," + _
"'" + p_jiguan + "'," + "'" + p_chushengriqi + "'," + "'" + p_wenhua + "'," + "'" + p_hunyin + "'," + "'" + p_work + "'," + "'" + p_zhiye + "'," + _
"'" + p_huhao + "'," + "'" + p_qrriqi + "'," + "'" + p_qrdidian + "')"
cnn.Execute local_db '将数据送入数据库
MsgBox "您已经成功迁入了一个新人口", , "提示"
'初始化窗口
Unload frmpeople
'初始化主窗口
mainfrm.guanli.Enabled = True
mainfrm.chaxun.Enabled = True
mainfrm.tongji.Enabled = True
If userid = "admin" Then
mainfrm.xitong.Enabled = True
mainfrm.bdb.Enabled = True
Else
mainfrm.xitong.Enabled = False
mainfrm.bdb.Enabled = False
End If
mainfrm.Command1.Enabled = True
mainfrm.Command2.Enabled = True
mainfrm.Command3.Enabled = True
If userid = "admin" Then
mainfrm.Command4.Enabled = True
Else
mainfrm.Command4.Enabled = False
End If
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
Select Case flag
Case 1
Label2.Caption = temphuhao1
Label4.Caption = temphuhao2
frmpeople.Caption = "人口登记表(添加人口)"
Text9.Locked = False
Text10.Locked = False
Command4.Enabled = False
Command6.Enabled = True
Command1.Enabled = False
Text9.Text = ""
Text10.Text = ""
Label6.Visible = True
Label8.Visible = True
Command3.Visible = False '重叠放置两个重置按钮,通过变换属性用于不同页面
Command3.Enabled = False
Command7.Visible = False
Command7.Enabled = False
Command8.Visible = False
Command8.Enabled = False
Command10.Visible = True
Command10.Enabled = True
Frame4.Enabled = False
Label24.Enabled = False
Label23.Enabled = False
Label22.Enabled = False
Text7.Enabled = False
flag = 3
Case 2
Label2.Caption = temphuhao1
Label4.Caption = temphuhao2
Text9.Text = ""
Text10.Text = ""
Text9.Locked = False
Text10.Locked = False
frmpeople.Caption = "人口登记表(迁入人口)"
Command4.Enabled = False
Command1.Enabled = False
Label6.Visible = True
Label8.Visible = True
Command3.Visible = False '重叠放置两个重置按钮,通过变换属性用于不同页面
Command3.Enabled = False
Command7.Visible = False
Command7.Enabled = False
Command8.Visible = True
Command8.Enabled = True
Label37.Visible = True
Frame4.Caption = "迁入信息"
Command6.Enabled = False
Command6.Visible = False
Command9.Enabled = True
Command9.Visible = True
flag = 0
End Select
Label23.Caption = Date
For i = 0 To 150 '自动生成年份
Combo2.List(i) = i + 1900
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -