【正文】
txtItem(Index).Enabled = False Next Index 39。所有移動(dòng)控件可用 For Index = 0 To 3 CmdMove(Index).Enabled = True Next Index 39。 39。當(dāng)flagSuShe=true 執(zhí)行,宿舍已分配數(shù)加一操作Dim flagCunZai As Boolean 39。用來(lái)存放出錯(cuò)消息Dim Index As IntegerPrivate Sub Form_Load()SQL = select * from 宿舍分配表 Set rs = SelectSQL(SQL)Set = rsIf 0 ThenCall showdataCall XingMingdataElseFor Index = 0 To 3CmdMove(Index).Enabled = FalseNext IndexEnd If = True = True = True = False = FalseEnd SubPrivate Sub CmdMove_Click(Index As Integer)Select Case IndexCase Is = 0If Not Then Case Is = 1If 0 Then If = False Then If = True Then End IfCase Is = 2If 0 Then If = False Then If = True Then End IfCase Is = 3If Not Then End SelectIf 0 ThenCall showdata = True = True = True = False = FalseElse = True = False = False = False = FalseEnd IfEnd SubPrivate Sub LoadData()39。 39。 39。 39。增加已分配床位數(shù)標(biāo)志End IfElseIf XueHaoValue txtItem(0).Text And uSheValue txtItem(1).Text Then If 0 ThenMsgBox (該學(xué)生已經(jīng)分配宿舍,請(qǐng)不要重復(fù)添加!)Checkdata = FalseExit Function ElseCheckdata = True End IfIf (2) + 1 (1) ThenMsgBox 此宿舍已滿,請(qǐng)另行分配宿舍!Checkdata = FalseExit FunctionElseCheckdata = True 39。 amp。 amp。SuShe = (1)If flag = Add And flagSuShe = True ThenFor Index = 0 To 1If txtItem(Index).Text Then(Index) = txtItem(Index).TexttxtItem(Index).Enabled = FalseEnd IfNext Index(姓名) = (姓名) 39。SQL = select * from 宿舍信息表 where 宿舍號(hào)=39。Set rsSuShe = SelectSQL(SQL) (2) = (2) 1 ElseIf flagSuShe = False ThenFor Index = 0 To 1 If txtItem(Index).Text Then (Index) = txtItem(Index).Text txtItem(Index).Enabled = False End IfNext Index39。 Trim(txtItem(0).Text) amp。 amp。ElseExit FunctionEnd IfNext IndexElseSQL = select 姓名 from 學(xué)生信息表 where 學(xué)號(hào)=39。Set rsLinShi2 = SelectSQL(SQL)(姓名) = (姓名)Exit FunctionEnd IfEnd IfEnd FunctionPrivate Sub CmdDelete_Click()39。 39。所有移動(dòng)控件不可用 If = 0 Then For Index = 0 To 3 CmdMove(Index).Enabled = False Next Index End If 39。 39。 39。 amp。 amp。重新裝載數(shù)據(jù) 39。 amp。 (學(xué)號(hào)) amp。 39。)If Not Then Call showdata 39。在加入學(xué)號(hào)和宿舍號(hào)的同時(shí),從學(xué)生信息表中獲取此學(xué)生姓名,加入到宿舍分配表中End IfEnd IfCall XingMingdataFor Index = 0 To 3CmdMove(Index).Enabled = TrueNext IndexCall LoadData = True = True = True = False = FalseIf flag = Add Then MsgBox (成功添加數(shù)據(jù)!) Else MsgBox (成功更新數(shù)據(jù)!) End If Call LoadDataIf 0 Then (學(xué)號(hào)=39。 SuShe amp。(姓名) = (姓名) 39。 39。 39。保存If Not Checkdata Then Exit SubDim rsSuShe As New Dim rsXueSheng As New Dim SuShe As String 39。**添加操作MsgBox (該學(xué)生已經(jīng)分配宿舍,請(qǐng)不要重復(fù)添加!)Checkdata = FalseExit FunctionEnd IfIf (2) + 1 (1) ThenMsgBox 此宿舍已滿,請(qǐng)另行分配宿舍!Checkdata = FalseExit FunctionElseCheckdata = TrueflagSuShe = True 39。 amp。 amp。 amp。用來(lái)存放修改前,當(dāng)前修改記錄的學(xué)號(hào),用它在checkdata()函數(shù)中與文本框值比較Dim SuSheValue As String 39。For Index = 1 To If Not ThenElseEnd IfNext IndexElseExit FunctionEnd IfEnd FunctionPrivate Sub Form_Unload(Cancel As Integer) = TrueUnload MeEnd SubPrivate Sub cmdexit_click() = TrueUnload MeEnd SubF宿舍分配管理表:Dim rs As New Dim SQL As StringDim flag As String 39。 amp。按鈕可用性處理 = True: = False: = True = False: = False MsgBox (成功刪除的數(shù)據(jù)!) End If Else MsgBox (沒(méi)有可刪除的數(shù)據(jù)!) End If Exit SubErrMsg: MsgBox , vbExclamation, 出錯(cuò)End SubPrivate Sub CmdCancel_Click()39。刪除操作 On Error GoTo ErrMsg If 0 Then msg = MsgBox(刪除該條記錄嗎?, vbYesNo) If msg = vbYes Then Call SuSheDelete Call LoadData 39。文本框可用 For Index = 0 To 2 txtItem(Index).Enabled = True Next Index 39。 39。重新裝載數(shù)據(jù) 39。如果是修改數(shù)據(jù) msg = MsgBox(您確實(shí)要修改這條數(shù)據(jù)嗎?, vbYesNo) If msg = vbYes Then For Index = 0 To 2 If txtItem(Index).Text Then (Index) = txtItem(Index).Text txtItem(Index).Enabled = False End If Next Index Else Exit Sub End If ElseIf flag = Add Then 39。設(shè)置標(biāo)志flag flag = Add 39。在文本框中顯示數(shù)據(jù) 39。移到第一條記錄 If Not Then Case Is = 1 39。查詢SQL語(yǔ)句 If flag = Add And 0 Then MsgBox (該宿舍的信息已經(jīng)存在,重復(fù)添加!) Checkdata = False Exit Function End If Checkdata = True 39。 amp。檢查數(shù)據(jù)的合法性 Dim rsts As New Dim xb As New Dim msgt As String Dim gs As String gs = select 宿舍號(hào) from 宿舍信息表 Set xb = SelectSQL(gs) msgt = 39。所有移動(dòng)控件可用 For Index = 0 To 3 CmdMove(Index).Enabled = True Next Index 39。 (宿舍號(hào)) amp。 (學(xué)號(hào)) amp。清空文本框、并不可用