C#人事工資管理系統(tǒng)實(shí)驗(yàn)報(bào)告--精選文檔_第1頁
C#人事工資管理系統(tǒng)實(shí)驗(yàn)報(bào)告--精選文檔_第2頁
已閱讀5頁,還剩11頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、武漢工業(yè)學(xué)院數(shù)據(jù)庫應(yīng)用系統(tǒng)設(shè)計(jì)實(shí)驗(yàn)報(bào)告 學(xué)號(hào): 090501102 姓名: 畢 波 班級(jí): 計(jì)算機(jī)091 指導(dǎo)教師: 人事工資管理系統(tǒng)設(shè)計(jì)總說明:在當(dāng)今社會(huì),工資管理是一項(xiàng)必要而且很關(guān)鍵的工作?,F(xiàn)在隨著企業(yè)數(shù)量的急劇增加,處理人們的工資數(shù)據(jù)變的越來越煩瑣艱巨。如今,計(jì)算機(jī)已經(jīng)普及到了幾乎每個(gè)學(xué)校、家庭,我們的學(xué)習(xí)和生活已經(jīng)處處離不開計(jì)算機(jī)的存在。本系統(tǒng)依據(jù)開發(fā)要求主要應(yīng)用于企業(yè)人事系統(tǒng),完成對(duì)日常的工資增刪查改的數(shù)字化管理。比較系統(tǒng)地對(duì)員工的信息和工資進(jìn)行管理,查詢、增添、修改、刪除都變的非常簡便,節(jié)省了大量的工作量。本課程設(shè)計(jì)是在學(xué)習(xí)了數(shù)據(jù)庫應(yīng)用系統(tǒng)和相關(guān)開發(fā)軟件課程之后,讓學(xué)生通過實(shí)際項(xiàng)目

2、的設(shè)計(jì)、開發(fā),培養(yǎng)學(xué)生獨(dú)立進(jìn)行數(shù)據(jù)庫軟件的建模、在計(jì)算機(jī)中進(jìn)行數(shù)據(jù)庫設(shè)計(jì)、并通過相關(guān)軟件開發(fā)系統(tǒng)的能力。本系統(tǒng)的基本功能包括:部門信息的管理(查詢、添加、修改、刪除學(xué)生部門等)、職員信息的管理(錄入、查詢、修改、刪除員工的信息等)、工資信息的管理(錄入、查詢、修改員工的工資等)。本系統(tǒng)主要用于對(duì)員工工資進(jìn)行管理,能夠進(jìn)行插入、刪除、修改、查詢和顯示員工的信息。登錄該系統(tǒng)時(shí),用戶需要輸入口令和密碼,以確保數(shù)據(jù)的安全性,成功登錄的用戶,可以插入員工的信息和工資,并對(duì)員工的信息和工資進(jìn)行增、刪、改操作。基于上述想法,我們將員工數(shù)據(jù)保存到數(shù)據(jù)庫中。我們要求系統(tǒng)能夠高效快速的處理數(shù)據(jù),并且要保證數(shù)據(jù)的正

3、確性、相容性和安全性。所以在數(shù)據(jù)庫中需要定義很多觸發(fā)器,比如刪除了某個(gè)員工的信息則刪除對(duì)應(yīng)的所有工資信息、活著刪除了某部門則刪除該部門所有的信息等。所以我們要從數(shù)據(jù)庫中讀取數(shù)據(jù),并且和界面聯(lián)系起來,同時(shí)也能將用戶界面上的數(shù)據(jù)存儲(chǔ)到數(shù)據(jù)庫中。以上是設(shè)計(jì)此系統(tǒng)應(yīng)該注意的地方和設(shè)計(jì)原則,以下就是遵循這些原則和標(biāo)準(zhǔn)設(shè)計(jì)出的一套完整的管理系統(tǒng)。 一 系統(tǒng)需求:根據(jù)題目需求,可以把系統(tǒng)分為三個(gè)部分:部門信息管理部分、職員信息管理部分和工資信息管理部分。本次實(shí)驗(yàn)中,我主要負(fù)責(zé)部門信息管理模塊,題中需要對(duì)部門信息進(jìn)行查詢、添加、修改、刪除操作,這些操作按是否改變數(shù)據(jù)庫數(shù)據(jù)可分為兩類:查詢操作,只讀取數(shù)據(jù)庫信息

