某學(xué)校公寓管理系統(tǒng)設(shè)計(jì)書.doc_第1頁(yè)
某學(xué)校公寓管理系統(tǒng)設(shè)計(jì)書.doc_第2頁(yè)
某學(xué)校公寓管理系統(tǒng)設(shè)計(jì)書.doc_第3頁(yè)
某學(xué)校公寓管理系統(tǒng)設(shè)計(jì)書.doc_第4頁(yè)
某學(xué)校公寓管理系統(tǒng)設(shè)計(jì)書.doc_第5頁(yè)
已閱讀5頁(yè),還剩29頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

某學(xué)校公寓管理系統(tǒng)設(shè)計(jì)書 1 課題描述各個(gè)學(xué)校對(duì)學(xué)生宿舍的管理已經(jīng)有了很長(zhǎng)的歷史,并且已經(jīng)具備了一定的規(guī)模和形態(tài),同時(shí)對(duì)學(xué)生公寓的服務(wù)和管理也要求很高.諸如對(duì)學(xué)生入住情況的詳細(xì)了解,以及來(lái)訪者的情況都要求宿舍管理人員做的好,做的完善。這樣要求公寓管理人員對(duì)學(xué)生宿舍管理進(jìn)行宏觀的和微觀的細(xì)致管理,其中最好的辦法是用計(jì)算機(jī)操作的學(xué)生宿舍管理系統(tǒng)來(lái)實(shí)現(xiàn)對(duì)學(xué)生宿舍的管理。學(xué)生宿舍管理系統(tǒng)在各個(gè)學(xué)校中都具有廣泛的應(yīng)用,它具有衛(wèi)生評(píng)比、違紀(jì)處理、來(lái)客登記和房間信息功能。它不僅具有檢索迅速、查找方便、操作簡(jiǎn)單、可靠性高、存儲(chǔ)量大、保密性好、壽命長(zhǎng)和成本低的優(yōu)點(diǎn),還可以極大地提高宿舍管理員的工作效率和質(zhì)量。開發(fā)工具:Visual Basic 6.02 需求分析2.1 可行性研究可行性研究的目的,就是用最小的代價(jià)在盡可能短的時(shí)間內(nèi)確定問(wèn)題是否能夠解決,是否值得去解。我們從三個(gè)方面來(lái)進(jìn)行可行性研究,即技術(shù)可行性、經(jīng)濟(jì)可行性和操作可行性。2. 1.1 技術(shù)可行性學(xué)生宿舍管理系統(tǒng),采用Visual Basic 6.0進(jìn)行編程和界面設(shè)計(jì),以 SQL server 2000為后臺(tái)數(shù)據(jù)庫(kù)來(lái)實(shí)現(xiàn)的,全面采用以窗口、表單、對(duì)話框和聯(lián)機(jī)幫助為特征的圖形用戶界面的技術(shù)和操作方法。系統(tǒng)操作簡(jiǎn)單,功能大,使用方便,具有很強(qiáng)的技術(shù)可行性。2. 1.2經(jīng)濟(jì)可行性學(xué)生宿舍管理是一個(gè)很大的項(xiàng)目,在早期,還沒(méi)有利用計(jì)算機(jī)管理時(shí),一切都是利用人工進(jìn)行管理的,這樣管理起來(lái)既煩瑣又復(fù)雜,資料也很容易被丟失,而且耗時(shí)、耗資金。而利用本系統(tǒng),可以高效地對(duì)學(xué)生宿舍進(jìn)行統(tǒng)一管理與控制,資料也不容易被丟失,這樣大大節(jié)省了人力與資源,提高了管理效率,給管理人員帶來(lái)很多方便。2. 1.3操作可行性操作可行性也即實(shí)用性。隨著計(jì)算機(jī)技術(shù)的發(fā)展以及網(wǎng)絡(luò)的發(fā)展,對(duì)學(xué)生宿舍的管理與控制越來(lái)越實(shí)用并且得到管理者的證實(shí),無(wú)論是查詢還是修改都有很方便,查詢的信息一目了然。因此,它具有很強(qiáng)的實(shí)用性。因此本系統(tǒng)在操作上也可行。 根據(jù)上述三個(gè)方面的研究得出:可以開發(fā)本系統(tǒng)。2.2 功能需求基于系統(tǒng)需求分析,該系統(tǒng)需要實(shí)現(xiàn)以下基本功能:衛(wèi)生評(píng)比管理模塊,主要完成評(píng)比信息的錄入、修改和刪除以及評(píng)比結(jié)果的查詢功能。違紀(jì)處理管理模塊,主要完成違紀(jì)信息的錄入、修改、刪除和查詢等功能。來(lái)客登記管理模塊,主要提供來(lái)訪登記、離開登記和來(lái)訪信息查詢功能。房間信息管理模塊,主要是提供對(duì)房間信息的錄入、修改、刪除功能,同時(shí)提供房間分配和房間信息查詢功能。數(shù)據(jù)庫(kù)管理:對(duì)現(xiàn)有的數(shù)據(jù)庫(kù)進(jìn)行管理,包括數(shù)據(jù)備份和恢復(fù),以方便用戶對(duì)數(shù)據(jù)庫(kù)的管理和維護(hù)工作,提高系統(tǒng)的數(shù)據(jù)安全性。2.3 性能需求系統(tǒng)運(yùn)行環(huán)境:Windows 2000及其以上數(shù)據(jù)庫(kù):SQL server 20003系統(tǒng)設(shè)計(jì)3.1系統(tǒng)層次模塊圖學(xué)生宿舍管理系統(tǒng)宿舍信息管理衛(wèi)生情況管理違規(guī)情況管理訪客信息管理衛(wèi)生情況錄入評(píng)分查詢違規(guī)處理情況錄入違規(guī)處理情況查詢來(lái)訪登記離開登記來(lái)訪查詢圖3.1 系統(tǒng)層次模塊圖3.2數(shù)據(jù)庫(kù)設(shè)計(jì) 3.2.1數(shù)據(jù)庫(kù)實(shí)體圖設(shè)計(jì)宿舍宿舍號(hào)備 注衛(wèi)生情況圖3.2 宿舍實(shí)體圖學(xué)生學(xué) 號(hào)姓 名衛(wèi)生情況班 級(jí)圖3.3 學(xué)生實(shí)體圖訪客姓 名來(lái)訪時(shí)間離開時(shí)間圖3.4 訪客實(shí)體圖3.2.2數(shù)據(jù)庫(kù)E-R圖設(shè)計(jì)宿 舍學(xué) 生訪 客宿舍信息訪客信息圖3.5宿舍管理系統(tǒng)E-R圖3.2.3數(shù)據(jù)庫(kù)關(guān)系模型設(shè)計(jì)宿舍(宿舍號(hào),衛(wèi)生情況,備注)學(xué)生(學(xué)號(hào),姓名,班級(jí),違紀(jì)處理情況)宿舍信息(宿舍號(hào),學(xué)號(hào))訪客(姓名,來(lái)訪時(shí)間,離開時(shí)間)訪客信息(姓名,來(lái)訪時(shí)間,學(xué)號(hào))3.2.4數(shù)據(jù)庫(kù)物理設(shè)計(jì)系統(tǒng)建立的數(shù)據(jù)庫(kù)表主要有五個(gè),如下圖所示。字段名數(shù)據(jù)類型字段長(zhǎng)度與格式關(guān)鍵字宿舍號(hào)varchar5是衛(wèi)生情況varchar50否備注varchar50否圖3.6“宿舍”信息表結(jié)構(gòu)字段名數(shù)據(jù)類型字段長(zhǎng)度與格式關(guān)鍵字學(xué)號(hào)varchar5是姓名varchar50否班級(jí)varchar50否違紀(jì)處理情況varchar50否圖3.7“學(xué)生”信息表結(jié)構(gòu)字段名數(shù)據(jù)類型字段長(zhǎng)度與格式關(guān)鍵字學(xué)號(hào)varchar5是宿舍號(hào)varchar5是圖3.8“宿舍信息”信息表結(jié)構(gòu)字段名數(shù)據(jù)類型字段長(zhǎng)度與格式關(guān)鍵字姓名varchar50是訪問(wèn)時(shí)間varchar50是離開時(shí)間varchar50否圖3.9“訪客”信息表結(jié)構(gòu)字段名數(shù)據(jù)類型字段長(zhǎng)度與格式關(guān)鍵字學(xué)號(hào)varchar50是姓名varchar50是來(lái)訪時(shí)間varchar50否 圖3.10“訪客信息”信息表結(jié)構(gòu)3.3主控平臺(tái)界面設(shè)計(jì)充分考慮易于操作的系統(tǒng)需求,主控制平臺(tái)使用簡(jiǎn)單和直觀的布局設(shè)計(jì)。4系統(tǒng)實(shí)現(xiàn)4.1系統(tǒng)用戶管理模塊創(chuàng)建一個(gè)系統(tǒng)登錄窗體、一個(gè)轉(zhuǎn)入窗體的主窗口窗體,利用組合框?yàn)橛脩籼峁?shù)據(jù),實(shí)現(xiàn)多項(xiàng)選擇的功能,如圖4.1所示。圖4.1 登錄窗口其主要代碼如下:Option ExplicitPublic strcon As StringPrivate Sub btnCancel_Click() txtUserName.Text = txtPassword.Text = If MsgBox(退出嗎?, vbOKCancel, 提示) = vbOK Then End End IfEnd SubPrivate Sub cmdok_Click() Rem 判斷是否為空If Len(txtUserName.Text) = 0 Then MsgBox 用戶名不能為空, vbExclamation, 警告 Exit SubEnd IfIf Len(txtPassword.Text) = 0 Then MsgBox 密碼不能為空, vbExclamation, 警告 Exit SubEnd IfRem 獲取密碼用戶 Dim struser As String struser = txtUserName.Text Dim strpw As String strpw = txtPassword.TextDim strsql As Stringstrsql = select ano as user,secret as pw from adminer Dim conn As New ADODB.ConnectionDim rst As New ADODB.RecordsetDim cmd As New ADODB.Commandconn.ConnectionString = strcon 引用公共變量 On Error GoTo conconn.Opencmd.ActiveConnection = conncmd.CommandText = strsqlSet rst = cmd.ExecuteDo Until rst.EOF If UCase(struser) = UCase(rst(user) Then If strpw = rst(pw) Then 密碼正確,顯示窗體,退出循環(huán) main.Show Unload Me rst.Close conn.Close txtUserName.Text = txtPassword.Text = Exit Sub Else 密碼錯(cuò)誤 MsgBox 密碼錯(cuò)誤, vbExclamation, 警告 txtPassword.Text = rst.Close conn.Close Exit Sub End IfEnd If rst.MoveNextLooprst.Closeconn.Close MsgBox 不存在該用戶, vbExclamation, 警告 txtPassword.Text = Exit Subcon:MsgBox 請(qǐng)確認(rèn)以下設(shè)置 & Chr(13) + Chr(10) & SQL Server 服務(wù)器已經(jīng)啟動(dòng); & Chr(13) + Chr(10) & 數(shù)據(jù)庫(kù)身份驗(yàn)證模式為SQL Server 和 Windows身份驗(yàn)證模式End SubPrivate Sub Form_Load()strcon = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=學(xué)生宿舍管理系統(tǒng);server=(local)End SubPrivate Sub Label1_Click()End Sub4.2衛(wèi)生評(píng)比管理模塊創(chuàng)建一個(gè)衛(wèi)生評(píng)比管理窗體,里面包括查詢、添加和修改功能,利用Label、Textbox、Button和 DatGird等畫出如下窗體。圖4.2衛(wèi)生評(píng)分錄入界面圖4.2衛(wèi)生評(píng)分錄入界面圖4.3衛(wèi)生評(píng)分查詢界面其主要代碼如下:Public strcon As StringPrivate Sub Command1_Click() If Trim(Text1.Text) = Then MsgBox 沒(méi)有選中任何行或則學(xué)號(hào)為空!, vbInformation, 提示 Exit Sub End If On Error GoTo myError: Dim strsql As String strsql = select 宿舍號(hào) from 宿舍 Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql Set rst = cmd.ExecuteDo Until rst.EOF Dim strsno As String strsno = UCase(rst(宿舍號(hào)) rst.MoveNextLoop If strsno UCase(Text1.Text) Then MsgBox 該宿舍不存在!, vbExclamation, 提示 conn.Close Exit Sub End If strsql = update 宿舍 set 衛(wèi)生情況= & Text2.Text & where 宿舍號(hào)= & Text1.Text & Call sqlcmd(strsql) MsgBox 執(zhí)行成功!, vbInformation, 提示 Text1.Text = Text2.Text = Exit SubmyError: MsgBox 更新失敗! & Chr(10) + Chr(13) & 更新的數(shù)據(jù)中存在非法字符空格、單引號(hào)、雙引號(hào)、空, vbExclamation, 提示End SubPrivate Sub Command2_Click()Unload MeEnd SubSub sqlcmd(strsql As String) 更新、刪除、插入數(shù)據(jù) Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量 conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql cmd.Execute conn.Close End SubPrivate Sub Form_Load()strcon = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=學(xué)生宿舍管理系統(tǒng);server=(local)End SubPrivate Sub Text1_Change()End SubOption ExplicitPublic blnNeedUpdate As BooleanPublic blnAdding As BooleanPublic strcon As StringPrivate Sub Command1_Click()Dim struser As StringIf Len(Text1.Text) 0 Then struser = Text1.TextElse If Len(Text2.Text) 0 Then struser = Text2.Text Else MsgBox 信息不能為空, vbExclamation, 警告 End IfEnd IfDim strsql As StringDim strsql1 As Stringstrsql = select 宿舍號(hào) as sushe from 宿舍 Dim conn As New ADODB.ConnectionDim rst As New ADODB.RecordsetDim cmd As New ADODB.Commandconn.ConnectionString = strcon 引用公共變量conn.Opencmd.ActiveConnection = conncmd.CommandText = strsqlSet rst = cmd.ExecuteDo Until rst.EOF If UCase(struser) = UCase(rst(sushe) Thenstrsql1 = select 宿舍號(hào),衛(wèi)生情況 from 宿舍 where 宿舍號(hào)= & Text1.Text & Call bindGrid(strsql1) Exit Sub Else strsql1 = select 宿舍號(hào),衛(wèi)生情況 from 宿舍 where 衛(wèi)生情況= & Text2.Text & Call bindGrid(strsql1)End If rst.MoveNextLooprst.Closeconn.CloseEnd SubSub bindGrid(strsql As String)Rem 綁定datagrid Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset conn.ConnectionString = strcon 引用公共變量 conn.CursorLocation = adUseClient conn.Open rst.Open strsql, conn, adOpenDynamic, adLockBatchOptimistic Set DataGrid1.DataSource = rst.DataSource Call gridWidth End SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click() If Trim(Text1.Text) = Then MsgBox 沒(méi)有選中任何行或則宿舍號(hào)為空!, vbInformation, 提示 Exit Sub End If On Error GoTo myError: Dim strsql As String strsql = update 宿舍 set 宿舍號(hào)= & Text1.Text & ,衛(wèi)生情況= & Text2.Text & where 宿舍號(hào)= & Text1.Text & Call sqlcmd(strsql) blnAdding = False strsql = select 宿舍號(hào),衛(wèi)生情況 from 宿舍 where 宿舍號(hào)= & Text1.Text & Call bindGrid(strsql) MsgBox 執(zhí)行成功!, vbInformation, 提示 Text1.Text = Text2.Text = Exit SubmyError: MsgBox 更新失敗! & Chr(10) + Chr(13) & 更新的數(shù)據(jù)中存在非法字符空格、單引號(hào)、雙引號(hào)、空, vbExclamation, 提示End SubPrivate Sub Command4_Click() Text1.Locked = False Text1.Text = Text2.Text = End SubPrivate Sub DataGrid1_Click()blnAdding = False Text1.Locked = True Dim n As Integer Dim DgCount As Integer DgCount = DataGrid1.Columns.Count For n = 0 To DgCount - 1 DataGrid1.Col = n Select Case n Case 0 Text1.Text = DataGrid1.Text Case 1 Text2.Text = DataGrid1.Text End Select Next nEnd SubPrivate Sub Form_Load()strcon = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=學(xué)生宿舍管理系統(tǒng);server=(local)End SubSub gridWidth() Dim n As Integer Dim DgCount As Integer DgCount = DataGrid1.Columns.Count For n = 0 To DgCount - 1 DataGrid1.Columns(n).Width = Len(DataGrid1.Columns(n).Caption) * 350 DataGrid1.Col = n DataGrid1.AllowAddNew = False DataGrid1.AllowArrows = False DataGrid1.AllowDelete = False DataGrid1.AllowUpdate = False Next nEnd SubPrivate Sub DridStudent_RowColChange(LastRow As Variant, ByVal LastCol As Integer) End SubSub sqlcmd(strsql As String) 更新、刪除、插入數(shù)據(jù) Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量 conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql cmd.Execute conn.Close End Sub 4.3違紀(jì)處理管理模塊創(chuàng)建一個(gè)違紀(jì)處理管理窗體,里面包括查詢、添加和修改功能,利用Label、Textbox、Button和 DatGird等畫出如下窗體,如下圖所示。圖4.4違紀(jì)情況錄入界面圖4.5違紀(jì)情況查詢界面其主要代碼如下:Public strcon As StringPrivate Sub Command1_Click() If Trim(Text1.Text) = Then MsgBox 沒(méi)有選中任何行或則學(xué)號(hào)為空!, vbInformation, 提示 Exit Sub End If On Error GoTo myError: Dim strsql As String strsql = select 學(xué)號(hào) from 學(xué)生 Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量 conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql Set rst = cmd.ExecuteDo Until rst.EOF Dim strsno As String strsno = UCase(rst(學(xué)號(hào)) rst.MoveNext If strsno = UCase(Text1.Text) Then strsql = update 學(xué)生 set 違紀(jì)處理情況= & Text2.Text & where 學(xué)號(hào)= & Text1.Text & Call sqlcmd(strsql) MsgBox 執(zhí)行成功!, vbInformation, 提示 Text1.Text = Text2.Text = Exit Sub End If Loop MsgBox 該學(xué)生不存在!, vbExclamation, 提示 conn.Close Exit SubmyError: MsgBox 更新失敗! & Chr(10) + Chr(13) & 更新的數(shù)據(jù)中存在非法字符空格、單引號(hào)、雙引號(hào)、空, vbExclamation, 提示End SubPrivate Sub Command2_Click()Unload MeEnd SubSub sqlcmd(strsql As String) 更新、刪除、插入數(shù)據(jù) Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量 conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql cmd.Execute conn.Close End SubPrivate Sub Form_Load()strcon = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=學(xué)生宿舍管理系統(tǒng);server=(local)End SubPrivate Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubOption ExplicitPublic blnNeedUpdate As BooleanPublic blnAdding As BooleanPublic strcon As StringPrivate Sub Command1_Click()Dim struser As StringIf Len(Text1.Text) 0 Then struser = Text1.TextElse If Len(Text2.Text) 0 Then struser = Text2.Text Else MsgBox 信息不能為空, vbExclamation, 警告 End IfEnd IfDim strsql As StringDim strsql1 As Stringstrsql = select 學(xué)號(hào) as sushe from 學(xué)生 Dim conn As New ADODB.ConnectionDim rst As New ADODB.RecordsetDim cmd As New ADODB.Commandconn.ConnectionString = strcon 引用公共變量conn.Opencmd.ActiveConnection = conncmd.CommandText = strsqlSet rst = cmd.ExecuteDo Until rst.EOF If UCase(struser) = UCase(rst(sushe) Then strsql1 = select 學(xué)號(hào),違紀(jì)處理情況 from 學(xué)生 where 學(xué)號(hào)= & Text1.Text & Call bindGrid(strsql1) Exit Sub Else strsql1 = select 學(xué)號(hào),違紀(jì)處理情況 from 學(xué)生 where 學(xué)號(hào)= & Text2.Text & Call bindGrid(strsql1)End If rst.MoveNextLooprst.Closeconn.CloseEnd SubSub bindGrid(strsql As String)Rem 綁定datagrid Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordsetconn.ConnectionString = strcon 引用公共變量 conn.CursorLocation = adUseClientconn.Open rst.Open strsql, conn, adOpenDynamic, adLockBatchOptimistic Set DataGrid1.DataSource = rst.DataSource Call gridWidth End SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Command3_Click() If Trim(Text1.Text) = Then MsgBox 沒(méi)有選中任何行或則學(xué)號(hào)為空!, vbInformation, 提示 Exit Sub End If On Error GoTo myError: Dim strsql As String strsql = update 學(xué)生 set 學(xué)號(hào)= & Text1.Text & ,違紀(jì)處理情況= & Text2.Text & where 學(xué)號(hào)= & Text1.Text & Call sqlcmd(strsql) blnAdding = False strsql = select 學(xué)號(hào),違紀(jì)處理情況 from 學(xué)生 where 學(xué)號(hào)= & Text1.Text & Call bindGrid(strsql) MsgBox 執(zhí)行成功!, vbInformation, 提示 Text1.Text = Text2.Text = Exit SubmyError: MsgBox 更新失敗! & Chr(10) + Chr(13) & 更新的數(shù)據(jù)中存在非法字符空格、單引號(hào)、雙引號(hào)、空, vbExclamation, 提示End SubPrivate Sub Command4_Click() Text1.Locked = False Text1.Text = Text2.Text = End SubPrivate Sub DataGrid1_Click()blnAdding = False Text1.Locked = True Dim n As Integer Dim DgCount As Integer DgCount = DataGrid1.Columns.Count For n = 0 To DgCount - 1 DataGrid1.Col = n Select Case n Case 0 Text1.Text = DataGrid1.Text Case 1 Text2.Text = DataGrid1.Text End Select Next nEnd SubPrivate Sub Form_Load()strcon = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=學(xué)生宿舍管理系統(tǒng);server=(local)End SubSub gridWidth() Dim n As Integer Dim DgCount As Integer DgCount = DataGrid1.Columns.Count For n = 0 To DgCount - 1 DataGrid1.Columns(n).Width = Len(DataGrid1.Columns(n).Caption) * 350 DataGrid1.Col = n DataGrid1.AllowAddNew = False DataGrid1.AllowArrows = False DataGrid1.AllowDelete = False DataGrid1.AllowUpdate = False Next nEnd SubPrivate Sub DridStudent_RowColChange(LastRow As Variant, ByVal LastCol As Integer) End SubSub sqlcmd(strsql As String) 更新、刪除、插入數(shù)據(jù) Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量 conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql cmd.Execute conn.Close End Sub 4.4來(lái)客登記管理模塊創(chuàng)建一個(gè)來(lái)訪查詢窗體,里面包括查詢、添加和修改功能,利用Label、Textbox、Button和 DatGird等畫出如下窗體,如下圖所示。圖4.6來(lái)訪登記界面圖4.7離開登記界面圖4.8來(lái)訪查詢界面其主要代碼如下: Public strcon As StringPrivate Sub Command1_Click() If Trim(Text1.Text) = Then MsgBox 訪客姓名為空!, vbInformation, 提示 Exit Sub End If If Trim(Text2.Text) = Then MsgBox 被訪人宿舍為空!, vbInformation, 提示 Exit Sub End If If Trim(Text3.Text) = Then MsgBox 被訪人姓名為空!, vbInformation, 提示 Exit Sub End If If Trim(Text4.Text) = Then MsgBox 訪問(wèn)時(shí)間為空!, vbInformation, 提示 Exit Sub End If On Error GoTo myError: Dim strsql As String Dim strsql1 As String strsql = select 宿舍號(hào),姓名,學(xué)生.學(xué)號(hào) as xuehao from 宿舍信息,學(xué)生 where 宿舍信息.學(xué)號(hào)=學(xué)生.學(xué)號(hào) and 姓名= & Text3.Text & and 宿舍號(hào)= & Text2.Text & Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量 conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql Set rst = cmd.ExecuteDo Until rst.EOF Dim strsno As String Dim strsno1 As String Dim strsno2 As String strsno = UCase(rst(宿舍號(hào)) strsno1 = UCase(rst(姓名) strsno2 = UCase(rst(xuehao) rst.MoveNextLoop If strsno2 = 0 Then MsgBox 該學(xué)生不存在!, vbInformation, 提示 Exit Sub Else strsql1 = insert into 訪客 values( & Text1.Text & , & Text4.Text & ,) Call sqlcmd(strsql1) strsql1 = insert into 訪客信息 values( & Text1.Text & , & strsno2 & , & Text4.Text & ) Call sqlcmd(strsql1) End If MsgBox 執(zhí)行成功!, vbInformation, 提示 Text1.Text = Text2.Text = Text3.Text = Text4.Text = Exit SubmyError: MsgBox 更新失敗! & Chr(10) + Chr(13) & 更新的數(shù)據(jù)中存在非法字符空格、單引號(hào)、雙引號(hào)、空, vbExclamation, 提示End SubPrivate Sub Command2_Click()Unload MeEnd SubSub sqlcmd(strsql As String) 更新、刪除、插入數(shù)據(jù) Dim conn As New ADODB.Connection Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量 conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql cmd.Execute conn.Close End SubPrivate Sub Form_Load()strcon = Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=學(xué)生宿舍管理系統(tǒng);server=(local)End SubPrivate Sub Label4_Click()End SubPublic strcon As StringPrivate Sub Command1_Click() If Trim(Text1.Text) = Then MsgBox 來(lái)訪人姓名為空!, vbInformation, 提示 Exit Sub End If On Error GoTo myError: Dim strsql As String strsql = select 姓名 from 訪客 Dim conn As New ADODB.Connection Dim rst As New ADODB.Recordset Dim cmd As New ADODB.Command conn.ConnectionString = strcon 引用公共變量conn.Open cmd.ActiveConnection = conn cmd.CommandText = strsql Set rst = cmd.ExecuteDo Until rst.EOF Dim strsno As String strsno = UCase(rst(姓名) rst.MoveNext If strsno UCase(Text1.Text) Then strsql = update 訪客 set 離開時(shí)間= & Text2.Text & where 姓名= & Text1.Text & Call sqlcmd(strsql) MsgBox 執(zhí)行成功!, vbInformation, 提示 Text1.Text = Text2.Text = Exit Sub End If Loop MsgBox 該訪客不存在!, vbExclamation, 提示 conn.Close Exit Sub myError: MsgBox 更新失?。?& Chr(10) + Chr(13) & 更新的數(shù)據(jù)中存在非法字符空格、單引號(hào)、雙引號(hào)、空,

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論