




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、PAGE PAGE 56“人力資源管理系統(tǒng)”項(xiàng)目開發(fā)實(shí)訓(xùn)說(shuō)明一 項(xiàng)目開發(fā)實(shí)訓(xùn)進(jìn)度說(shuō)明2學(xué)時(shí)課要完成的任務(wù):完成主界面的設(shè)計(jì);數(shù)據(jù)庫(kù)類DataBase的定義和使用;登陸界面的設(shè)計(jì)1)主界面設(shè)計(jì)如圖2)數(shù)據(jù)庫(kù)類Database的定義和使用說(shuō)明:因?yàn)楦鱾€(gè)窗體均需要對(duì)數(shù)據(jù)庫(kù)進(jìn)行訪問(wèn),可以把對(duì)數(shù)據(jù)庫(kù)的一些操作通過(guò)一個(gè)類來(lái)實(shí)現(xiàn),這樣可以使對(duì)數(shù)據(jù)庫(kù)的訪問(wèn)更加簡(jiǎn)單。類的定義請(qǐng)參考相應(yīng)截圖和代碼類的定義Imports System.DataImports System.Data.OleDbImportsSystem.ComponentModelPublicClass DataBaseImplements IDi
2、sposable 實(shí)現(xiàn)接口IDisposable,主要用來(lái)“顯示釋放資源”Private OledbConn As OleDbConnection 數(shù)據(jù)庫(kù)連接對(duì)象Private trans As OleDbTransaction 事務(wù)處理對(duì)象Dim OledbComm As OleDbCommandPublicShared sConn AsString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=hrmbook.mdb;Persist Security Info=FalsePrivate disposedValue AsBoolean = Fa
3、lse 檢測(cè)冗余的調(diào)用ProtectedOverridableSub Dispose(ByVal disposing AsBoolean)IfNotMe.disposedValue ThenIf disposing Then TODO: 顯式調(diào)用時(shí)釋放非托管資源If OledbConn IsNothing = FalseThen OledbConn.Dispose() OledbConn = NothingEndIfEndIf TODO: 釋放共享的非托管資源EndIfMe.disposedValue = True本部分代碼自動(dòng)添加的EndSub本部分代碼自動(dòng)添加的#Region IDispo
4、sable Support Visual Basic 添加此代碼是為了正確實(shí)現(xiàn)可處置模式。PublicSub Dispose() Implements IDisposable.Dispose 不要更改此代碼。請(qǐng)將清理代碼放入上面的 Dispose(ByVal disposing As Boolean) 中。 Dispose(True) GC.SuppressFinalize(Me)EndSub#EndRegionPublicSub Open()If OledbConn IsNothing = TrueThen建立數(shù)據(jù)庫(kù)連接對(duì)象 OledbConn = New OleDbConnection(s
5、Conn) me.sConn打開數(shù)據(jù)庫(kù)連接 OledbConn.Open()EndIfEndSubPublicSub Close()如果數(shù)據(jù)庫(kù)連接對(duì)象不為空則關(guān)閉數(shù)據(jù)庫(kù)連接If OledbConn IsNothing = FalseThen OledbConn.Close()EndIfEndSubPublicFunction RunSelectSQL(ByVal sSQLString As System.String) As DataView本過(guò)程的功能:對(duì)數(shù)據(jù)庫(kù)的操作【按條件選擇合適的記錄】Me.Open()Dim OledbDS As DataSet = New DataSetDim Ol
6、edbDA As OleDbDataAdapter = New OleDbDataAdapter(sSQLString, Me.OledbConn) OledbDA.Fill(OledbDS)Return OledbDS.Tables(0).DefaultViewEndFunctionPublicSub RunDelOrInsSQL(ByVal sSQLString As System.String)本過(guò)程的功能:對(duì)數(shù)據(jù)庫(kù)的操作【執(zhí)行刪除或插入操作】Me.Open()Dim OledbComm As OleDbCommand = New OleDbCommand(sSQLString,Me.O
7、ledbConn) OledbComm.ExecuteNonQuery()EndSubPublicSub RunMulDelOrInsSQL(ByVal arr As ArrayList)本過(guò)程的功能:對(duì)數(shù)據(jù)庫(kù)的操作【批量的執(zhí)行刪除或插入操作,用到了事物處理的作用】Me.Open() trans = OledbConn.BeginTransactionDim i AsIntegerTryFor i = 0 To arr.Count - 1 OledbComm = New OleDbCommand(arr(i), Me.OledbConn) OledbComm.Transaction = tra
8、ns OledbComm.ExecuteNonQuery()Next i trans.Commit()Catch ex As Exception trans.Rollback()ThrowNew ExceptionEndTryEndSubPublicFunction getResult(ByVal strSql AsString) As OleDbDataReader本過(guò)程的功能:對(duì)數(shù)據(jù)庫(kù)的操作【按條件讀出合適的記錄】Me.Open() OledbComm = New OleDbCommand(strSql, Me.OledbConn)Dim dr As OleDbDataReader = O
9、ledbComm.ExecuteReader()Return drEndFunctionEndClassDataBase類截圖DataBase類截圖DataBase類截圖DataBase類截圖事務(wù)是作為包執(zhí)行的一組數(shù)據(jù)庫(kù)命令。利用事務(wù),您的應(yīng)用程序?qū)⒛軌蛟谑聞?wù)進(jìn)程中的任何部分出現(xiàn)任何錯(cuò)誤時(shí)中止(回滾)所有已在事務(wù)中執(zhí)行的更改。例如,假設(shè)某個(gè)應(yīng)用程序具有兩個(gè)表,其中一個(gè)表示庫(kù)存清單,而另一個(gè)表示訂單。當(dāng)向一個(gè)表添加訂單時(shí),需要在另一個(gè)表中減少相應(yīng)的庫(kù)存。如果對(duì)訂單表的更新成功但對(duì)庫(kù)存清單表的更新失敗,則將損壞數(shù)據(jù)的完整性。為了確保兩個(gè)表都成功進(jìn)行更新,可以將兩個(gè)數(shù)據(jù)命令都打包到一個(gè)事務(wù)中。如果一
10、個(gè)表成功更新而另一個(gè)表未成功更新,則可以回滾整個(gè)事務(wù),解決導(dǎo)致失敗的問(wèn)題,然后重試該事務(wù)。3)登陸界面設(shè)計(jì)及相應(yīng)代碼附主界面代碼以及代碼截圖:(要把啟動(dòng)對(duì)象設(shè)置為Sub Main)PublicClass frmMainPublicSharedSubMain()Dim frml AsNew frmLogin frml.ShowDialog() 先顯示登陸界面窗體,用戶編號(hào),密碼等信息正確才允許顯示主界面If frml.bResult ThenDim fm AsNew frmMain fm.ShowDialog()EndIfEndSubPrivateFunction GetInstanceStat
11、e(ByVal name AsString) AsBoolean本過(guò)程功能是判斷某子窗體是否已存在Dim i AsInteger = Me.MdiChildren.LengthFor i = 0 ToMe.MdiChildren.Length - 1IfMe.MdiChildren(i).Name = name ThenMe.MdiChildren(i).Focus()ReturnTrueEndIfNextReturnFalseEndFunction“機(jī)構(gòu)編制管理(&X)”菜單下的三子菜單1)“機(jī)構(gòu)設(shè)置及編碼”對(duì)應(yīng)菜單的Name屬性值:機(jī)構(gòu)設(shè)置及編碼ToolStripMenuItem2)“機(jī)構(gòu)
12、詳細(xì)信息”對(duì)應(yīng)菜單的Name屬性值:機(jī)構(gòu)詳細(xì)信息ToolStripMenuItem3)“退出”對(duì)應(yīng)菜單的Name屬性值:退出ToolStripMenuItemPrivateSub機(jī)構(gòu)設(shè)置及編碼ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles機(jī)構(gòu)設(shè)置及編碼ToolStripMenuItem.ClickIf GetInstanceState(frmDepManage) ThenExitSubEndIf frmDepManage.MdiParent = MefrmDe
13、pManage是“機(jī)構(gòu)設(shè)置及編碼”模塊窗體的Name屬性值 frmDepManage.Show()EndSubPrivateSub機(jī)構(gòu)詳細(xì)信息ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles機(jī)構(gòu)詳細(xì)信息ToolStripMenuItem.ClickIf GetInstanceState(frmDepInfo) ThenExitSubEndIfDim childFrm AsNew frmDepInfo frmDepInfo是“機(jī)構(gòu)詳細(xì)信息”模塊窗體的Name屬性值
14、 childFrm.MdiParent = Me childFrm.Show()EndSubPrivateSub退出ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles退出ToolStripMenuItem.Click Application.Exit()EndSub“人員信息管理(&Y)”菜單下的二子菜單1)“職員信息維護(hù)”對(duì)應(yīng)菜單的Name屬性值:職員信息維護(hù)ToolStripMenuItem2)“職員信息查詢”對(duì)應(yīng)菜單的Name屬性值:職員信息查詢ToolSt
15、ripMenuItemPrivateSub職員信息維護(hù)ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles職員信息維護(hù)ToolStripMenuItem.ClickIf GetInstanceState(frmPeopleManage) ThenExitSubEndIfDim childFrm AsNew frmPeopleManage frmPeopleManage是“職員信息維護(hù)”模塊窗體的Name屬性值 childFrm.MdiParent = Me chil
16、dFrm.Show()EndSubPrivateSub職員信息查詢ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles職員信息查詢ToolStripMenuItem.ClickIf GetInstanceState(frmPeopleQuery) ThenExitSubEndIfDim childFrm AsNew frmPeopleQuery frmPeopleQuery是“職員信息查詢”模塊窗體的Name屬性值 childFrm.MdiParent = Me c
17、hildFrm.Show()EndSub薪資福利管理(&Z)菜單下的四子菜單1)“當(dāng)月工資管理”對(duì)應(yīng)菜單的Name屬性值:當(dāng)月工資管理ToolStripMenuItem2)“工資發(fā)放歷史”對(duì)應(yīng)菜單的Name屬性值:工資發(fā)放歷史ToolStripMenuItem3)“職員獎(jiǎng)勵(lì)管理”對(duì)應(yīng)菜單的Name屬性值:職員獎(jiǎng)勵(lì)管理ToolStripMenuItem3)“職員懲罰管理”對(duì)應(yīng)菜單的Name屬性值:職員懲罰管理ToolStripMenuItemPrivateSub當(dāng)月工資管理ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e
18、 As System.EventArgs) Handles當(dāng)月工資管理ToolStripMenuItem.ClickIf GetInstanceState(frmSalaryManage) ThenExitSubEndIfDim childFrm AsNew frmSalaryManage frmSalaryManage是“當(dāng)月工資管理”模塊窗體的Name屬性值 childFrm.MdiParent = Me childFrm.Show()EndSubPrivateSub工資發(fā)放歷史ToolStripMenuItem_Click(ByVal sender As System.Object, B
19、yVal e As System.EventArgs) Handles工資發(fā)放歷史ToolStripMenuItem.ClickIf GetInstanceState(frmSalaryHis) ThenExitSubEndIfDim childFrm AsNew frmSalaryHis frmSalaryHis是“工資發(fā)放歷史”模塊窗體的Name屬性值 childFrm.MdiParent = Me childFrm.Show()EndSubPrivateSub職員獎(jiǎng)勵(lì)管理ToolStripMenuItem_Click(ByVal sender As System.Object, ByVa
20、l e As System.EventArgs) Handles職員獎(jiǎng)勵(lì)管理ToolStripMenuItem.ClickIf GetInstanceState(frmPrize) ThenExitSubEndIfDim childFrm AsNew frmPrize frmPrize是“職員獎(jiǎng)勵(lì)管理”模塊窗體的Name屬性值 childFrm.MdiParent = Me childFrm.Show()EndSubPrivateSub職員懲罰管理ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.E
21、ventArgs) Handles職員懲罰管理ToolStripMenuItem.ClickIf GetInstanceState(frmPunishInfo) ThenExitSubEndIfDim childFrm AsNew frmPunishInfo frmPunishInfo是“職員懲罰管理”模塊窗體的Name屬性值 childFrm.MdiParent = Me childFrm.Show()EndSubEndClass附數(shù)據(jù)庫(kù)介紹本系統(tǒng)的數(shù)據(jù)庫(kù)描述如下:(注意表間關(guān)系的建立,請(qǐng)看提供的數(shù)據(jù)庫(kù)文件hrmbook.mdb,同學(xué)們可直接使用)數(shù)據(jù)庫(kù)表(7張表)用戶清單表字段名字段類型是
22、否主鍵用戶編號(hào)文本是部門文本否姓名文本否性別文本否密碼文本否組織機(jī)構(gòu)編碼表字段名字段類型是否主鍵說(shuō)明內(nèi)部編號(hào)自動(dòng)編號(hào)否類別文本否AbsIndex數(shù)字否記錄總機(jī)構(gòu)中索引ItemIndex數(shù)字否記錄在同級(jí)結(jié)構(gòu)中的索引ItemLevel數(shù)字否記錄是第幾個(gè)級(jí)別ParentIndex數(shù)字否記錄的上級(jí)結(jié)構(gòu)中索引類別號(hào)文本否單位編號(hào)文本是單位名稱文本否拼音編碼文本否單位地址文本否單位電話號(hào)碼文本否開戶銀行文本否帳號(hào)文本否開戶全稱文本否職員基本信息表字段名字段類型是否主鍵內(nèi)部編號(hào)自動(dòng)編號(hào)否職員編號(hào)文本是姓名文本否姓名簡(jiǎn)碼文本否性別文本否出生日期數(shù)字否年齡數(shù)字否籍貫文本否民族文本否文化程度文本否畢業(yè)學(xué)校文本否健
23、康狀況文本否婚姻狀況文本否身份證號(hào)碼文本否家庭電話文本否辦公電話文本否手機(jī)文本否電子郵件地址文本否職工賬號(hào)文本否單位編號(hào)文本否備注文本否月工資統(tǒng)計(jì)表字段名字段類型是否主鍵日期數(shù)字否職員編號(hào)文本是基本工資數(shù)字否浮動(dòng)工資數(shù)字否合同補(bǔ)數(shù)字否糧副補(bǔ)數(shù)字否房補(bǔ)數(shù)字否臨時(shí)補(bǔ)數(shù)字否職務(wù)工資數(shù)字否工齡工資數(shù)字否考核工資數(shù)字否獎(jiǎng)金數(shù)字否應(yīng)發(fā)金額合計(jì)數(shù)字否房租數(shù)字否水電費(fèi)數(shù)字否請(qǐng)假扣除數(shù)字否考勤扣除數(shù)字否罰款數(shù)字否住房公積金數(shù)字否醫(yī)療保險(xiǎn)數(shù)字否養(yǎng)老保險(xiǎn)數(shù)字否失業(yè)保險(xiǎn)數(shù)字否生育保險(xiǎn)數(shù)字否工傷保險(xiǎn)數(shù)字否應(yīng)扣金額合計(jì)數(shù)字否工資合計(jì)數(shù)字否個(gè)人所得稅數(shù)字否實(shí)發(fā)金額數(shù)字否發(fā)放否文本否月份數(shù)字否工資發(fā)放歷史表字段名字段類型是否
24、主鍵日期數(shù)字否職員編號(hào)文本是基本工資數(shù)字否浮動(dòng)工資數(shù)字否合同補(bǔ)數(shù)字否糧副補(bǔ)數(shù)字否房補(bǔ)數(shù)字否臨時(shí)補(bǔ)數(shù)字否職務(wù)工資數(shù)字否工齡工資數(shù)字否考核工資數(shù)字否獎(jiǎng)金數(shù)字否應(yīng)發(fā)金額合計(jì)數(shù)字否房租數(shù)字否水電費(fèi)數(shù)字否請(qǐng)假扣除數(shù)字否考勤扣除數(shù)字否罰款數(shù)字否住房公積金數(shù)字否醫(yī)療保險(xiǎn)數(shù)字否養(yǎng)老保險(xiǎn)數(shù)字否失業(yè)保險(xiǎn)數(shù)字否生育保險(xiǎn)數(shù)字否工傷保險(xiǎn)數(shù)字否應(yīng)扣金額合計(jì)數(shù)字否工資合計(jì)數(shù)字否個(gè)人所得稅數(shù)字否實(shí)發(fā)金額數(shù)字否發(fā)放否文本否月份數(shù)字否職員懲罰表字段名字段類型是否主鍵序號(hào)自動(dòng)編號(hào)是職員編號(hào)文本否懲罰類型文本否懲罰金額數(shù)字否是否計(jì)入工資文本否懲罰原因文本否部門意見(jiàn)文本否懲罰日期數(shù)字否職員獎(jiǎng)勵(lì)表字段名字段類型是否主鍵序號(hào)自動(dòng)編號(hào)是職員
25、編號(hào)文本否獎(jiǎng)勵(lì)類型文本否獎(jiǎng)勵(lì)金額數(shù)字否是否計(jì)入工資文本否獎(jiǎng)勵(lì)原因文本否部門意見(jiàn)文本否獎(jiǎng)勵(lì)日期數(shù)字否注意:添加代碼時(shí)要注意有些代碼是有聯(lián)系的,比如,某過(guò)程可能調(diào)用其它過(guò)程。那么被調(diào)過(guò)程寫好后,主調(diào)過(guò)程調(diào)用時(shí)才是正確的。否則說(shuō)某某過(guò)程沒(méi)有聲明。2學(xué)時(shí)課要完成的任務(wù)“機(jī)構(gòu)編制管理(&X)”菜單下的二子菜單“機(jī)構(gòu)設(shè)置及編碼”窗體模塊frmDepManage的實(shí)現(xiàn)“機(jī)構(gòu)詳細(xì)信息”frmDepInfo窗體模塊的實(shí)現(xiàn)1)“機(jī)構(gòu)設(shè)置及編碼”窗體frmDepManage設(shè)計(jì)、代碼及運(yùn)行界面。其主要功能為:實(shí)現(xiàn)設(shè)置機(jī)構(gòu)的層次關(guān)系【把數(shù)據(jù)庫(kù)里的組織機(jī)構(gòu)在TreeView控件里顯示成層次關(guān)系】。PublicClass
26、 frmDepManagePrivate dvList As DataViewPrivateSub InitTree(ByRef nodes As TreeNodeCollection, ByVal sParentIndex AsString)TryDim tmpNode As TreeNodeDim absIndex AsStringDim dvTemp As DataView = dvList.Table.DefaultView選出數(shù)據(jù)源中ParentIndex為sParentIndex的數(shù)據(jù)行Dim dataRows() As DataRow = dvList.Table.Select(
27、ParentIndex= & sParentIndex & )循環(huán)添加TreeNodeForEach dr As DataRow In dataRows獲得節(jié)點(diǎn)所需數(shù)據(jù) tmpNode = New TreeNode tmpNode.Text = dr(類別) absIndex=dr(AbsIndex)添加節(jié)點(diǎn) nodes.Add(tmpNode)遞歸調(diào)用 InitTree(nodes(nodes.Count - 1).Nodes, absIndex)NextCatch ex As Exception MessageBox.Show(初始化TreeViews失敗)EndTryEndSubPriv
28、ateSub frmDepManage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.LoadDim db AsNew DataBaseDim strSQL AsString strSQL = select * from 組織機(jī)構(gòu)編碼表 order by absIndex dvList = db.RunSelectSQL(strSQL) db.Dispose() InitTree(trvList.Nodes, -1)EndSubEndClass2)“機(jī)構(gòu)詳細(xì)信息”窗體frmDepIn
29、fo設(shè)計(jì)、相應(yīng)代碼及運(yùn)行界面其功能主要是維護(hù)組織機(jī)構(gòu)的信息【比如:修改某信息后,點(diǎn)保存按鈕保存到數(shù)據(jù)庫(kù)】DataGridView控件DataGridView控件注意:用代碼綁定DataGridView控件【dgvDepInfo.DataSource=dt.DefaultView】2學(xué)時(shí)課要完成的任務(wù)“人員信息管理(&Y)”菜單下的二子菜單“職員信息維護(hù)”窗體模塊frmPeopleManage的實(shí)現(xiàn)“職員信息查詢”窗體模塊frmPeopleQuery的實(shí)現(xiàn)1)“職員信息維護(hù)”窗體模塊frmPeopleManage的設(shè)計(jì)、運(yùn)行界面及代碼其主要功能是用于輸入和修改職員的資料代碼如下:相應(yīng)文本框控件和
30、相應(yīng)字段綁定,DataGridView控件用代碼綁定PublicClass frmPeopleManagePrivate iCurrentLine AsInteger = -1PrivateSub SetDataGridView()Me.OleDbConnection1.ConnectionString = DataBase.sConnMe.OleDbDataAdapter1.Fill(Me.DataSet11)Dim dt As DataTable dt = Me.DataSet11.Tables(職員基本信息表)dt.DefaultView.AllowDelete = Falsedt.De
31、faultView.AllowNew = False dgvPeopleInfo.DataSource = dt.DefaultViewEndSubPrivateSub frmPeopleManage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.LoadMe.OleDbDataAdapter1.Fill(Me.DataSet11, 職員基本信息表)Dim db As DataBase = New DataBaseDim strSQL AsString = select 單位編號(hào) f
32、rom strSQL += 組織機(jī)構(gòu)編碼表 order by 單位編號(hào)Dim dv As DataView = db.RunSelectSQL(strSQL)ForEach drv As DataRowView In dvMe.cbbDepCode.Items.Add(drv(單位編號(hào))Next db.Dispose() SetDataGridView()顯示圖片,把綁定“Images”字段的TextBox18藏在圖片框Picturebox1控件的后面IfMe.TextBox18.Text.Trim.Length 0 ThenMe.PictureBox1.Image = Image.FromF
33、ile(Me.TextBox18.Text.Trim)ElseMe.PictureBox1.Image = NothingEndIfEndSubPrivateSub dgvPeopleInfo_CellClick(ByVal sender AsObject, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvPeopleInfo.CellClickTry BindingContext(Me.DataSet11, 職員基本信息表).ResumeBinding()If iCurrentLine = -1 Or
34、 iCurrentLine dgvPeopleInfo.CurrentCell.RowIndex Then iCurrentLine = dgvPeopleInfo.CurrentCell.RowIndex BindingContext(Me.DataSet11, 職員基本信息表).Position = dgvPeopleInfo.CurrentCell.RowIndexEndIfIf dgvPeopleInfo.CurrentCell.RowIndex = Me.DataSet11.Tables(職員基本信息表).Rows.Count Then BindingContext(Me.DataS
35、et11, 職員基本信息表).SuspendBinding()EndIf顯示圖片,把綁定“Images”字段的TextBox18藏在圖片框Picturebox1控件的后面IfMe.TextBox18.Text.Trim.Length 0 ThenMe.PictureBox1.Image = Image.FromFile(Me.TextBox18.Text.Trim)ElseMe.PictureBox1.Image = NothingEndIfCatch ex As Exception MessageBox.Show(ex.Message)EndTryEndSubPrivateSub ToolS
36、trip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ToolStrip1.ItemClickedIf e.ClickedItem IsMe.tbbSave ThenDim row AsInteger row = dgvPeopleInfo.CurrentCell.RowIndex dgvPeopleInfo.CurrentCell = dgvPeopleInfo.Rows(row + 1).Cells(0)
37、BindingContext(Me.DataSet11, 職員基本信息表).Position = dgvPeopleInfo.CurrentCell.RowIndexTryIfMe.DataSet11.HasChanges ThenMe.OleDbDataAdapter1.Update(Me.DataSet11)Me.DataSet11.Tables(職員基本信息表).DefaultView.RowFilter = dgvPeopleInfo.CurrentCell = dgvPeopleInfo.Rows(row).Cells(0) MessageBox.Show(數(shù)據(jù)修改成功!)Else
38、dgvPeopleInfo.CurrentCell = dgvPeopleInfo.Rows(row).Cells(0) MessageBox.Show(無(wú)修改的數(shù)據(jù)!)EndIfCatch ex As Exception MessageBox.Show(修改的數(shù)據(jù)出錯(cuò)!)EndTryElseIf e.ClickedItem IsMe.tbbDel ThenTryDim iRow AsInteger iRow = dgvPeopleInfo.CurrentCell.RowIndexIf MessageBox.Show(確認(rèn)要?jiǎng)h除此條記錄嗎?, Confirm, MessageBoxButton
39、s.YesNo) = Windows.Forms.DialogResult.Yes ThenMe.DataSet11.Tables(職員基本信息表).Rows(iRow).Delete()ElseExitSubEndIfTryIfMe.DataSet11.HasChanges ThenMe.DataSet11.AcceptChanges()Me.OleDbDataAdapter1.Update(Me.DataSet11, 職員基本信息表) MessageBox.Show(數(shù)據(jù)刪除成功!)Else MessageBox.Show(無(wú)修改的數(shù)據(jù)!)EndIfCatch ex As Exceptio
40、n MessageBox.Show(刪除數(shù)據(jù)出錯(cuò)1! & ex.Message)EndTryCatch ex As Exception MessageBox.Show(刪除數(shù)據(jù)出錯(cuò)2!)EndTryEndIfEndSubPrivateSub cbbDepCode_TextChanged(ByVal sender AsObject, ByVal e As System.EventArgs) Handles cbbDepCode.TextChangedDim db As DataBase = New DataBaseDim strSQL AsString = select 單位名稱 from st
41、rSQL += 組織機(jī)構(gòu)編碼表 where 單位編號(hào)= strSQL += Me.cbbDepCode.Text.Trim + Dim dv As DataView = db.RunSelectSQL(strSQL)If dv.Table.Rows.Count 0 ThenMe.TextBox16.Text = dv.Table.Rows(0)(0)ElseMe.TextBox16.Text = EndIfEndSubEndClass2)“職員信息查詢”窗體模塊frmPeopleQuery的設(shè)計(jì)、運(yùn)行界面及代碼其主要功能是查詢職員的資料,但不能修改職員的信息。4學(xué)時(shí)課要完成的任務(wù)薪資福利管理(
42、&Z)菜單下的四子菜單第1次課要完成的任務(wù):“當(dāng)月工資管理”窗體模塊功能的實(shí)現(xiàn)“工資發(fā)放歷史”窗體模塊功能的實(shí)現(xiàn)第2次課要完成的任務(wù):“職員獎(jiǎng)勵(lì)管理”窗體模塊功能的實(shí)現(xiàn)“職員懲罰管理”窗體模塊功能的實(shí)現(xiàn)第1次課要完成的任務(wù)2學(xué)時(shí)1)“當(dāng)月工資管理”窗體frmSalaryManage的設(shè)計(jì)、運(yùn)行界面和代碼其主要功能是計(jì)算當(dāng)月工資和工資發(fā)放其代碼如下:PublicClass frmSalaryManagePrivate dvMaster As DataViewPrivate iCurrentLine AsInteger = -1PrivateSub LoadData()Dim strSQL AsS
43、tring = select 姓名,日期,應(yīng)發(fā)金額合計(jì),應(yīng)扣金額合計(jì), strSQL += 工資合計(jì),個(gè)人所得稅,實(shí)發(fā)金額,發(fā)放否,a.職員編號(hào) strSQL += from 職員基本信息表 as a,月工資統(tǒng)計(jì)表 as b strSQL += where a.職員編號(hào)=b.職員編號(hào) order by 內(nèi)部編號(hào)Dim db As DataBase = New DataBase dvMaster = db.RunSelectSQL(strSQL) dvMaster.AllowDelete = False dvMaster.AllowNew = False dvMaster.AllowEdit =
44、 False dgvSalaryInfo.DataSource = dvMaster控制某列的列寬For i AsInteger = 0 To 8根據(jù)內(nèi)容調(diào)整列寬Me.dgvSalaryInfo.Columns(i).AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsNext控制某列是否可以點(diǎn)列標(biāo)題進(jìn)行排序For i AsInteger = 0 To 8不可以點(diǎn)列標(biāo)題進(jìn)行排序,只能靠編程Me.dgvSalaryInfo.Columns(i).SortMode = DataGridViewColumnSortMode.NotSortabl
45、eNext db.Dispose()Me.OleDbConnection1.ConnectionString = DataBase.sConnMe.OleDbDataAdapter1.Fill(Me.DataSet11, 月工資統(tǒng)計(jì)表)EndSubPrivateSub frmSalaryManage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load把新職工信息插入到工資統(tǒng)計(jì)表中Dim strSQL AsString = insert into 月工資統(tǒng)計(jì)表(職員編號(hào)) sele
46、ct 職員編號(hào) from 職員基本信息表 as h where h.職員編號(hào) not in (select 職員編號(hào) from 月工資統(tǒng)計(jì)表)Dim db As DataBase = New DataBase db.RunDelOrInsSQL(strSQL) db.Dispose() LoadData()EndSubPrivateSub btnCalSalary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalSalary.ClickIfMe.txbNowSalary.Text.T
47、rim.Length 6 Then MessageBox.Show(請(qǐng)輸入正確的年月數(shù)據(jù),比如:200903,2009表示2009年,03表示3月份)ExitSubEndIfDim month AsInteger = Convert.ToInt32(Me.txbNowSalary.Text.Trim)Dim db As DataBase = New DataBaseDim arr As ArrayList = New ArrayListDim strSQL AsString = select sum(獎(jiǎng)勵(lì)金額) as 獎(jiǎng)金,i.職員編號(hào) as 職員編號(hào) from 職員獎(jiǎng)勵(lì)表 as i wher
48、e i.是否計(jì)入工資=是 and i.獎(jiǎng)勵(lì)日期 + Convert.ToString(month * 100) + and i.獎(jiǎng)勵(lì)日期 + Convert.ToString(month * 100) + and i.懲罰日期 + Convert.ToString(month + 1) * 100) + group by i.職員編號(hào) dr = db.getResult(strSQL)While (dr.Read()Dim jine AsString = dr.GetDouble(0)Dim id AsString = dr.GetString(1) strSQL = update 月工資統(tǒng)計(jì)
49、表 set 罰款= + jine.ToString() + where 職員編號(hào)= & id & and 日期= & month arr.Add(strSQL)EndWhile dr.Close() strSQL = update 月工資統(tǒng)計(jì)表 set 罰款=0 where 罰款 is null & arr.Add(strSQL) strSQL = update 月工資統(tǒng)計(jì)表 set 應(yīng)扣金額合計(jì) = 房租 + 水電費(fèi) + 請(qǐng)假扣除 + 罰款 + 考勤扣除 + 住房公積金 + 醫(yī)療保險(xiǎn) + 養(yǎng)老保險(xiǎn) + 失業(yè)保險(xiǎn) arr.Add(strSQL) strSQL = update 月工資統(tǒng)計(jì)表 s
50、et 應(yīng)發(fā)金額合計(jì) = 基本工資 + 浮動(dòng)工資 + 合同補(bǔ) + 糧副補(bǔ) + 房補(bǔ) + 臨時(shí)補(bǔ)+職務(wù)工資+工齡工資+ 考核工資+ 獎(jiǎng)金 arr.Add(strSQL) strSQL = update 月工資統(tǒng)計(jì)表 set 工資合計(jì) = 應(yīng)發(fā)金額合計(jì) - 應(yīng)扣金額合計(jì) arr.Add(strSQL) strSQL = update 月工資統(tǒng)計(jì)表 set 實(shí)發(fā)金額 = 工資合計(jì) arr.Add(strSQL) db.RunMulDelOrInsSQL(arr) db.Dispose()重新加載數(shù)據(jù) LoadData() MsgBox(當(dāng)月工資計(jì)算完畢,可以發(fā)放了!)EndSubPrivateSub
51、dgvSalaryInfo_CellClick(ByVal sender AsObject, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvSalaryInfo.CellClickIf iCurrentLine = -1 Or iCurrentLine dgvSalaryInfo.CurrentCell.RowIndex Then iCurrentLine = dgvSalaryInfo.CurrentCell.RowIndex BindingContext(Me.DataSet11, 月工資統(tǒng)計(jì)表)
52、.Position = dgvSalaryInfo.CurrentCell.RowIndexEndIfEndSubPrivateSub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.ClickDim row AsIntegerTry row = Me.dgvSalaryInfo.CurrentCell.RowIndexMe.dgvSalaryInfo.CurrentCell = dgvSalaryInfo.Rows(row +
53、 1) Mod dvMaster.Table.Rows.Count).Cells(0)保證要修改或錄入的記錄完畢(位置改變,意味該記錄錄入完畢) BindingContext(Me.DataSet11, 月工資統(tǒng)計(jì)表).Position = dgvSalaryInfo.CurrentCell.RowIndexIfMe.DataSet11.HasChanges(DataRowState.Modified) ThenMsgBox(修改記錄)Me.OleDbDataAdapter1.Update(Me.DataSet11)Me.DataSet11.Tables(月工資統(tǒng)計(jì)表).DefaultView
54、.RowFilter = Me.dgvSalaryInfo.CurrentCell = Me.dgvSalaryInfo.Rows(row).Cells(0) LoadData() MessageBox.Show(修改成功)Else MessageBox.Show(無(wú)修改的數(shù)據(jù)!)EndIfCatch ex As ExceptionMe.dgvSalaryInfo.CurrentCell = Me.dgvSalaryInfo.Rows(row).Cells(0) MessageBox.Show(修改的數(shù)據(jù)出錯(cuò) & ex.Message)EndTryEndSubPrivateSub btnGiv
55、eSalary_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGiveSalary.ClickIf MessageBox.Show(是否發(fā)放?, Confirm, _ MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes ThenDim db As DataBase = New DataBaseDim id AsString = dvMaster.Table.Rows(dgvSalaryInfo.CurrentCell.Row
56、Index)(職員編號(hào))Dim arr As ArrayList = New ArrayListDim strSQL AsString = update 月工資統(tǒng)計(jì)表 set 發(fā)放否=是 where 職員編號(hào)= & id & arr.Add(strSQL) strSQL = insert into 工資發(fā)放歷史表 select * from 月工資統(tǒng)計(jì)表 where 職員編號(hào)= & id & arr.Add(strSQL) db.RunMulDelOrInsSQL(arr) LoadData()ElseExitSubEndIfEndSubEndClass2)“工資發(fā)放歷史”窗體frmSlary
57、His的設(shè)計(jì)、運(yùn)行界面和代碼其主要功能用于查詢職員歷史月份的工資其代碼如下:第2次課要完成的任務(wù)2學(xué)時(shí)1)“職員獎(jiǎng)勵(lì)管理”窗體frmPrize的設(shè)計(jì)、運(yùn)行界面和相應(yīng)代碼其主要功能用于設(shè)置職員的獎(jiǎng)勵(lì)信息其代碼如下:PublicClass frmPrizePrivateSub SetDataGridView()Me.OleDbConnection1.ConnectionString = DataBase.sConnMe.OleDbDataAdapter1.Fill(Me.DataSet11) dgvPrizeInfo.DataSource = Me.DataSet11.Tables(職員獎(jiǎng)勵(lì)表).
58、DefaultViewEndSubPrivateSub frmPrize_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load SetDataGridView()EndSubPrivateSub tsbSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbSave.ClickDim row AsInteger row = Me.dgvPrizeInfo.CurrentCel
59、l.RowIndexMe.dgvPrizeInfo.CurrentCell = Me.dgvPrizeInfo.Rows(row + 1).Cells(0)TryIfMe.DataSet11.HasChanges ThenMe.OleDbDataAdapter1.Update(Me.DataSet11)Me.DataSet11.Tables(職員獎(jiǎng)勵(lì)表).DefaultView.RowFilter = MessageBox.Show(數(shù)據(jù)修改成功!)Else MessageBox.Show(無(wú)修改的數(shù)據(jù)!)EndIfCatch ex As Exception MessageBox.Show(修改的數(shù)據(jù)出錯(cuò)! & ex.Message)EndTryEndSubPrivateSub tsbDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tsbDel.ClickTryDim row AsInteger row = Me.dgvPrizeInfo.CurrentCell.RowIndexIf MessageBox.Show(你確認(rèn)要?jiǎng)h除此條記錄嗎?, 確認(rèn), MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes The
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 九江理工職業(yè)學(xué)院《數(shù)據(jù)庫(kù)管理系統(tǒng)》2023-2024學(xué)年第二學(xué)期期末試卷
- 安徽省定遠(yuǎn)育才實(shí)驗(yàn)學(xué)校2025年高三3月摸底考試綜合試題含解析
- 重慶理工職業(yè)學(xué)院《新世紀(jì)文學(xué)研究》2023-2024學(xué)年第一學(xué)期期末試卷
- 景德鎮(zhèn)陶瓷大學(xué)《會(huì)展廣告設(shè)計(jì)》2023-2024學(xué)年第一學(xué)期期末試卷
- 成都醫(yī)學(xué)院《和聲(3)》2023-2024學(xué)年第二學(xué)期期末試卷
- 河北中醫(yī)藥大學(xué)《麻醉解剖學(xué)》2023-2024學(xué)年第二學(xué)期期末試卷
- 四川工程職業(yè)技術(shù)學(xué)院《書法(Ⅰ)》2023-2024學(xué)年第二學(xué)期期末試卷
- 浙江省杭州市蕭山區(qū)2025年初三質(zhì)量檢測(cè)試題(三模)化學(xué)試題試卷含解析
- 山東省武城縣達(dá)標(biāo)名校2025屆初三下學(xué)期中考考前質(zhì)量檢測(cè)試題三(5月模擬)英語(yǔ)試題含答案
- 2025信息技術(shù)系統(tǒng)維護(hù)服務(wù)合同
- 校外租房學(xué)生走訪記錄
- GB 26403-2011食品安全國(guó)家標(biāo)準(zhǔn)食品添加劑特丁基對(duì)苯二酚
- 威尼斯的小艇 省一等獎(jiǎng)
- 2023年神東煤炭校園招聘筆試題庫(kù)及答案解析
- 爆破作業(yè)現(xiàn)場(chǎng)勘查記錄表(樣表)
- 臨床試驗(yàn)疑難問(wèn)題解答
- 物資編碼手冊(cè)
- 中國(guó)神經(jīng)外科重癥患者氣道管理
- 畢業(yè)論文建筑沉降觀測(cè)
- 國(guó)航因私免折票系統(tǒng)
- 機(jī)電安裝總進(jìn)計(jì)劃?rùn)M道圖
評(píng)論
0/150
提交評(píng)論