4、,不對(duì)信息做修改;刪除、更新和添加操作,需要對(duì)數(shù)據(jù)庫中的數(shù)據(jù)進(jìn)行讀寫操作。因此只要寫兩部分代碼,查詢部分:deptinfo_Query進(jìn)行部門信息查詢,查詢數(shù)據(jù)庫信息;信息管理部分:deptinfo_Manage,對(duì)信息進(jìn)行更新、增加和刪除。二 數(shù)據(jù)庫設(shè)計(jì)1.數(shù)據(jù)需求人事工資管理系統(tǒng)需要完成的主要功能有:1員工的基本信息錄入2.工資信息表的錄入。3.部門信息表的查詢、插入、修改、刪除等操作。2.相關(guān)表表1 職工表:Employee_Info表2 工資表:Salary表3 部門表:Dept_Info表4 系統(tǒng)用戶表:User_Info3.數(shù)據(jù)流程圖人事工資管理系統(tǒng)登錄 系統(tǒng)管理員職工表部門表工資

5、表圖 數(shù)據(jù)流程圖三 員工工資相關(guān)操作 1.查詢部分 相關(guān)代碼: dateGrid1數(shù)據(jù)綁定 private void BindData(String sql) SqlConnection connection = new SqlConnection(connString); SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); dataGridView1.DataSource = dataSet.T

6、ables0; dataGridView1.Columns0.DataPropertyName = "職¡ã工¡è號(hào)?" dataGridView1.Columns1.DataPropertyName = "年份" dataGridView1.Columns2.DataPropertyName = "月份" dataGridView1.Columns3.DataPropertyName = "工資º" 部門組合框的數(shù)據(jù)綁定 private void BindDept

7、ComBox() string sql = "SELECT * FROM Dept_Info" SqlConnection connection = new SqlConnection(connString); SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); DeptcomBox.DataSource = dataSet.Tables0; DeptcomBox.Displa

8、yMember = "DeptName" DeptcomBox.ValueMember = "DeptID" DeptcomBox.SelectedIndex = 0; 按部門查詢 private void check1_CheckedChanged(object sender, EventArgs e) if (check1.Checked) btnYes.Enabled = true; DeptcomBox.Enabled = true; check4.Checked = false; check4.Enabled = false; else Dep

9、tcomBox.Enabled = false; check4.Enabled = true; 按年份查詢 private void check2_CheckedChanged(object sender, EventArgs e) btnYes.Enabled = true; if (check2.Checked) YearComBox.Enabled = true; else YearComBox.Enabled = false; YearComBox.SelectedIndex = 0; 按月份Y查詢 private void check3_CheckedChanged(object s

10、ender, EventArgs e) if (check3.Checked) btnYes.Enabled = true; MonthComBox.Enabled = true; else MonthComBox.Enabled = false; 僅查詢自己的工資 private void check4_CheckedChanged(object sender, EventArgs e) if (check4.Checked) btnYes.Enabled = true; check1.Enabled = false; DeptcomBox.Enabled = false; else che

