C#人事工资管理系统实验报告_第1页
C#人事工资管理系统实验报告_第2页
C#人事工资管理系统实验报告_第3页
C#人事工资管理系统实验报告_第4页
C#人事工资管理系统实验报告_第5页
已阅读5页,还剩14页未读, 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

.武汉工业学院数据库应用系统设计实验报告学号:090501102姓名:毕波班级:计算机091指导教师:.人事工资管理系统设计总说明:在当今社会,工资管理是一项必要而且很关键的工作。现在随着企业数量精品文档放心下载的急剧增加,处理人们的工资数据变的越来越烦琐艰巨。如今,计算机已经普及到了几乎每谢谢阅读个学校、家庭,我们的学习和生活已经处处离不开计算机的存在。谢谢阅读本系统依据开发要求主要应用于企业人事系统,完成对日常的工资增删查改的数字化管精品文档放心下载理。比较系统地对员工的信息和工资进行管理,查询、增添、修改、删除都变的非常简便,感谢阅读节省了大量的工作量。本课程设计是在学习了《数据库应用系统》和相关开发软件课程之后,让学生通过实际精品文档放心下载项目的设计、开发,培养学生独立进行数据库软件的建模、在计算机中进行数据库设计、并感谢阅读通过相关软件开发系统的能力。谢谢阅读精品文档放心下载本系统主要用于对员工工资进行管理,能够进行插入、删除、修改、查询和显示员工的精品文档放心下载信息。登录该系统时,用户需要输入口令和密码,以确保数据的安全性,成功登录的用户,感谢阅读可以插入员工的信息和工资,并对员工的信息和工资进行增、删、改操作。精品文档放心下载基于上述想法,我们将员工数据保存到数据库中。我们要求系统能够高效快速的处理数感谢阅读据,并且要保证数据的正确性、相容性和安全性。所以在数据库中需要定义很多触发器,比谢谢阅读如删除了某个员工的信息则删除对应的所有工资信息、活着删除了某部门则删除该部门所有感谢阅读的信息等。所以我们要从数据库中读取数据,并且和界面联系起来,同时也能将用户界面上的数据精品文档放心下载存储到数据库中。以上是设计此系统应该注意的地方和设计原则,以下就是遵循这些原则和精品文档放心下载标准设计出的一套完整的管理系统。第1页共页一根据题目需求,可以把系统分为三个部分:部门信息管理部分、职员信息管理部分和工精品文档放心下载资信息管理部分。本次实验中,我主要负责部门信息管理模块,题中需要对部门信息进行查询、添加、修改、删除操作,这些操作按是否改变数据库数据可分为两类:查询操作,只读

取数据库信息,不对信息做修改;删除、更新和添加操作,需要对数据库中的数据进行读写操作。因此只要写两部分代码,查询部分:deptinfo_Query进行部门信息查询,查询数据库信

