人事工资管理系统_第1页
人事工资管理系统_第2页
人事工资管理系统_第3页
人事工资管理系统_第4页
人事工资管理系统_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

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

文档简介

*人事工资管理系统09地理信息系统一 开发背景企业在发展中不断地壮大,员工也随之增加。对于人事管理部门来说,迫切地需要一个操作方便、功能简单实用,可以满足企业对员工的档案及工资信息进行管理系统。在企业选择人事工资管理系统时,主要存在以下几个方面的要求:(1) 对企业员工的档案进行管理(2) 系统的功能要符合本企业的基本情况(3) 系统的功能操作要简单、实用、操作方便,不要出现复杂的操作。(4) 可以方便地对工资信息进行打印。二 需求分析通过实际调查,要求本系统具有以下功能:良好的人机界面。方便的添加和修改数据功能。方便的数据查询功能。方便的数据打印功能。在相应的窗体中,可方便地删除数据。三 系统设计1.系统目标(1) 界面友好、操作方便(2) 可以对员工档案进行管理,包括增、删、改、查。(3) 实现奖罚管理。(4) 可以使用操作员管理修改口令和更改操作员。、(5) 系统运行稳定、安全可靠。2.系统预览3.业务流程图人事工资管理系统的业务流程如图:4.数据库概念设计应用程序开发过程中,对数据库的操作时必不可少的,数据库设计师根据程序的需求及其实现功能所制定的,数据库设计得是否合理将直接影响程序的开发进程。(1)数据库设计在系统开发中占有非常重要的比重,它是通过管理系统的整体需求而制定的,数据库设计的好坏直接影响到系统的后期开发。下面对本系统中具有代表性的数据库设计做详细说明。在本系统中,为了提高系统的安全性,每一个用户都要使用正确的用户名和密码才能进入主窗体,而且还需要根据指定的用户名提供相应的权限,为了能够验证正确的用户名和密码得到相应的权限,应在数据库中创建登录表。登录用户信息表的实体E-R图:员工档案信息表的实体E-R图:员工工资信息表的实体E-R图:(2)数据库逻辑结构设计根据上面设计好的E-R图,可以在数据库中创建相应的数据表db_User(登录表)字段名数据类型长度主键用户编号Int4是UserNamevarchar20否UserPwdvarchar15否权限varchar10否db_employee(员工档案信息表)字段名数据类型长度主键员工编号Int4是姓名Char10否性别Char10否年龄Int4否民族Varchar10否职务Char10否db_pay(员工工资信息表)字段名数据类型长度主键员工编号Int4是工资月份Varchar50是基本工资decimal9否职务津贴decimal9否奖励金额decimal9否罚款金额decimal9否应发工资decimal9否实发工资decimal9否四 公共类设计项目开发过程中,通常会以类的形式来组织、封装一些常用的方法和事件,这样做不仅可以提高代码的重用率,也大大方便了用户对代码的管理。在本系统中,主要建立了两个公共类,分别为DBConnection类和DBOperate类。DBConnection类主要用于连接数据库;在DBOperate类中则定义了一些操作数据库的公用方法,分别用于实现各种功能,下面详细介绍这两个类。1. DBConnection公共类DBConnection类是数据库连接类,此类主要用于连接SQL Server数据库,在连接数据库时,只需调用此类中的MYConnection即可,其实现代码如下:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data.SqlClient;namespace PMSClass class DBConnetion public static SqlConnection MYConnection() return new SqlConnection(server=.;database=db_PMS;user=sa;pwd=123); 2. DBOperate公共类DBOperate类中建立了多个方法用于执行不同的SQL语句using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.SqlClient;using System.Data;namespace WindowsFormsApplication1 class DBOperate SqlConnection conn = PMSClass.DBConnetion.MYConnection(); public int OperateData(string strSql) conn.Open(); SqlCommand cmd = new SqlCommand(strSql, conn); int i = (int)cmd.ExecuteNonQuery(); conn.Close(); return i; public DataSet gettable(string sql) DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(sql, conn); sda.Fill(ds); ds.Dispose(); return ds; public void BindDataGridView(DataGridView dgv, string sql) DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(sql, conn); sda.Fill(ds); dgv.DataSource = ds.Tables0; ds.Dispose(); 下面对该类中的方法进行讲解(1)OperateData()方法用于对数据库执行SQL语句public int OperateData(string strSql) conn.Open(); SqlCommand cmd = new SqlCommand(strSql, conn); int i = (int)cmd.ExecuteNonQuery(); conn.Close(); return i; (2)gettable()方法用于根据指定的SQL查询语句返回相应的dataset对象public DataSet gettable(string sql) DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(sql, conn); sda.Fill(ds); ds.Dispose(); return ds; (3) BindDataGridView()方法用于将数据库中的数据绑定到datagridview控件public void BindDataGridView(DataGridView dgv, string sql) DataSet ds = new DataSet(); SqlDataAdapter sda = new SqlDataAdapter(sql, conn); sda.Fill(ds); dgv.DataSource = ds.Tables0; ds.Dispose(); 五 登录模块设计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.SqlClient;namespace WindowsFormsApplication1 public partial class Form1 : Form public Form1() InitializeComponent(); private void button1_Click(object sender, EventArgs e) try if (textBox1.Text = | textBox2.Text = ) MessageBox.Show(用户名或密码不能为空!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); return; else SqlConnection conn = PMSClass.DBConnetion.MYConnection(); conn.Open(); string s = select * from db_User where UserName= + textBox1.Text.ToString().Trim() + and UserPwd= + textBox2.Text.Trim() + ; SqlCommand cmd = new SqlCommand(s, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) this.Hide(); conn.Close(); Form2 main = new Form2(); main.User = textBox1.Text.ToString().Trim(); main.Show(); else textBox1.Text = ; textBox2.Text = ; MessageBox.Show(用户名或密码错误!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch (Exception ex) MessageBox.Show(ex.Message); private void button2_Click(object sender, EventArgs e) this.Close(); 在登录窗体中,单击登录按钮,程序调用DBConnection类中的MYCconnection()方法连接数据库,然后通过sqldatareader对象的hasrows属性判断用户输入的用户名和密码是否正确,如果正确,则登录系统,并将用户名传到下个窗体中,否则,弹出用户名或密码错误信息提示,登录按钮事件代码如下:private void button1_Click(object sender, EventArgs e) try if (textBox1.Text = | textBox2.Text = ) MessageBox.Show(用户名或密码不能为空!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); return; else SqlConnection conn = PMSClass.DBConnetion.MYConnection(); conn.Open(); string s = select * from db_User where UserName= + textBox1.Text.ToString().Trim() + and UserPwd= + textBox2.Text.Trim() + ; SqlCommand cmd = new SqlCommand(s, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) this.Hide(); conn.Close(); Form2 main = new Form2(); main.User = textBox1.Text.ToString().Trim(); main.Show(); else textBox1.Text = ; textBox2.Text = ; MessageBox.Show(用户名或密码错误!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); catch (Exception ex) MessageBox.Show(ex.Message); 六 员工信息模块设计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.SqlClient;namespace WindowsFormsApplication1 public partial class Form2 : Form public Form2() InitializeComponent(); public string User; DBOperate operate = new DBOperate(); private void Form2_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“db_PMSDataSet.db_employee”中。您可以根据需要移动或移除它。 this.db_employeeTableAdapter.Fill(this.db_PMSDataSet.db_employee); string sql = select * from db_User where UserName= + User + ; DataSet ds = operate.gettable(sql); string power = ds.Tables0.Rows03.ToString(); if (power = 一般用户) button2.Hide(); private void button1_Click(object sender, EventArgs e) Form3 f3 = new Form3(); f3.User = User; f3.Show(); private void button3_Click(object sender, EventArgs e) this.Close(); private void button2_Click(object sender, EventArgs e) Form4 f4 = new Form4(); f4.User = User; f4.Show(); private void button4_Click(object sender, EventArgs e) string sql = select * from db_employee; operate.BindDataGridView(dataGridView1 ,sql ); 根据员工登录名的不同,分给员工不同的权限,如果只是工人那只能查看工资信息如果你是监制那么可以修改员工的信息及打入工资七 编辑模块设计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.SqlClient;namespace WindowsFormsApplication1 public partial class Form4 : Form public Form4() InitializeComponent(); public string User; DBOperate dbop = new DBOperate(); SqlConnection conn = PMSClass.DBConnetion.MYConnection(); private void Form4_Load(object sender, EventArgs e) / TODO: 这行代码将数据加载到表“db_PMSDataSet1.db_employee”中。您可以根据需要移动或移除它。 this.db_employeeTableAdapter.Fill(this.db_PMSDataSet1.db_employee); private void button1_Click(object sender, EventArgs e) if (textBox1 .Text =) MessageBox.Show(请输入姓名, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else conn.Open(); string s = select * from db_employee where 姓名= + textBox1.Text.ToString().Trim() + ; SqlCommand cmd = new SqlCommand(s, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) string sql = select * from db_employee where 姓名=+ textBox1 .Text .ToString ().Trim () +; dbop.BindDataGridView(dataGridView1, sql); textBox2.Text = Convert.ToString(dataGridView10, dataGridView1.CurrentCell.RowIndex.Value); textBox3.Text = Convert.ToString(dataGridView11, dataGridView1.CurrentCell.RowIndex.Value); textBox4.Text = Convert.ToString(dataGridView12, dataGridView1.CurrentCell.RowIndex.Value); textBox5.Text = Convert.ToString(dataGridView13, dataGridView1.CurrentCell.RowIndex.Value); textBox6.Text = Convert.ToString(dataGridView14, dataGridView1.CurrentCell.RowIndex.Value); textBox7.Text = Convert.ToString(dataGridView15, dataGridView1.CurrentCell.RowIndex.Value); else textBox1.Text = ; MessageBox.Show(姓名错误!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); conn.Close(); private void button2_Click(object sender, EventArgs e) string sql = select * from db_employee; dbop.BindDataGridView(dataGridView1 ,sql ); private void button3_Click(object sender, EventArgs e) if (textBox2.Text = ) MessageBox.Show(请输入您要修改的员工编号!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else conn.Open(); string s = select * from db_employee where 员工编号= + textBox2.Text.ToString().Trim() + ; SqlCommand cmd = new SqlCommand(s, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) string sql = update db_employee set 员工编号= + textBox2.Text.Trim() + ,姓名= + textBox3.Text.Trim() + ,性别= + textBox4.Text.Trim() + ,年龄= + textBox5.Text.Trim() + ,民族= + textBox6.Text.Trim() + ,职务= + textBox7.Text.Trim() + where 员工编号= + textBox2.Text + ; dbop.OperateData(sql); MessageBox.Show(修改成功!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(员工编号不存在!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); conn.Close(); private void button4_Click(object sender, EventArgs e) if (textBox2.Text = ) MessageBox.Show(请输入您要删除的用户编号!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else conn.Open(); string s = select * from db_employee where 员工编号= + textBox2.Text.ToString().Trim() + ; SqlCommand cmd = new SqlCommand(s, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) string sql = delete from db_employee where 员工编号= + textBox2.Text.Trim() + ; dbop.OperateData(sql); /string sql1 = delete from db_User where 用户编号= + textBox2.Text.Trim() + ; /dbop.OperateData(sql1); MessageBox.Show(删除成功!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show(您要删除的员工编号不存在!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); conn.Close(); private void button5_Click(object sender, EventArgs e) try if (textBox2.Text = ) MessageBox.Show(请输入您要新增的用户编号!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else conn.Open(); string s = select * from db_employee where 员工编号= + textBox2.Text.ToString().Trim() + ; SqlCommand cmd = new SqlCommand(s, conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); if (sdr.HasRows) MessageBox.Show(您要新增的员工以存在!, 提示, MessageBoxButtons.OK, MessageBoxIcon.Information); else string sql = insert into db_employee values ( + textBox2.Text.Trim() + , + textBox3.Text.Trim() + , + textBox4.Text.Trim() + , + textBox5.Text.Trim() + , + textBox6.Text.Trim() + , + textBox7.Text.Trim() + ); dbop.OperateData(sql); Form5 f5 = new Form5(); f5.id = textBox2.Text.Trim(); f5.Show(); conn.Close(); catch (Exception) MessageBox.Show(插入异常,提示); throw; private void button6_Click(object sender, EventArgs e) Form6 f6 = new Form6(); f6.User = User; f6.Show(); private void button7_Click(object sender, EventArgs e) this.Close(); private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) textBox2.Text = dataGridView1.CurrentRow.CellsdataGridView1.Columns0.Index.Value.ToString(); textBox3.Text = dataGridView1.CurrentRow.CellsdataGridView1.Columns1.Index.Value.ToString(); textBox4.Text = dataGridView1.CurrentRow.CellsdataGridView1.Columns2.Index.Value.ToString(); textBox5.Text = dataGridView1.CurrentRow.CellsdataGridView1.Columns3.Index.Value.ToString(); textBox6.Text = dataGridView1.CurrentRow.CellsdataGridView1.Columns4.Index.Value.ToString(); textBox7.Text = dataGridView1.CurrentRow.CellsdataGridView1.Columns5.Index.Value.ToString(); private void button8_Click(object sender, EventArgs e) textBox2.Text = ; textBox3.Text = ; textBox4.Text = ; textBox5.Text = ; textBox6.Text = ; textBox7.Text = ; 点击注册按钮,登录用户名、密码就注册了这时系统就有了用户名为yumen,密码为yumen的用户了!其代码如下: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.SqlClient;namespace WindowsFormsApplication1 public partial class Form5 : Form public Form5() InitializeComponent(); public string id; DBOperate dbop = ne

温馨提示

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

评论

0/150

提交评论