11、ck1.Enabled = true; check1.Checked = false; private void btnYes_Click(object sender, EventArgs e) count = 0; String YearStr; int MonthStr; String DeptStr; String sqlStr = "" sql = "" DeptStr = Convert.ToString(DeptcomBox.SelectedValue.ToString(); 部門號(hào) if (check1.Checked) DeptStr =

12、 Convert.ToString(DeptcomBox.SelectedValue.ToString(); sqlStr = String.Format("select Salary.EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資º' from Salary,Employee_Info where DeptID='0'and Salary.EmpID=Employee_Info.EmpID", DeptStr);

13、if (count = 0) sql += sqlStr; count = 1; else sql += " intersect " + sqlStr; check1.Checked = false; 年份 if (check2.Checked) YearStr = Convert.ToString(YearComBox.SelectedItem.ToString(); if(this.mainForm.operatorRight=2) sqlStr = String.Format("select EmpID as '職工號(hào)', Year as &

14、#39;年份', Month as '月份', Salary as '工資' from Salary where Year='0'", YearStr); else if(this.mainForm.operatorRight=1) sqlStr = String.Format("select Salary.EmpID as '職工號(hào)', Year as '年份', Month as '月', Salary as '工資' from Salary,Empl

15、oyee_Info,Dept_Info where Year='0'and Salary.EmpID=Employee_Info.EmpID and Employee_Info.DeptID=Dept_Info.DeptID and Dept_Info.DeptID in (select DeptID from Employee_Info where EmpID='1')", YearStr,this.mainForm.person.userName); else sqlStr = String.Format("select EmpID as

16、 '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資Á' from Salary where Year='0'and EmpID='1'", YearStr,this.mainForm.person.userName); if (count = 0) sql += sqlStr; count = 1; else sql += " intersect " + sqlStr; check2.Checked = fal

17、se; 月份 if (check3.Checked) MonthStr = Convert.ToInt32(MonthComBox.SelectedItem.ToString(); if (this.mainForm.operatorRight = 2) sqlStr = String.Format("select EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資' from Salary where Month='0'", M

18、onthStr); else if (this.mainForm.operatorRight = 1) sqlStr = String.Format("select Salary.EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資' from Salary,Employee_Info,Dept_Info where Month='0'and Salary.EmpID=Employee_Info.EmpID and Employee_Info

19、.DeptID=Dept_Info.DeptID and Dept_Info.DeptID in (select DeptID from Employee_Info where EmpID='1')", MonthStr, this.mainForm.person.userName); else sqlStr = String.Format("select EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工' from Salary

20、 where Month='0' and EmpID='1'", MonthStr,this.mainForm.person.userName); if (count = 0) sql += sqlStr; count = 1; else sql += " intersect " + sqlStr; check3.Checked = false; 自己工資 if (check4.Checked) sql = String.Format("select EmpID as '職工號(hào)', Year as '

21、;年份', Month as '月份', Salary as '工資' from Salary where EmpID='0'", this.mainForm.person.userName); if (count = 0) sql += sqlStr; count = 1; else sql += " intersect " + sqlStr; check4.Checked = false; SqlCommand command = new SqlCommand(sql, connection); try

22、connection.Open(); SqlDataReader data = command.ExecuteReader(); if (data.Read() BindData(sql); else if(this.mainForm.operatorRight=2) sql = String.Format("select EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資' from Salary"); else if (this.mainFo

23、rm.operatorRight = 1) sql = String.Format("select Salary.EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資' from Salary,Employee_Info,Dept_Info where Salary.EmpID=Employee_Info.EmpID and Employee_Info.DeptID=Dept_Info.DeptID and Dept_Info.DeptID in (sele

24、ct DeptID from Employee_Info where EmpID='0')", this.mainForm.person.userName); else sql = String.Format("select EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資' from Salary where EmpID='0'", this.mainForm.person.userName); Bi

25、ndData(sql); MessageBox.Show("查詢失敗,沒有符合要求的工資信息", "查找失敗ã", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); catch (Exception ex) MessageBox.Show(ex.Message, "數(shù)據(jù)庫操作失敗¹", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); finally connection.Close(); private voi

26、d LoadOrCancel() mainForm = (MainForm)this.ParentForm; YearComBox.SelectedIndex = 0; MonthComBox.SelectedIndex = 0; YearComBox.Enabled = false; MonthComBox.Enabled = false; DeptcomBox.Enabled = false; btnYes.Enabled = false; BindDeptComBox(); if (this.mainForm.operatorRight = 2) sql = String.Format(

27、"select EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資' from Salary"); else if (this.mainForm.operatorRight = 1) DeptcomBox.Visible = false; check1.Visible = false; sql = String.Format("select Salary.EmpID as '職工號(hào)', Year as '年份&#

28、39;, Month as '月份', Salary as '工資' from Salary,Employee_Info,Dept_Info where Salary.EmpID=Employee_Info.EmpID and Employee_Info.DeptID=Dept_Info.DeptID and Dept_Info.DeptID in (select DeptID from Employee_Info where EmpID='0')", this.mainForm.person.userName); else check

29、1.Visible = false; check4.Visible = false; DeptcomBox.Visible = false; sql = String.Format("select EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as '工資' from Salary where EmpID='0'", this.mainForm.person.userName); BindData(sql); count = 0; pri

30、vate void groupBox2_Enter(object sender, EventArgs e) 2.對(duì)表的增刪改部分: ataGrid數(shù)據(jù)綁定 private void BindData() sql = String.Format("select EmpID as '職工號(hào)', Year as '年份', Month as '月份', Salary as ' 工資' from Salary"); SqlConnection connection = new SqlConnection(connStr

31、ing); SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, connection); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); dataGridView1.DataSource = dataSet.Tables0; dataGridView1.Columns0.DataPropertyName = "職工號(hào)" dataGridView1.Columns1.DataPropertyName = "年份" dataGridV

32、iew1.Columns2.DataPropertyName = "月份" dataGridView1.Columns3.DataPropertyName = "工資" 刪除 private void btn3_Click(object sender, EventArgs e) cleartext(); textreadwrite(); btnOkOrCancel(); combMonth.Enabled = true; combYear.Enabled = true; txt4.ReadOnly = true; opterate = "del

33、ete" 修改或更新職工工資信息 private void btnOk_Click(object sender, EventArgs e) btnOkOrCancel(); btnOk.Enabled = false; EmpID = txt1.Text; Year = Convert.ToString(combYear.SelectedItem.ToString(); Month = Convert.ToInt32(combMonth.SelectedItem.ToString(); String salary = txt4.Text; if (salary = "&qu

34、ot;) salary = "0" Salary = (float)Convert.ToDouble(salary.Trim(); int num = 0; try if (EmpID != "") sql = String.Format("select count (*) from Employee_Info where EmpID='0'", EmpID); SqlCommand command = new SqlCommand(sql, connection); connection.Open(); int c

35、= (int)command.ExecuteScalar(); connection.Close(); if (c > 0) connection = new SqlConnection(connString); connection.Open(); sql = String.Format("select count (*) from Salary where EmpID='0'and Year='1' and Month='2'", EmpID, Year, Month); SqlCommand mycmd = new

36、 SqlCommand(sql, connection); num = (int)mycmd.ExecuteScalar(); connection.Close(); 職工的工資信息存在 if (num > 0) if (opterate = "insert") MessageBox.Show("錄入不成功,您要錄入的員工的工資信息已存在!", "錄入失敗", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textreadonly(); else if (opterate

37、= "update") sql = String.Format("update Salary set Salary='0'where EmpID='1' and Year='2' and Month='3'", Salary, EmpID, Year, Month); connection.Open(); command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); connection.Close(); Bind

38、Data(); textreadonly(); MessageBox.Show("更新成功! ", "更新成功", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else connection.Open(); sql = String.Format("delete from Salary where EmpID='0'and Year='1' and Month='2'", EmpID, Year, Month); command

39、= new SqlCommand(sql, connection); command.ExecuteNonQuery(); connection.Close(); BindData(); MessageBox.Show("刪除成功! ", "刪除成功", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textreadonly(); else if (opterate = "insert") sql = String.Format("insert into Salary(

40、EmpID,Year,Month,Salary)values ('0','1','2','3')", EmpID, Year, Month, Salary); command = new SqlCommand(sql, connection); connection.Open(); command.ExecuteNonQuery(); connection.Close(); BindData(); MessageBox.Show("錄入成功! ", "錄入成功", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); textreadonly(); else if (opterate = "update") MessageBox.Show("修改失敗,不存在要修改的工資信息! ", "修T改失敗", MessageBoxButtons.OK, MessageBoxIcon.E

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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)論