📄 管理区信息.frm
字号:
BorderStyle = 1 'Fixed Single
Caption = " 总楼群数:"
Height = 255
Left = 4680
TabIndex = 6
Top = 840
Width = 1215
End
Begin VB.Label Label5
BorderStyle = 1 'Fixed Single
Caption = " 地理位置:"
Height = 255
Left = 1680
TabIndex = 5
Top = 840
Width = 1215
End
Begin VB.Label Label4
BorderStyle = 1 'Fixed Single
Caption = " 承 建 商:"
Height = 255
Left = 4680
TabIndex = 4
Top = 480
Width = 1215
End
Begin VB.Label Label3
BorderStyle = 1 'Fixed Single
Caption = " 开 发 商:"
Height = 255
Left = 1680
TabIndex = 3
Top = 480
Width = 1215
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
Caption = " 管理区名称:"
Height = 255
Left = 4680
TabIndex = 2
Top = 120
Width = 1215
End
Begin VB.Label Label1
BorderStyle = 1 'Fixed Single
Caption = " 管理区代码:"
Height = 255
Left = 1680
TabIndex = 1
Top = 120
Width = 1215
End
Begin VB.Image Image1
Height = 2985
Left = 0
Picture = "管理区信息.frx":ABC7
Top = 3840
Width = 7530
End
End
Attribute VB_Name = "管理区信息"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim isadding As Boolean
Dim objcn As Connection
Dim objmessage As Recordset
'添加记录
Private Sub Cmdadd_Click()
txtNews = "添加新记录"
Text1.Text = ""
Combo1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
isadding = True
DTP1.Visible = True
DTP2.Visible = True
Text12.Visible = False
Text13.Visible = False
End Sub
'删除记录
Private Sub Cmddelete_Click()
With objmessage
'在当前表中无数据和不添加记录时,不执行删除操作
If Not isadding And .RecordCount < 1 Then Exit Sub
If isadding Then
isadding = False
If objmessage.RecordCount < 1 Then
txtNews = "记录:无"
Text1.Text = ""
Combo1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
Text14.Text = ""
Else
Text1.Text = .Fields("管理区代码")
Combo1.Text = .Fields("管理区名称")
Text2.Text = .Fields("开发商")
Text3.Text = .Fields("承建商")
Text4.Text = .Fields("地理位置")
Text5.Text = .Fields("总楼群数")
Text6.Text = .Fields("总占地面积")
Text7.Text = .Fields("总套房数")
Text8.Text = .Fields("总建筑面积")
Text9.Text = .Fields("总人口")
Text10.Text = .Fields("总使用面积")
Text11.Text = .Fields("车位数")
Text12.Text = .Fields("开发日期")
Text13.Text = .Fields("竣工日期")
Text14.Text = .Fields("备注")
End If
Else
If MsgBox("是否删除当前记录?", vbYesNo + vbQuestion, "温馨提示") = vbYes Then
objmessage.Delete
cmdMove(2).Value = True
Else
Text1.Text = .Fields("管理区代码")
Combo1.Text = .Fields("管理区名称")
Text2.Text = .Fields("开发商")
Text3.Text = .Fields("承建商")
Text4.Text = .Fields("地理位置")
Text5.Text = .Fields("总楼群数")
Text6.Text = .Fields("总占地面积")
Text7.Text = .Fields("总套房数")
Text8.Text = .Fields("总建筑面积")
Text9.Text = .Fields("总人口")
Text10.Text = .Fields("总使用面积")
Text11.Text = .Fields("车位数")
Text12.Text = .Fields("开发日期")
Text13.Text = .Fields("竣工日期")
Text14.Text = .Fields("备注")
End If
End If
End With
End Sub
Private Sub cmdMove_Click(Index As Integer)
With objmessage
Select Case Index '切换当前记录
Case 0 '使第一个记录成为当前记录
If .RecordCount > 0 And Not .BOF Then .MoveFirst
Case 1 '使上一个记录成为当前记录
If .RecordCount > 0 And Not .BOF Then
.MovePrevious
If .BOF Then .MoveFirst
End If
Case 2 '使下一个记录成为当前记录
If .RecordCount > 0 And Not .EOF Then
.MoveNext
If .EOF Then .MoveLast
End If
Case 3 '使最后一个记录成为当前记录
If .RecordCount > 0 And Not .EOF Then .MoveLast
End Select
If .RecordCount < 1 Then
txtNews = "记录:无" '显示无记录提示
Else
'显示当前记录数据
Text1.Text = .Fields("管理区代码")
Combo1.Text = .Fields("管理区名称")
If IsNull(.Fields("开发商")) Then
Text2.Text = ""
Else
Text2.Text = .Fields("开发商")
End If
If IsNull(.Fields("承建商")) Then
Text3.Text = ""
Else
Text3.Text = .Fields("承建商")
End If
If IsNull(.Fields("地理位置")) Then
Text4.Text = ""
Else
Text4.Text = .Fields("地理位置")
End If
If IsNull(.Fields("总楼群数")) Then
Text5.Text = ""
Else
Text5.Text = .Fields("总楼群数")
End If
If IsNull(.Fields("总占地面积")) Then
Text6.Text = ""
Else
Text6.Text = .Fields("总占地面积")
End If
If IsNull(.Fields("总套房数")) Then
Text7.Text = ""
Else
Text7.Text = .Fields("总套房数")
End If
If IsNull(.Fields("总建筑面积")) Then
Text8.Text = ""
Else
Text8.Text = .Fields("总建筑面积")
End If
If IsNull(.Fields("总人口")) Then
Text9.Text = ""
Else
Text9.Text = .Fields("总人口")
End If
If IsNull(.Fields("总使用面积")) Then
Text10.Text = ""
Else
Text10.Text = .Fields("总使用面积")
End If
If IsNull(.Fields("车位数")) Then
Text11.Text = ""
Else
Text11.Text = .Fields("车位数")
End If
If IsNull(.Fields("开发日期")) Then
Text12.Text = ""
Else
Text12.Text = .Fields("开发日期")
End If
If IsNull(.Fields("竣工日期")) Then
Text13.Text = ""
Else
Text13.Text = .Fields("竣工日期")
End If
If IsNull(.Fields("备注")) Then
Text14.Text = ""
Else
Text14.Text = .Fields("备注")
End If
'显示当前记录编号和记录总数
txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
End If
End With
If isadding Then isadding = False
End Sub
Private Sub Cmdsave_Click()
With objmessage
'If Not isadding And .RecordCount < 1 Then Exit Sub
If Text1.Text = "" Then '选择管理区代码
MsgBox "请选译代码", , "温馨提示"
Text1.SetFocus
Text1.Text = ""
Exit Sub
End If
If Combo1.Text = "" Then '选择管理区名称
MsgBox "请输入名称!", vbInformation, "温馨提示"
Combo1.SetFocus
Exit Sub
End If
'If Trim(Text12.Text) = "" Then
' MsgBox "请输入日期", vbInformation, "温馨提示"
'Text12.SetFocus
' Exit Sub
'End If
'If Trim(Text13.Text) = "" Then
' MsgBox "请输入日期", vbInformation, "温馨提示"
' Text13.SetFocus
' Exit Sub
'End If
'检查代码是否重复
Dim objcopy As New Recordset
Set objcopy = objmessage.Clone
If objcopy.RecordCount > 0 Then
objcopy.MoveFirst
objcopy.Find "管理区代码='" & Trim(Text1.Text) & "'"
If (isadding And Not objcopy.EOF) Or (Not isadding And Not objcopy.EOF And objcopy.AbsolutePosition <> objmessage.AbsolutePosition) Then
MsgBox "代码已被使用!", vbCritical, "温馨提示"
Text1.SetFocus
Text1.SelStart = 0
Exit Sub
Else
If isadding Then objmessage.AddNew
.Fields("管理区代码") = Trim(Text1.Text)
.Fields("管理区名称") = Trim(Combo1.Text)
.Fields("开发商") = Trim(Text2.Text)
.Fields("承建商") = Trim(Text3.Text)
.Fields("地理位置") = Trim(Text4.Text)
.Fields("总楼群数") = Trim(Text5.Text)
.Fields("总占地面积") = Trim(Text6.Text)
.Fields("总套房数") = Trim(Text7.Text)
.Fields("总建筑面积") = Trim(Text8.Text)
.Fields("总人口") = Trim(Text9.Text)
.Fields("总使用面积") = Trim(Text10.Text)
.Fields("车位数") = Trim(Text11.Text)
.Fields("开发日期") = Trim(DTP1.Value)
.Fields("竣工日期") = Trim(DTP2.Value)
.Fields("备注") = Trim(Text14.Text)
objmessage.Update
MsgBox "数据保存成功!", vbInformation, "温馨提示"
isadding = False
txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
'End If
End If
Else
If isadding Then
.AddNew
.Fields("管理区代码") = Trim(Text1.Text)
.Fields("管理区名称") = Trim(Combo1.Text)
.Fields("开发商") = Trim(Text2.Text)
.Fields("承建商") = Trim(Text3.Text)
.Fields("地理位置") = Trim(Text4.Text)
.Fields("总楼群数") = Trim(Text5.Text)
.Fields("总占地面积") = Trim(Text6.Text)
.Fields("总套房数") = Trim(Text7.Text)
.Fields("总建筑面积") = Trim(Text8.Text)
.Fields("总人口") = Trim(Text9.Text)
.Fields("总使用面积") = Trim(Text10.Text)
.Fields("车位数") = Trim(Text11.Text)
.Fields("开发日期") = DTP1.Value
.Fields("竣工日期") = DTP2.Value
.Fields("备注") = Trim(Text14.Text)
.Update
MsgBox "数据保存成功!", vbInformation, "温馨提示"
isadding = False
txtNews = "记录:" & .AbsolutePosition & "/" & .RecordCount
End If
End If
End With
DTP1.Visible = False
DTP2.Visible = False
Text12.Visible = True
Text13.Visible = True
End Sub
Private Sub Command4_Click()
物业管理系统.Show
Unload Me
End Sub
Private Sub Form_Load()
'建立数据库联接
Set objcn = New Connection '实例化联接对象
With objcn '建立数据库联接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;PWD=sa;Data Source=(local);" & _
"Initial Catalog=物业管理系统"
.Open
End With
'获取管理区信息
Set objmessage = New Recordset
With objmessage
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from 管理区信息"
End With
cmdMove(0).Value = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -