📄 frm_yezhu_edit.frm
字号:
VERSION 5.00
Begin VB.Form Frm_yezhu_edit
BorderStyle = 1 'Fixed Single
Caption = "业主修改"
ClientHeight = 3165
ClientLeft = 4185
ClientTop = 2670
ClientWidth = 3390
Icon = "Frm_yezhu_edit.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3165
ScaleWidth = 3390
StartUpPosition = 1 '所有者中心
Begin VB.ComboBox Combo1
Height = 300
Left = 1140
Style = 2 'Dropdown List
TabIndex = 6
Top = 120
Width = 2055
End
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 1920
TabIndex = 5
Top = 2460
Width = 975
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 360
TabIndex = 4
Top = 2460
Width = 1035
End
Begin VB.TextBox Text4
Height = 300
Left = 1140
TabIndex = 3
Top = 1800
Width = 2055
End
Begin VB.TextBox Text3
Height = 300
Left = 1140
TabIndex = 2
Top = 1380
Width = 2055
End
Begin VB.TextBox Text2
Height = 300
Left = 1140
TabIndex = 1
Top = 960
Width = 2055
End
Begin VB.TextBox Text1
Height = 300
Left = 1140
TabIndex = 0
Top = 540
Width = 2055
End
Begin VB.Label Label1
Caption = "房 号"
Height = 315
Left = 180
TabIndex = 11
Top = 180
Width = 495
End
Begin VB.Label Label7
Caption = "电 话"
Height = 255
Left = 180
TabIndex = 10
Top = 1860
Width = 555
End
Begin VB.Label Label6
Caption = "职 业"
Height = 255
Left = 180
TabIndex = 9
Top = 1440
Width = 555
End
Begin VB.Label Label5
Caption = "身份证号"
Height = 195
Left = 180
TabIndex = 8
Top = 1020
Width = 795
End
Begin VB.Label Label4
Caption = "业主姓名"
Height = 255
Left = 180
TabIndex = 7
Top = 600
Width = 735
End
End
Attribute VB_Name = "Frm_yezhu_edit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo myerr
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
Set cn = GetCn
rst.Open "select fh,id from fangchan order by 1", cn, 0, 1
If rst.BOF And rst.EOF Then
MsgBox "请先建立房产信息!", vbExclamation, "提示"
Exit Sub
End If
Combo1.Clear
Do While Not rst.EOF
Combo1.AddItem rst(0)
Combo1.ItemData(Combo1.NewIndex) = rst(1)
rst.MoveNext
Loop
rst.Close
cn.Close
Combo1 = Frm_yezhu.ListView1.SelectedItem.Text
Text1 = Frm_yezhu.ListView1.SelectedItem.SubItems(1)
Text2 = Frm_yezhu.ListView1.SelectedItem.SubItems(2)
Text3 = Frm_yezhu.ListView1.SelectedItem.SubItems(3)
Text4 = Frm_yezhu.ListView1.SelectedItem.SubItems(4)
Exit Sub
myerr:
Select Case Err
Case -2147217904
If rst.State = 1 Then rst.Close
rst.Open "select count(*) from yezhu", cn, 0, 1
If rst(0) = 0 Then
MsgBox "请先建立房产信息!", vbExclamation, "提示"
Exit Sub
Else
MsgBox Error, vbExclamation, "提示"
End If
Case Else
MsgBox Error, vbExclamation, "提示"
End Select
End Sub
Private Sub Command1_Click()
On Error GoTo myerr
Dim cn As ADODB.Connection
Dim rst As New ADODB.Recordset
msg = MsgBox("是否修改?", vbYesNo + vbQuestion, "提示")
If msg = vbNo Then Exit Sub
If Trim(Combo1) = "" Then
MsgBox "房号不能为空!", vbExclamation, "提示"
Text1.SetFocus
Exit Sub
End If
If Trim(Text1) = "" Then
MsgBox "业主姓名不能为空!", vbExclamation, "提示"
Text1.SetFocus
Exit Sub
End If
If Trim(Text2) = "" Then
MsgBox "身份证号不能为空!", vbExclamation, "提示"
Text2.SetFocus
Exit Sub
End If
If Trim(Text3) = "" Then
MsgBox "业主职业不能为空!", vbExclamation, "提示"
Text3.SetFocus
Exit Sub
End If
If Trim(Text4) = "" Then
MsgBox "电话不能为空!", vbExclamation, "提示"
Text4.SetFocus
Exit Sub
End If
If Len(Text1) > 8 Then
MsgBox "业主姓名超长!", vbExclamation, "提示"
Text1.SetFocus
Exit Sub
End If
If Len(Text2) > 18 Then
MsgBox "身份证号超长!", vbExclamation, "提示"
Text2.SetFocus
Exit Sub
End If
If Len(Text3) > 50 Then
MsgBox "职业超长!", vbExclamation, "提示"
Text3.SetFocus
Exit Sub
End If
If Len(Text4) > 20 Then
MsgBox "电话超长!", vbExclamation, "提示"
Text4.SetFocus
Exit Sub
End If
Set cn = GetCn
rst.Open "select * from yezhu where fid=" & Combo1.ItemData(Combo1.ListIndex), cn, 0, 1
If Not (rst.BOF And rst.EOF) And Combo1 <> Frm_yezhu.ListView1.SelectedItem.Text Then
MsgBox "该房号已存在业主!", vbExclamation, "提示"
Combo1.SetFocus '
rst.Close
Exit Sub
End If
rst.Close
cn.Execute "update yezhu set fid='" & Combo1.ItemData(Combo1.ListIndex) & "',xm='" & Text1 & "',sfz='" & Text2 & "',zy='" & Text3 & "',dh='" & Text4 & "' where id=" & Frm_yezhu.ListView1.SelectedItem.SubItems(5)
Frm_yezhu.ListView1.SelectedItem.Text = Combo1
Frm_yezhu.ListView1.SelectedItem.SubItems(1) = Text1
Frm_yezhu.ListView1.SelectedItem.SubItems(2) = Text2
Frm_yezhu.ListView1.SelectedItem.SubItems(3) = Text3
Frm_yezhu.ListView1.SelectedItem.SubItems(4) = Text4
MsgBox "已成功保存!", vbExclamation, "提示"
Unload Me
Exit Sub
myerr:
MsgBox Error, vbExclamation, "提示"
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -