1、 软件工程作业 人事工资管理系统 学 院: 班 级: 学 号: 姓 名: 指导老师: 目录 一、需求分析………………………………………………………. 3 1、功效定义……………………………………………………….. 3 2、参与者列表……………………………………………………... 3 3、用例图…………………………………………………………… 3 二、分析…………………………………………………………….. 6 1、类图………………………………………………………………. 6 2
2、状态图…………………………………………………………… 7 3、活动图…………………………………………………………… 7 4、次序图…………………………………………………………… 10 5、协作图…………………………………………………………… 12 三、设计……………………………………………………………… 14 1、步骤图…………………………………………………………… 14 2、实体E-R图………………………………………………………… 15 3、数据字典……………………………………………………………. 16 4、数据库E-R图……………………………………………………… 17
3、四、实现…………………………………………………………………… 17 1、源程序………………………………………………………………….. 17 2、界面…………………………………………………………………….. 3 五、总结和心得…………………………………………………………… 3 六、参考文件…………………………………………………………….. 3 一、需求分析 1、 功效定义 工资管理系统应完成以下功效: ⑴职员信息管理:包含职员基础信息,如工龄情况,学历情况,工作岗位,部门信息。实现对职员信息输入、查询和修改,对于转出、
4、辞职、解聘、退休职员信息删除。 ⑵人事调动管理:包含对职员岗位和部门查询和修改。 ⑶工资管理:职员工资分为两部分:一部分是基础工资,依据职员工龄和岗位设置;另一部分是动态工资,依据职员考勤情况和工作评价情况计算,在计算出总工资后,还应扣除部分费用,如税款、公积金、养老金等。包含对工资查询和修改。 ⑷考勤管理:包含正常出勤、异常出勤(如请假、迟到、早退)、加班。 ⑸工作评价管理:职员评价信息分为两部分,一部分是主管经理对职员评价信息,包含工作分工、完成情况、工作态度等;另一部分是同组职员评价信息,包含工作态度、合作情况等。依据工作评价发放奖金。 ⑹系统管理模块:对人事工资管理系统维护
5、升级和对用户管理:用户信息添加、用户信息修改、用户信息删除和用户权限分配。 2、 参与者列表 ⑴人事部门:①对职员信息管理,包含对职员信息输入、查询、修改。对于转出、辞职、解聘、退休职员信息删除。 ②对人事调动管理,包含对职员岗位和部门查询和修改。 ⑵财务部门:依据职员考勤和工作评价,完成工资核实并发放工资。 ⑶系统管理员:对人事工资管理系统维护、升级和对用户管理:用户信息添加、用户信息修改、用户信息删除和用户权限分配。 ⑷职员: 系统关键使用者,登陆系统后,对自己基础信息查询和对自己工资查询。 ⑸考勤部门:对职员出勤情况进行统计,对职员工作进
6、行评价。 3、用例图 图1 财务部门用例 图2 人事部门用例 图6 人事工资管理系统用例图 一、 分析 1、 类图 2、 状态图 图1 系统状态图 3、活动图 图1 用户注册活动图 图2 登录活动图 图3职员信息查询活动图 图4 对职员信息删除、添加、修改活动图 图5 考勤管理活动图 4、次序图 图1 用户注册次序图 图2 登录次序图
7、 图3 添加职员信息次序图 图4 人事调动次序图 图5 考勤管理次序图 5、协作图 图1 用户注册协作图 图2 登录协作图 图3 添加职员信息协作图 图4 考勤管理协作图 三、设计 1、步骤图 2、实体E-R图 工资 职员号 工资年月 应发工资 奖励金额 扣除工资 实发工资 岗位名称 部门编号 部门 部门名称 部门责任人 部门人数 取得 评价情况 岗位 岗位编号 部门编号 职员号 考勤 职员号 正常出勤
8、 天数 异常出勤 天数 加班天数 职员学历 职员学历 岗位编号 职员姓名 婚姻情况 职员性别 职员号 工龄 部门编号 职员 职员姓名 隶属 属于 属于 考评 依据 3、数据字典 (1)、职员档案信息表:PERSONNEL.DBF 字段 字段名 类型 宽度 说明 1 职员号 字符型 3 数字 2 职员姓名 字符型 10 小于等于5个汉字 3 职员性别 字符型 2 “男”或“女” 4 职员学历 字符型 10 小
9、于等于5个汉字 5 婚姻情况 字符型 4 “已婚”或“未婚” 6 工 龄 数值型 2 1~99之间 7 岗位编号 数值型 2 1~99之间 8 部门编号 数值型 2 1~99之间 (2)、工资设置表:COURSE.DBF 字段 字段名 类型 宽度 说明 1 职员号 数值型 3 数字 2 工资年月 字符型 20 _年_月_日 3 应发工资 数值型 5 1-99999之间 4 奖励金额 数值型 4 1-9999之间 5 扣除工资 数值型 4 1~9999之
10、间 6 实发工资 数值型 5 1-99999之间 (3)、岗位设置表:RANK.DBF 字段 字段名 类型 宽度 说明 1 岗位编号 数值型 2 1~99之间 2 岗位名称 字符型 14 小于等于7个汉字 3 部门编号 数值型 2 1~99之间 (4)、部门设置表:APARTMENT.DBF 字段 字段名 类型 宽度 说明 1 部门编号 数值型 2 1-99之间 2 部门名称 字符型 14 小于等于7个汉字 3 部门责任人 字符型 10 小于等于5个汉字 4 部门人数 数值型 4 1~9
11、999之间 (5)、考勤设置表:KAOQIN.DBF 字段 字段名 类型 宽度 说明 1 职员号 数值型 3 数字 2 正常出勤天数 数值型 3 1~999之间 3 异常出勤天数 数值型 3 1~999之间 4 加班天数 数值型 3 1~999之间 5 评价情况 字符型 4 优异、良好、中等、差 4、数据库E-R图 四、实现 1、源代码 (1)登录界面代码设计 本代码实现Form1,作用是对登录用户审核,将登录用户信息和数据库中用户表相比对,存在此用户且信息正确则进入,不然登录失败。 us
12、ing System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace 工资管理系统 { public partial class Form1 : Form { public
13、static string password; public static string username; public Form1() { InitializeComponent(); } public int CheckUsers()//连接数据库进行查询 { username = textBox1.Text.ToString(); password = textBox2.Text.ToString(
14、); string Afile = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; //access文件 OleDbConnection AconnStr = new OleDbConnection(Afile); OleDbCommand Acmd=new OleDbCommand("select * from [user] where userName=
15、'"+username+"' and password='"+password+"'",AconnStr); OleDbDataReader odr=null; AconnStr.Open(); try { odr=Acmd.ExecuteReader(); } catch (Exception ex) { if (ex != null) retu
16、rn 0; } while (odr.Read()) { return 1; } odr.Close(); AconnStr.Close(); return 0; } private void button1_Click(object sender, EventArgs e) {//对登录信息进行审核,正确则进入
17、不然登录失败 if(textBox1.Text==""||textBox2.Text=="") MessageBox.Show("请输入信息","信息提醒"); else if (CheckUsers()==1) { this.Hide(); Form6 form6 = new Form6(); form6.Show(); } el
18、se { MessageBox.Show("你输入用户名或口令不正确!","信息提醒"); } } private void button2_Click(object sender, EventArgs e) { textBox1.Text = ""; textBox2.Text = ""; } } } (2)职员信息更新界面 本代码实现Form3,作用是对职员信息进
19、行更新,能够职员信息作查找,添加,删除,修改等操作,还能够查询工资信息,并能计算总工资。 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace 工资管理系统 { public
20、partial class Form3 : Form { public static int string1, string2, string3, day; public Form3() { InitializeComponent(); } private void Form3_Load(object sender, EventArgs e) { loadUsers(); } private
21、 void loadUsers() {//连接数据库 string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; //access文件连接 string OleDbString = "select * from [Message]"; OleDbConnection connection = new O
22、leDbConnection(connectionString); DataSet ds = new DataSet(); try { connection.Open(); OleDbDataAdapter command = new OleDbDataAdapter(OleDbString, connection); command.Fill(ds, "Message"); }
23、 catch (OleDbException ex) { throw new Exception(ex.Message); } //将表绑定到dataGridView1控件 this.dataGridView1.DataSource = ds.Tables[0]; this.dataGridView1.Columns[0].ReadOnly = true;//先0列,即用户名列为关键定不许修改
24、 connection.Close(); } private void pictureBox1_Click(object sender, EventArgs e) { } private void btnDelete_Click(object sender, EventArgs e) { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\len
25、ovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; string SQLString = "delete from [Message] where [sno]='" + this.dataGridView1.CurrentRow.Cells["Sno"].Value+ "'"; OleDbConnection connection = new OleDbConnection(connectionString); connection.Open();
26、 OleDbCommand command = new OleDbCommand(SQLString, connection); if (command.ExecuteNonQuery()==1) MessageBox.Show("删除成功!"); if (connection != null) connection.Close(); loadUsers(); } private void Addb
27、utton_Click(object sender, EventArgs e) {//连接数据库实现添加操作。 if (textBox1.Text == "" || textBox2.Text == "") MessageBox.Show("请输入要添加信息!", "提醒信息"); else { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Sour
28、ce=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; string SQLString = "insert into [Message]([Sno],[职员姓名]) values('" + this.textBox2.Text + "','" + this.textBox1.Text + "')"; OleDbConnection connection = new OleDbConnection(connectionString);
29、 connection.Open(); OleDbCommand command = new OleDbCommand(SQLString, connection); if (command.ExecuteNonQuery() == 1) MessageBox.Show("添加成功!"); if (connection != null) connection.Close();
30、 } loadUsers(); } private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) {//目前修改过值 string updateValue = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString(); //目前修改行用户名(关键字)
31、 string username = dataGridView1.Rows[e.RowIndex].Cells["Sno"].Value.ToString(); string colName = dataGridView1.Columns[e.ColumnIndex].Name;//修改值对应列名 string OleDbString = "update [Message] set [" + colName + "]='" + updateValue + "' where Sno='" + username + "'";
32、 string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; OleDbConnection connection = new OleDbConnection(connectionString); connection.Open(); OleDbCommand command = new
33、OleDbCommand(OleDbString, connection); if (command.ExecuteNonQuery() == 1) if (connection != null) connection.Close(); } private void button4_Click(object sender, EventArgs e) {//实现操作信息 if (MessageBox.Show("确定退出?",
34、"确定信息", MessageBoxButtons.YesNo) == DialogResult.Yes) Application.Exit(); } private void button5_Click(object sender, EventArgs e) { this.Hide(); Form4 form4 = new Form4(); form4.Show(); } privat
35、e void button2_Click(object sender, EventArgs e) { loadUsers(); MessageBox.Show("更新成功"); } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") MessageBox
36、Show("请输入要查找信息!", "提醒信息"); else { string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; //access文件 string OleDbString = "select * from [Message] where Sno='" + this.t
37、extBox2.Text + "'"; OleDbConnection connection = new OleDbConnection(connectionString); DataSet ds = new DataSet(); try { connection.Open(); OleDbDataAdapter command = new OleDbDataAdapter(O
38、leDbString, connection); command.Fill(ds, "Message"); } catch (OleDbException ex) { throw new Exception(ex.Message); } //将表绑定到dataGridView1控件 this.dataGridV
39、iew1.DataSource = ds.Tables[0]; this.dataGridView1.Columns[0].ReadOnly = true;//先0列,即用户名列为关键定不许修改 connection.Close(); } } private void Form3_FormClosing(object sender, FormClosingEventArgs e) { Application.Exit(
40、); } public string Findstring1() { string Afile = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; //access文件 OleDbConnection AconnStr = new OleDbConnection(Afile); OleDbComma
41、nd Acmd = new OleDbCommand("select [基础工资] from [Message],[工资] where Sno='"+ textBox2.Text +"' and Message.职员工种=工资.职员工种 and Message.工资等级=工资.工资等级", AconnStr); OleDbDataReader odr = null; AconnStr.Open(); try { odr = Acmd.ExecuteReade
42、r(); } catch (Exception ex) { if (ex != null) return null; } if (odr != null) { while (odr.Read()) { return odr[0].ToString(); } odr.Close();
43、 } AconnStr.Close(); return null; } public string Findday() { string Afile = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; //access文件 OleDbConnection AconnStr
44、 = new OleDbConnection(Afile); OleDbCommand Acmd = new OleDbCommand("select [考勤天数] from [Message] where Sno='" + textBox2.Text + "'", AconnStr); OleDbDataReader odr = null; AconnStr.Open(); try { odr = Acmd.ExecuteReader();
45、 } catch (Exception ex) { if (ex != null) return null; } if (odr != null) { while (odr.Read()) { return odr[0].ToString(); } odr.Close(); }
46、 AconnStr.Close(); return null; } public string Findstring2() { string Afile = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security Info=True"; //access文件 OleDbConnection AconnStr = n
47、ew OleDbConnection(Afile); OleDbCommand Acmd = new OleDbCommand("select [日工资] from [Message],[工资] where Sno='" + textBox2.Text + "'and Message.职员工种=工资.职员工种 and Message.工资等级=工资.工资等级", AconnStr); OleDbDataReader odr = null; AconnStr.Open(); try
48、 { odr = Acmd.ExecuteReader(); } catch (Exception ex) { if (ex != null) return null; } if (odr != null) { while (odr.Read()) { return odr[0].ToStri
49、ng(); } odr.Close(); } AconnStr.Close(); return null; } public string Findstring3() { string Afile = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Users\\lenovo\\Desktop\\C#\\db.mdb;Persist Security I
50、nfo=True"; //access文件 OleDbConnection AconnStr = new OleDbConnection(Afile); OleDbCommand Acmd = new OleDbCommand("select [职员津贴] from [Message],[工资]where Sno='" + textBox2.Text + "'and Message.职员工种=工资.职员工种 and Message.工资等级=工资.工资等级", AconnStr); OleDbDataReader odr =






