📄 维修管理.frm
字号:
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin MSAdodcLib.Adodc Adodc2
Height = 330
Left = 4440
Top = 1680
Width = 1815
_ExtentX = 3201
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=物业管理系统;Data Source=(local)"
OLEDBString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=物业管理系统;Data Source=(local)"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "select * from 维修信息"
Caption = "Adodc2"
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
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 objflor As Recordset
Dim objrep As Recordset
Dim objhome As Recordset
Private Sub Cmbtype_Click()
'获取楼房信息
Set objhome = New Recordset
With objhome
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from " & Trim(Cmbtype.Text)
Set .ActiveConnection = Nothing '断开数据库联接
End With
With objhome
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
Cmbroom.AddItem .Fields("房号")
.MoveNext
Wend
End If
End With
End Sub
'添加记录
Private Sub Cmdadd_Click()
Cmbroom.Clear
MsgBox "请输入新记录!", vbInformation, "温馨提示"
Text1.Text = "自动编号"
Text2.Text = ""
Cmbtype.Text = ""
Cmbroom.Text = ""
Cmbclass.Text = ""
Text3.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
'可写状态
Text2.Enabled = True
Cmbtype.Enabled = True
Cmbroom.Enabled = True
Cmbclass.Enabled = True
DTP1.Enabled = True
Text3.Enabled = True
Text5.Enabled = True
Text6.Enabled = True
Text7.Enabled = True
Text8.Enabled = True
Text9.Enabled = True
Text10.Enabled = True
isadding = True
End Sub
'退出添加状态
Private Sub Cmdback_Click()
MsgBox "你选择退出添加状态", vbInformation, "温馨提示"
If isadding Then
isadding = False
End If
End Sub
'删除记录
Private Sub Cmddelete_Click()
If isadding = True Then
MsgBox "当前为状态为添加记录状态,不能删除记录"
Adodc2.Recordset.CancelBatch '显示当前记录
Else
If MsgBox("是否要删除当前记录?", vbYesNo + vbQuestion, "温馨提示") = vbYes Then
Adodc2.Recordset.Delete
Adodc2.Recordset.Requery
Adodc2.Refresh
End If
End If
End Sub
Private Sub Cmdexit_Click()
物业管理系统.Show
Unload Me
End Sub
Private Sub Cmdsave_Click()
If isadding = False Then
MsgBox "此状态不允许添加记录!", vbCritical, "温馨提示"
Exit Sub
End If
With objrep
If Text2.Text = "" Then
MsgBox "请输入标题!", vbInformation, "温馨提示"
Text2.SetFocus
Text2.Text = ""
Exit Sub
End If
If Cmbtype.Text = "" Then
MsgBox "请选择所属大楼!", vbInformation, "温馨提示"
Cmbtype.SetFocus
Exit Sub
End If
If Trim(Cmbroom.Text) = "" Then
MsgBox "请选择房间", vbInformation, "温馨提示"
Cmbroom.SetFocus
Exit Sub
End If
If Trim(Cmbclass.Text) = "" Then
MsgBox "请选择故障类别", vbInformation, "温馨提示"
Cmbclass.SetFocus
Exit Sub
End If
'If Trim(Text4.Text) = "" Then
'MsgBox "请输入故障时间", vbInformation, "温馨提示"
'Text4.SetFocus
'Exit Sub
'End If
If Trim(Text6.Text) = "" Then
MsgBox "请输入故障内容!", vbInformation, "温馨提示"
Text6.SetFocus
Exit Sub
End If
If Trim(Text7.Text) = "" Then
MsgBox "请输入处理结果!", vbInformation, "温馨提示"
Text7.SetFocus
Exit Sub
End If
'保存信息
If isadding Then .AddNew
.Fields("标题") = Trim(Text2.Text)
.Fields("房号") = Trim(Cmbroom.Text)
.Fields("大楼名称") = Trim(Cmbtype.Text)
.Fields("故障类别") = Trim(Cmbclass.Text)
.Fields("联系方式") = Trim(Text3.Text)
.Fields("故障时间") = Trim(DTP1.Value)
.Fields("故障现象") = Trim(Text5.Text)
.Fields("维修内容") = Trim(Text6.Text)
.Fields("处理结果") = Trim(Text7.Text)
.Fields("录入员") = Trim(Text8.Text)
.Fields("接待员") = Trim(Text9.Text)
.Fields("需要费用") = Trim(Text10.Text)
.Update
MsgBox "数据保存成功!", vbInformation, "温馨提示"
isadding = False
End With
Adodc2.Refresh '刷新记录
End Sub
'取消增加记录
Private Sub Command1_Click()
If isadding = True Then
MsgBox "是否放弃添加记录?", vbQuestion, "温馨提示"
Adodc2.Recordset.Requery
isadding = False
End If
End Sub
'按类别查找记录
Private Sub DataCombo1_Click(Area As Integer)
If DataCombo1.BoundText = "" Then
MsgBox "请选择故障类别", vbExclamation, "温馨提示"
DataCombo1.SetFocus
Exit Sub
End If
a = DataCombo1.BoundText
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find ("故障类别='" & a & "'")
'If Adodc1.Recordset.EOF Then
'MsgBox "未找到记录", vbCritical, "温馨提示"
'DataCombo1.SetFocus
'Exit Sub
'End If
b = "select * from 维修信息 where 故障类别='" & Adodc1.Recordset("故障类别") & "'"
Adodc2.RecordSource = b
Adodc2.Refresh
End Sub
Private Sub Form_Load()
' Cmdsave.Enabled = False
' Cmdback.Enabled = False
'Command1.Enabled = False
Label1.Visible = False
DataCombo1.Visible = False
'建立数据库联接
Set objcn = New Connection '实例化联接对象
With objcn '建立数据库联接
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=sa;PWD=sa;Data Source=(local);" & _
"Initial Catalog=物业管理系统"
.Open
End With
'获取维修信息数据
Set objrep = New Recordset
With objrep
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from 维修信息"
End With
'获取大楼信息数据
Set objflor = New Recordset
With objflor
Set .ActiveConnection = objcn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open "select * from 大楼信息"
End With
With objflor
If .RecordCount > 0 Then
.MoveFirst
While Not .EOF
Cmbtype.AddItem .Fields("大楼名称")
.MoveNext
Wend
End If
End With
End Sub
Private Sub Option1_Click()
Label1.Visible = False
DataCombo1.Visible = False
End Sub
Private Sub Option3_Click()
Label1.Visible = False
DataCombo1.Visible = False
End Sub
'选择查找按钮
Private Sub Option2_Click()
Label1.Visible = True
DataCombo1.Visible = True
End Sub
Private Sub CataCombo1_Click()
a = DataCombo1.BoundText
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find ("故障类别='" & a & "'")
b = "select * from 维修信息 where 故障类别='" & Adodc1.Recordset("故障类别") & "'"
Adodc2.RecordSource = b
Adodc2.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -