本論文在其他論文欄目,由論文格式網(wǎng)整理,轉載請注明來源www.donglienglish.cn,更多論文,請點論文格式范文查看
本模塊代碼如下:
Private Sub Command1_Click()
Dim strUserName As String
Dim strPassword As String
Static intLoginTimes As Integer
If Trim(Text1.Text) = "" Then '如果用戶名為空
MsgBox "用戶名不能為空!", vbOKOnly + vbCritical, "錯誤"
Text1.SetFocus
Exit Sub
End If
'打開數(shù)據(jù)庫中的 用戶表
Adodc1.Refresh
'查找用戶名
'Adodc1.Recordset.Find "用戶名 ='" & Text1.Text & "' ", , adSearchForward, 1
'也可以用下面的過濾方式
Adodc1.Recordset.Filter = "用戶名 ='" & Text1.Text & "'"
If Not Adodc1.Recordset.EOF Then '找到記錄
strUserName = Adodc1.Recordset!用戶名
strPassword = Adodc1.Recordset!密碼
'Else '沒找到記錄
'Text1 = ""
'Text2 = ""
End If
If strUserName = Text1.Text And strPassword = Text2.Text Then
Adodc1.Recordset.Close '關閉數(shù)據(jù)庫中的 用戶表
Unload Me '關閉窗體
frmMain.Show '顯示主窗體
Else
'用戶名或密碼不對
MsgBox "用戶名或密碼不對!", vbOKOnly + vbInformation, "提示"
Text1 = ""
Text2 = ""
intLoginTimes = intLoginTimes + 1
If intLoginTimes >= 3 Then '超過三次
Adodc1.Recordset.Close '關閉數(shù)據(jù)庫中的 用戶表
End '退出整個程序
End If
Text2.SetFocus '重新輸入密碼
SendKeys "{HOME}+{END}"
End If
End Sub
Private Sub Command2_Click()
Dim strql As String
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "Insert Into 住戶基本信息表 (戶主,住址,電話,入住時間,身份證號碼) values ('" + Text1.Text + "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "')"
strsql = "update 住戶基本信息表 set 住址 = '" + Text2.Text + "' ,戶主 = '" + Text1.Text + "',電話 = '" + Text3.Text + "',入住時間 = '" + Text4.Text + "' where 身份證號碼='" + Text5.Text + "'"
Private Sub Command4_Click()
Dim strqsl As String
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "delete * from 住戶基本信息表 where 住址 = '" + Text1.Text + "'"
db.Execute strsql
strsql = “delete*from 房屋基本信息 where 住址= + Text1.TEXT+”
5.4 房屋信息管理模塊
房產(chǎn)資料主要是對住戶的基本信息如 (物業(yè)地址、使用面積、房屋結構、設備、出售信息等信息)的添加、修改、刪除、查詢及統(tǒng)計記錄個數(shù)。添加、修改、刪除這些操作必須保存后才能生效。當記錄較多,通過簡單的查詢可以方便的找的目標記錄,查詢結果已表格方式顯示。表格顯示結果的同時,如果還出現(xiàn)多條記錄,可以根據(jù)某個字段對記錄進行排序,這樣可以給用戶帶來更大的方便和提高查找效率。
界面截圖如下:
圖(5-4) 房屋信息管理界面截圖
本模塊代碼如下:
Private Sub Command2_Click()
Dim strql As String
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "Insert Into 房屋基本信息 (住址,設備,房屋結構,房屋面積,出售信息) values ('" + Text1.Text + "','" & Text2.Text & "','" & Text3.Text & "','" & Text4.Text & "','" & Text5.Text & "')"
strsql = "update 房屋基本信息 set 住址 = '" + Text1.Text + "' ,設備 = '" + Text2.Text + "',房屋結構 = '" + Text3.Text + "',房屋面積 = '" + Text4.Text + "' where 出售信息='" + Text5.Text + "'"
End If
db.Execute strsql
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "delete * from 房屋基本信息 where 住址 = '" + Text1.Text + "'"
db.Execute strsql
Private Sub Command6_Click()
frmMain.Show
Unload Me
End Sub
Private Sub Form_Load()
Dim strsql As String
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "select * from 房屋基本信息"
Set rs = db.OpenRecordset(strsql)
End Sub
Private Sub Command3_Click()
Dim strsql As String
If MsgBox("是否要修改此記錄", 32 + 1, "修改") = 1 Then
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "update 收費信息表 set 住址 = '" + Text1.Text + "' ,水費 = '" + Text2.Text + "',電費 = '" + Text3.Text + "',寬帶 = '" + Text4.Text + "',垃圾清運費 ='" + Text5.Text + "',物業(yè)管理費 = '" + Text6.Text + "',收費時間 = '" + Text7.Text + "'"
End If
db.Execute strsql
db.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
MsgBox "修改成功"
End Sub
Private Sub Command4_Click()
Dim strqsl As String
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "delete * from 收費信息表 where 住址 = '" + Text1.Text + "'"
db.Execute strsql
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
MsgBox "刪除成功"
End Sub
Private Sub Command5_Click()
Form7.Show
Unload Me
End Sub
Private Sub Command6_Click()
frmMain.Show
Unload Me
End Sub
Private Sub Form_Load()
Dim strsql As String
Set db = OpenDatabase(App.Path + "\db1.mdb")
strsql = "select * from 收費信息表"
Set rs = db.OpenRecordset(strsql)
End Sub