【正文】
個 ADODC Data 控件( Adodc),用來與數(shù)據(jù)庫進行連接。這些控件的屬性設(shè)置如下表所示: 控件 屬性 屬性值 TextBox Name UserName TextBox Name PassWord PassWordChar * CommandButton Name cmdOK Caption 確定 CommandButton Name cmdCancel Private Sub ChangePWD_Click() End Sub Caption 取消 控件 屬性 屬性值 Label Caption 用戶名稱 Label Caption 用戶密碼 Adodc ConnectionString 連接“ 高校工資管理系統(tǒng) .mdb”,記錄源為“用戶信息表” 表 8 控件屬性表 3. 添加代碼 輸入用戶名稱和用戶密碼后 ,單擊“確定 ” 按鈕后,進入系統(tǒng),代碼如下: Private Sub cmdOK_Click() On Error GoTo errorhandle Dim finduser As Boolean finduser = False 39。將記錄指針移動到首記錄 If Trim( = ) Then MsgBox 請輸入用戶名稱! , vbOKOnly + vbExclamation, 警告 Exit Sub Else Do While Not 39。判斷數(shù)據(jù)表是否已經(jīng)讀完 ,即遍歷整張表 If ( 用 戶 名 稱 ) = Trim() Then 39。field 就是某個字段 finduser = True If (用戶密碼 ) = Trim() Then strUserName = Trim() 39。保存用戶名稱 Unload Me Else MsgBox 密碼不正確,請重新輸入! , vbOKOnly + vbExclamation, 警告 = End If End If 39。記錄往下移動一條 Loop If finduser = False Then MsgBox 沒有這個用戶,請重新輸入! , vbOKOnly + vbExclamation, 警告 = End If End If Exit Sub 單擊“取消”按鈕,退出修改密碼窗體,代碼如下: 建立 教師基本 工資 設(shè)置 窗體 添加一個普通窗體 ,caption 屬性設(shè)置基本工資設(shè)置 ,其窗體運行效果如下 : 其窗體命令按鈕的增加 ,刪除 ,修改 ,保存的源碼分析如下 : Private Sub cmdCancel_Click() Unload Me Exit Sub End Sub 添加 : Private Sub Command1_Click() Text1(0).SetFocus = False = False = False = True 39。 = True End Sub 刪除 : Private Sub Command2_Click() If MsgBox(確定刪除當前資料嗎 ?, vbInformation + vbYesNo, 刪除資 料 ?) = vbYes Then End If End Sub 修改 : Private Sub Command3_Click() = False = False = False = True 39。 = True End Sub 保存按鈕 : Private Sub Command4_Click() For i = 0 To 11 If Text1(i) = Then MsgBox 輸入不完整! , vbOKOnly + vbExclamation, 警告 Text1(i).SetFocus Exit Sub End If Next i If MsgBox(確定保存當前資料嗎 ?, vbInformation + vbYesNo, 保存資料 ?) = vbYes Then End If = True = True = True = False 39。 = True = True End Sub 建立 考勤信息統(tǒng)計窗體 添加一個普通窗體, Caption 屬性設(shè)為“ 教師考勤信息統(tǒng)計 ”, Name 屬性設(shè)為“ frmAttInfo”。 其窗體屬性設(shè)置如下 : 控件 屬性 屬性值 DataGrid1 DataSource Adodc1 DataGrid2 DataSource Adodc2 Adodc1 ConnectionString 記錄源為“ 教師考勤信息 ” Adodc2 ConnectionString 記錄源為“教師考勤信 息 表” 其窗體運行圖如下 : 其命令按鈕的源碼設(shè)計參考教師基本工資設(shè)置窗體的按鈕源碼 . 建立 工資結(jié)算窗體 添加一個普通窗體, Caption屬性設(shè)為“工資 結(jié)算 ”, Name屬性設(shè)為“ frmJSalary”。 其運行效果圖如下 : 其工資的結(jié)算代碼如下 : Private Sub Command2_Click() 39。計算 39。 If Text4(2) = Then MsgBox 請輸入獎金金額 !, vbOKOnly + vbExclamation, 提示 Text4(2).SetFocus Else If Text4(3) = Then MsgBox 請輸入其他補助金額 !, vbOKOnly + vbExclamation, 提示 Text4(3).SetFocus Else Text4(11) = Date Dim GL As Integer GL = Val(Year(Date) Year(Label1(10).Caption)) 39。計算工齡 Label2(8).Caption = Val(Label2(11).Caption) * GL 39。計算工齡工資 Text4(1).Text = Val(Label2(12).Caption) * Val(Label3(10).Caption) 39。計算加班工資 Text4(4).Text = Val(Label2(15).Caption) * Val(Label3(11).Caption) 39。計算遲到扣款 Text4(5).Text = Val(Label2(13).Caption) * Val(Label3(9).Caption) 39。計算病假扣款 Text4(6).Text = Val(Label2(14).Caption) * Val(Label3(8).Caption) 39。計算事假扣款 Text4(0).Text = Val(Text4(4).Text) + Val(Text4(5).Text) + Val(Text4(6).Text) 39。計算考勤扣款 Dim money As Integer 39。應(yīng)發(fā)金額 money = Val(Label2(9).Caption) + Val(Label2(10).Caption) + Val(Label2(8).Caption) _ + Val(Text4(1).Text) + Val(Text4(2).Text) + Val(Text4(3).Text) Val(Text4(0).Text) Val(Text4(7).Text) 39。計算個人所得稅 If money = 800 Then Text4(8).Text = 0 Else If (money 800) = 500 Then Text4(8).Text = (money 800) * Else If (money 800) 500 And (money 800) = 2021 Then Text4(8).Text = (money 800) * Else If (money 800) 2021 And (money 800) = Then Text4(8).Text = (money 800) * Else If (money 800) 5000 And (money 800) = 20210 Then Text4(8).Text = (money 800) * End If End If End If End If End If End If End If 39。計算實發(fā)金額 Text4(9).Text = money Val(Text4(8).Text) 39。計算基本工資額 ,包括職務(wù)津貼、基本工資、工齡工資 JBGZE = Val(Label2(10).Caption) + Val(Label2(9).Caption) + Val(Label2(8).Caption) 39。計算本月補助,包括加班工資、獎金、其他補助 BYBZ = Val(Text4(1).Text) + Val(Text4(2).Text) + Val(Text4(3).Text) 39。計算其他扣款,包括違紀罰款和個人所得稅 QTKK = Val(Text4(7).Text) + Val(Text4(0).Text) End Sub 固定工資調(diào)整窗體的設(shè)計 其窗體控件以及控件的屬性設(shè)置不 再重復(fù)描述 ,重點描述確定按鈕的源碼如下 : Private Sub Command1_Click() On Error GoTo errorhandle Dim m As Integer If = 基本工資 Then m = 1 If = 職務(wù)津貼 Then m = 2 If = 工齡津貼 /年 Then m = 3 If = 加班工資 /天 Then m = 4 If = 事 假扣款 /天 Then m = 5 If = 病假扣款 /天 Then m = 6 If = 遲到扣款 /天 Then m = 7 If = Then MsgBox 請選擇需調(diào)整的工資項目! , vbOKOnly + vbExclamation, 提示 Else If = Then MsgBox 請選擇調(diào)整的條件! , vbOKOnly + vbExclamation, 提示 Else If = Then MsgBox 請輸入調(diào)整值! , vbOKOnly + vbExclamation, 提示 Exit Sub End If 39。 Else 39。 If = 部門 Then 39。 = select * from 職工工資明細表 where 所屬部門 =39。 amp。 amp。 39。 39。 Call selectJS(m) 39。 Else 39。 If = 職務(wù) Then 39。 = select * from 職工工資明