

下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、武漢工業學院數據庫應用系統設計實驗報告 學號: 090501102 姓名: 畢 波 班級: 計算機091 指導教師: 人事工資管理系統設計總說明:在當今社會,工資管理是一項必要而且很關鍵的工作。現在隨著企業數量的急劇增加,處理人們的工資數據變的越來越煩瑣艱巨。如今,計算機已經普及到了幾乎每個學校、家庭,我們的學習和生活已經處處離不開計算機的存在。本系統依據開發要求主要應用于企業人事系統,完成對日常的工資增刪查改的數字化管理。比較系統地對員工的信息和工資進行管理,查詢、增添、修改、刪除都變的非常簡便,節省了大量的工作量。本課程設計是在學習了數據庫應用系統和相關開發軟件課程之后,讓學生通過實際項目
2、的設計、開發,培養學生獨立進行數據庫軟件的建模、在計算機中進行數據庫設計、并通過相關軟件開發系統的能力。本系統的基本功能包括:部門信息的管理(查詢、添加、修改、刪除學生部門等)、職員信息的管理(錄入、查詢、修改、刪除員工的信息等)、工資信息的管理(錄入、查詢、修改員工的工資等)。本系統主要用于對員工工資進行管理,能夠進行插入、刪除、修改、查詢和顯示員工的信息。登錄該系統時,用戶需要輸入口令和密碼,以確保數據的安全性,成功登錄的用戶,可以插入員工的信息和工資,并對員工的信息和工資進行增、刪、改操作。基于上述想法,我們將員工數據保存到數據庫中。我們要求系統能夠高效快速的處理數據,并且要保證數據的正
3、確性、相容性和安全性。所以在數據庫中需要定義很多觸發器,比如刪除了某個員工的信息則刪除對應的所有工資信息、活著刪除了某部門則刪除該部門所有的信息等。所以我們要從數據庫中讀取數據,并且和界面聯系起來,同時也能將用戶界面上的數據存儲到數據庫中。以上是設計此系統應該注意的地方和設計原則,以下就是遵循這些原則和標準設計出的一套完整的管理系統。 一 系統需求:根據題目需求,可以把系統分為三個部分:部門信息管理部分、職員信息管理部分和工資信息管理部分。本次實驗中,我主要負責部門信息管理模塊,題中需要對部門信息進行查詢、添加、修改、刪除操作,這些操作按是否改變數據庫數據可分為兩類:查詢操作,只讀取數據庫信息
4、,不對信息做修改;刪除、更新和添加操作,需要對數據庫中的數據進行讀寫操作。因此只要寫兩部分代碼,查詢部分:deptinfo_Query進行部門信息查詢,查詢數據庫信息;信息管理部分:deptinfo_Manage,對信息進行更新、增加和刪除。二 數據庫設計1.數據需求人事工資管理系統需要完成的主要功能有:1員工的基本信息錄入2.工資信息表的錄入。3.部門信息表的查詢、插入、修改、刪除等操作。2.相關表表1 職工表:Employee_Info表2 工資表:Salary表3 部門表:Dept_Info表4 系統用戶表:User_Info3.數據流程圖人事工資管理系統登錄 系統管理員職工表部門表工資
5、表圖 數據流程圖三 員工工資相關操作 1.查詢部分 相關代碼: dateGrid1數據綁定 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 = "職¡ã工¡è號?" dataGridView1.Columns1.DataPropertyName = "年份" dataGridView1.Columns2.DataPropertyName = "月份" dataGridView1.Columns3.DataPropertyName = "工資º" 部門組合框的數據綁定 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(); 部門號 if (check1.Checked) DeptStr =
12、 Convert.ToString(DeptcomBox.SelectedValue.ToString(); sqlStr = String.Format("select Salary.EmpID as '職工號', 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 '職工號', 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 '職工號', 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、 '職工號', 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 '職工號', 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 '職工號', 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 '職工號', 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 '職工號', 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 '職工號', Year as '年份', Month as '月份', Salary as '工資' from Salary"); else if (this.mainFo
23、rm.operatorRight = 1) sql = String.Format("select Salary.EmpID as '職工號', 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 '職工號', 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, "數據庫操作失敗¹", 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 '職工號', 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 '職工號', 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 '職工號', 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.對表的增刪改部分: ataGrid數據綁定 private void BindData() sql = String.Format("select EmpID as '職工號', 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 = "職工號" 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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025-2030中國四氟甲烷(CAS:75-73-0)行業市場發展趨勢與前景展望戰略研究報告
- 2025-2030中國口腔衛生產品行業市場發展趨勢與前景展望戰略研究報告
- 2025-2030中國醫療起搏器行業市場發展趨勢與前景展望戰略研究報告
- 2025-2030中國醫用麻醉口罩行業市場發展趨勢與前景展望戰略研究報告
- 2025-2030中國切菜板行業市場發展趨勢與前景展望戰略研究報告
- 2025-2030中國養老院建設行業市場深度調研及競爭格局與投資策略研究報告
- 2025-2030中國公交廣告行業市場深度發展趨勢與前景展望戰略研究報告
- 2025-2030中國光伏透明玻璃行業市場發展趨勢與前景展望戰略研究報告
- 2025-2030中國兒童房家具行業市場深度調研及發展潛力與投資研究報告
- 2025-2030中國促卵泡激素(FSH)行業市場發展趨勢與前景展望戰略研究報告
- GB/T 4354-2008優質碳素鋼熱軋盤條
- Unit6單元復習課件 牛津譯林版九年級英語上冊
- GB/T 33170.4-2016大型活動安全要求 第4部分:臨建設施指南
- 液化氣站安全檢查表分析(SCL+LS)評價記錄(生產設施)
- 人教版初中八年級音樂下冊全套課件
- 套絲機簡介課件
- 【計算機應用基礎試題】池州學院2022年練習題匯總(附答案解析)
- 創傷性網胃炎課件
- 中醫醫術確有專長人員(多年實踐人員)醫師資格考核申請表
- 宏觀大類外匯系列專題(一)阿根廷匯率貶值的經驗教訓
- 教學課件 金屬學與熱處理-崔忠圻
評論
0/150
提交評論