息;信息管理部分:deptinfo_Manage,对信息进行更新、增加和删除。精品文档放心下载二1.数据需求人事工资管理系统需要完成的主要功能有:1员工的基本信息录入2.工资信息表的录入。3.部门信息表的查询、插入、修改、删除等操作。2.相关表表1职工表:Employee_Info第2页共页表2工资表:Salary第3页共页表3部门表:Dept_Info表4系统用户表:User_Info3.数据流程图第4页共页人事工资管理系统登录职工部工资门表表表图数据流程图三1.查询部分相关代码:dateGrid1数据绑定privatevoidBindData(Stringsql)感谢阅读{SqlConnectionconnection=newSqlConnection(connString);谢谢阅读SqlDataAdapterdataAdapter=newSqlDataAdapter(sql,connection);精品文档放心下载DataSetdataSet=newDataSet();谢谢阅读dataAdapter.Fill(dataSet);精品文档放心下载dataGridView1.DataSource=dataSet.Tables[0];精品文档放心下载dataGridView1.Columns[0].DataPropertyName="职¡ã工¡è号?";谢谢阅读dataGridView1.Columns[1].DataPropertyName="年份";谢谢阅读dataGridView1.Columns[2].DataPropertyName="月份";感谢阅读dataGridView1.Columns[3].DataPropertyName="工资º";精品文档放心下载}部门组合框的数据绑定第5页共页privatevoidBindDeptComBox()谢谢阅读{stringsql="SELECT*FROM[Dept_Info]";精品文档放心下载SqlConnectionconnection=newSqlConnection(connString);感谢阅读SqlDataAdapterdataAdapter=newSqlDataAdapter(sql,connection);感谢阅读DataSetdataSet=newDataSet();谢谢阅读dataAdapter.Fill(dataSet);谢谢阅读DeptcomBox.DataSource=dataSet.Tables[0];感谢阅读DeptcomBox.DisplayMember="DeptName";精品文档放心下载DeptcomBox.ValueMember="DeptID";谢谢阅读DeptcomBox.SelectedIndex=0;谢谢阅读}按部门查询privatevoidcheck1_CheckedChanged(objectsender,EventArgse)谢谢阅读{if(check1.Checked){btnYes.Enabled=true;DeptcomBox.Enabled=true;精品文档放心下载check4.Checked=false;check4.Enabled=false;}else{DeptcomBox.Enabled=false;精品文档放心下载check4.Enabled=true;}}按年份查询privatevoidcheck2_CheckedChanged(objectsender,EventArgse)感谢阅读{btnYes.Enabled=true;if(check2.Checked){YearComBox.Enabled=true;感谢阅读}else{YearComBox.Enabled=false;谢谢阅读}YearComBox.SelectedIndex=0;精品文档放心下载}按月份Y查询privatevoidcheck3_CheckedChanged(objectsender,EventArgse)感谢阅读第6页共页{if(check3.Checked){btnYes.Enabled=true;MonthComBox.Enabled=true;感谢阅读}else{MonthComBox.Enabled=false;谢谢阅读}}仅查询自己的工资privatevoidcheck4_CheckedChanged(objectsender,EventArgse)精品文档放心下载{if(check4.Checked){btnYes.Enabled=true;check1.Enabled=false;DeptcomBox.Enabled=false;感谢阅读}else{check1.Enabled=true;check1.Checked=false;}}privatevoidbtnYes_Click(objectsender,EventArgse)谢谢阅读{count=0;StringYearStr;intMonthStr;StringDeptStr;StringsqlStr="";sql="";DeptStr=Convert.ToString(DeptcomBox.SelectedValue.ToString());感谢阅读部门号if(check1.Checked){DeptStr=Convert.ToString(DeptcomBox.SelectedValue.ToString());感谢阅读sqlStr=String.Format("select[Salary].EmpIDas'职工号',Yearas'年份',Monthas'谢谢阅读月份',Salaryas'工资'from[Salary],[Employee_Info]whereDeptID='{0}'and感谢阅读Salary.EmpID=Employee_Info.EmpID",DeptStr);感谢阅读if(count==0){第7页共页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("selectEmpIDas职工号',Yearas年份',Monthas月份',谢谢阅读Salaryas'工资'from[Salary]whereYear='{0}'",YearStr);感谢阅读}elseif(this.mainForm.operatorRight==1)精品文档放心下载{sqlStr=String.Format("selectSalary.EmpIDas职工号',Yearas年份',Monthas'谢谢阅读月',Salaryas'工资'fromSalary,Employee_Info,Dept_InfowhereYear='{0}'and谢谢阅读Salary.EmpID=Employee_Info.EmpIDandEmployee_Info.DeptID=Dept_Info.DeptIDandDept_Info.DeptIDin精品文档放心下载(selectDeptIDfromEmployee_InfowhereEmpID='{1}')",YearStr,this.mainForm.person.userName);谢谢阅读}else{sqlStr=String.Format("selectEmpIDas职工号',Yearas年份',Monthas月份感谢阅读',Salaryas'工资'from[Salary]whereYear='{0}'andEmpID='{1}'",谢谢阅读YearStr,this.mainForm.person.userName);谢谢阅读}if(count==0){sql+=sqlStr;count=1;}else{sql+="intersect"+sqlStr;精品文档放心下载}check2.Checked=false;}月份第8页共页if(check3.Checked){MonthStr=Convert.ToInt32(MonthComBox.SelectedItem.ToString());精品文档放心下载if(this.mainForm.operatorRight==2)谢谢阅读{sqlStr=String.Format("selectEmpIDas职工号',Yearas年份',Monthas月份',谢谢阅读Salaryas'工资'from[Salary]whereMonth='{0}'",MonthStr);精品文档放心下载}elseif(this.mainForm.operatorRight==1)精品文档放心下载{sqlStr=String.Format("selectSalary.EmpIDas职工号',Yearas年份',Monthas'感谢阅读月份',Salaryas'工资'fromSalary,Employee_Info,Dept_InfowhereMonth='{0}'and精品文档放心下载Salary.EmpID=Employee_Info.EmpIDandEmployee_Info.DeptID=Dept_Info.DeptIDandDept_Info.DeptIDin谢谢阅读(selectDeptIDfromEmployee_InfowhereEmpID='{1}')",MonthStr,this.mainForm.person.userName);感谢阅读}else{sqlStr=String.Format("selectEmpIDas职工号',Yearas年份',Monthas月份',谢谢阅读Salaryas'工'from[Salary]whereMonth='{0}'andEmpID='{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("selectEmpIDas职工号',Yearas年份',Monthas月份',Salary感谢阅读as'工资'fromSalarywhereEmpID='{0}'",this.mainForm.person.userName);感谢阅读if(count==0){sql+=sqlStr;count=1;}else第9页共页{sql+="intersect"+sqlStr;精品文档放心下载}check4.Checked=false;}SqlCommandcommand=newSqlCommand(sql,connection);谢谢阅读try{connection.Open();SqlDataReaderdata=command.ExecuteReader();精品文档放心下载if(data.Read()){BindData(sql);}else{if(this.mainForm.operatorRight==2)精品文档放心下载{sql=String.Format("selectEmpIDas'职工号',Yearas'年份',Monthas'月份谢谢阅读',Salaryas'工资'fromSalary");谢谢阅读}elseif(this.mainForm.operatorRight==1)感谢阅读{sql=String.Format("selectSalary.EmpIDas职工号',Yearas年份',Monthas谢谢阅读'月份',Salaryas工资'fromSalary,Employee_Info,Dept_InfowhereSalary.EmpID=Employee_Info.EmpID精品文档放心下载andEmployee_Info.DeptID=Dept_Info.DeptIDandDept_Info.DeptIDin(selectDeptIDfromEmployee_Info精品文档放心下载whereEmpID='{0}')",this.mainForm.person.userName);感谢阅读}else{sql=String.Format("selectEmpIDas'职工号',Yearas'年份',Monthas'月份谢谢阅读',Salaryas'工资'fromSalarywhereEmpID='{0}'",this.mainForm.person.userName);感谢阅读}BindData(sql);MessageBox.Show("查询失败,没有符合要求的工资信息","查找失败ã",精品文档放心下载MessageBoxButtons.OK,MessageBoxIcon.Exclamation);谢谢阅读}}catch(Exceptionex){MessageBox.Show(ex.Message,"数据库操作失败¹",MessageBoxButtons.OK,精品文档放心下载MessageBoxIcon.Exclamation);谢谢阅读}finally第页共页{connection.Close();}}privatevoidLoadOrCancel()感谢阅读{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("selectEmpIDas职工号',Yearas年份',Monthas月份',Salary谢谢阅读as'工资'fromSalary");}elseif(this.mainForm.operatorRight==1)精品文档放心下载{DeptcomBox.Visible=false;谢谢阅读check1.Visible=false;sql=String.Format("selectSalary.EmpIDas职工号',Yearas年份',Monthas月份',精品文档放心下载Salaryas'工资'fromSalary,Employee_Info,Dept_InfowhereSalary.EmpID=Employee_Info.EmpIDand谢谢阅读Employee_Info.DeptID=Dept_Info.DeptIDandDept_Info.DeptIDin(selectDeptIDfromEmployee_Infowhere精品文档放心下载EmpID='{0}')",this.mainForm.person.userName);精品文档放心下载}else{check1.Visible=false;check4.Visible=false;DeptcomBox.Visible=false;感谢阅读sql=String.Format("selectEmpIDas职工号',Yearas年份',Monthas月份',Salary谢谢阅读as'工资'fromSalarywhereEmpID='{0}'",this.mainForm.person.userName);精品文档放心下载}BindData(sql);count=0;}privatevoidgroupBox2_Enter(objectsender,EventArgse)感谢阅读{}第页共页2.对表的增删改部分:ataGrid数据绑定privatevoidBindData(){sql=String.Format("selectEmpIDas职工号',Yearas年份',Monthas月份',Salaryas'精品文档放心下载工资'fromSalary");SqlConnectionconnection=newSqlConnection(connString);感谢阅读SqlDataAdapterdataAdapter=newSqlDataAdapter(sql,connection);谢谢阅读DataSetdataSet=newDataSet();感谢阅读dataAdapter.Fill(dataSet);谢谢阅读dataGridView1.DataSource=dataSet.Tables[0];精品文档放心下载dataGridView1.Columns[0].DataPropertyName="职工号";谢谢阅读dataGridView1.Columns[1].DataPropertyName="年份";精品文档放心下载dataGridView1.Columns[2].DataPropertyName="月份";感谢阅读dataGridView1.Columns[3].DataPropertyName="工资";谢谢阅读}删除privatevoidbtn3_Click(objectsender,EventArgse)精品文档放心下载{cleartext();textreadwrite();btnOkOrCancel();combMonth.Enabled=true;combYear.Enabled=true;txt4.ReadOnly=true;opterate="delete";}修改或更新职工工资信息privatevoidbtnOk_Click(objectsender,EventArgse)精品文档放心下载{btnOkOrCancel();btnOk.Enabled=false;EmpID=txt1.Text;Year=Convert.ToString(combYear.SelectedItem.ToString());精品文档放心下载Month=Convert.ToInt32(combMonth.SelectedItem.ToString());感谢阅读Stringsalary=txt4.Text;精品文档放心下载if(salary==""){salary="0";}第页共页Salary=(float)Convert.ToDouble(salary.Trim());精品文档放心下载intnum=0;try{if(EmpID!=""){sql=String.Format("selectcount(*)from[Employee_Info]whereEmpID='{0}'",感谢阅读EmpID);SqlCommandcommand=newSqlCommand(sql,connection);精品文档放心下载connection.Open();intc=(int)command.ExecuteScalar();谢谢阅读connection.Close();if(c>0){connection=newSqlConnection(connString);精品文档放心下载connection.Open();sql=String.Format("selectcount(*)from[Salary]whereEmpID='{0}'and谢谢阅读Year='{1}'andMonth='{2}'",EmpID,Year,Month);精品文档放心下载SqlCommandmycmd=newSqlCommand(sql,connection);感谢阅读num=(int)mycmd.ExecuteScalar();谢谢阅读connection.Close();职工的工资信息存在if(num>0){if(opterate=="insert"){MessageBox.Show("录入不成功,您要录入的员工的工资信息已存在!","录入精品文档放心下载失败",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);精品文档放心下载textreadonly();}elseif(opterate=="update")感谢阅读{sql=String.Format("update[Salary]setSalary='{0}'whereEmpID='{1}'谢谢阅读andYear='{2}'andMonth='{3}'",Salary,EmpID,Year,Month);谢谢阅读connection.Open();command=newSqlCommand(sql,connection);精品文档放心下载command.ExecuteNonQuery();精品文档放心下载connection.Close();BindData();textreadonly();MessageBox.Show("更新成功!","更新成功",MessageBoxButtons.OK,感谢阅读MessageBoxIcon.Exclamation);精品文档放心下载}else第页共页{connection.Open();sql=String.Format("deletefrom[Salary]whereEmpID='{0}'and谢谢阅读Year='{1}'andMonth='{2}'",EmpID,Year,Month);感谢阅读command=newSqlCommand(sql,connection);谢谢阅读command.ExecuteNonQuery();谢谢阅读connection.Close();BindData();MessageBox.Show("删除成功!","删除成功",MessageBoxButtons.OK,精品文档放心下载MessageBoxIcon.Exclamation);谢谢阅读textreadonly();}}else{if(opterate=="insert"){sql=String.Format("insertinto精品文档放心下载[Salary](EmpID,Year,Month,Salary)values('{0}','{1}','{2}','{3}')",EmpID,Year,Month,Salary);精品文档放心下载command=newSqlCommand(sql,connection);感谢阅读connection.Open();command.ExecuteNonQuery();精品文档放心下载connection.Close();BindData();MessageBox.Show("录入成功!","录入成功",MessageBoxButtons.OK,精品文档放心下载MessageBoxIcon.Exclamation);精品文档放心下载textreadonly();}elseif(opterate=="update")谢谢阅读{MessageBox.Show("修改失败,不存在要修改的工资信息!","修T改失败",感谢阅读MessageBoxButtons.OK,MessageBoxIcon.Exclamation);精品文档放心下载textreadonly();}else{MessageBox.Show("删除失败,不存在要删除的工资信息!","删除失败",精品文档放心下载MessageBoxButtons.OK,MessageBoxIcon.Exclamation);感谢阅读textreadonly();}}}else{第页共页MessageBox.Show("不存在要管理的员工工资信息!","操作失败",精品文档放心下载MessageBoxButtons.OK,MessageBoxIcon.Exclamation);精品文档放心下载textreadonly();}}else{MessageBox.Show("操作失败,请填入员工号!","操作失败",MessageBoxButtons.OK,谢谢阅读MessageBoxIcon.Exclamation);精品文档放心下载textreadonly();}btnModi();/

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论