员工工资管理界面设计.docx
- 文档编号:23956888
- 上传时间:2023-05-22
- 格式:DOCX
- 页数:20
- 大小:879.84KB
员工工资管理界面设计.docx
《员工工资管理界面设计.docx》由会员分享,可在线阅读,更多相关《员工工资管理界面设计.docx(20页珍藏版)》请在冰豆网上搜索。
员工工资管理界面设计
第六章界面设计和代码设计
6.1界面设计Form1
1、登录界面
登录界面主要有用户名和密码组成,还有一些标题设置,登录和重置按钮组成。
此即为登录界面。
2、主操作界面Form6
主操作界面供选择查询和更新操作。
3、员工信息更新界面Form3
此界面主要实现对员工信息的更新,可以实现删除、更新、添加、查找等操作。
并能查看工资信息和月工资。
4、工资信息更新界面Form4
此界面实现对工资信息的更新,可以实现对工资的查找、删除、更新和添加等操作。
5、员工信息查询Form2
此界面实现对员工信息的查询,并能对工资信息的查询和返回主界面。
6、工资信息查询Form5
此界面实现对工资信息的查询,并能返回上一界面和退出本系统。
6.2、代码设计
此代码设计是对本系统的几个主要的界面的代码进行描述,主要是登录界面、员工信息更新界面、工资更新界面。
1、登录界面代码设计
本代码实现Form1,作用是对登录用户审核,将登录用户信息与数据库中用户表相比对,存在此用户且信息正确则进入,否则登录失败。
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.OleDb;
namespace工资管理系统
{
publicpartialclassForm1:
Form
{
publicstaticstringpassword;
publicstaticstringusername;
publicForm1()
{
InitializeComponent();
}
publicintCheckUsers()//连接数据库进行查询
{
username=textBox1.Text.ToString();
password=textBox2.Text.ToString();
stringAfile="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";//access文件
OleDbConnectionAconnStr=newOleDbConnection(Afile);
OleDbCommandAcmd=newOleDbCommand("select*from[user]whereuserName='"+username+"'andpassword='"+password+"'",AconnStr);
OleDbDataReaderodr=null;
AconnStr.Open();
try
{
odr=Acmd.ExecuteReader();
}
catch(Exceptionex)
{
if(ex!
=null)return0;
}
while(odr.Read())
{
return1;
}
odr.Close();
AconnStr.Close();
return0;
}
privatevoidbutton1_Click(objectsender,EventArgse)
{//对登录信息进行审核,正确则进入,否则登录失败
if(textBox1.Text==""||textBox2.Text=="")
MessageBox.Show("请输入信息","信息提示");
elseif(CheckUsers()==1)
{
this.Hide();
Form6form6=newForm6();
form6.Show();
}
else
{
MessageBox.Show("你输入的用户名或口令不正确!
","信息提示");
}
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
textBox1.Text="";
textBox2.Text="";
}
}
}
2、员工信息更新界面
本代码实现Form3,作用是对员工信息进行更新,可以员工信息作查找,添加,删除,修改等操作,还可以查询工资信息,并能计算总工资。
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingSystem.Data.OleDb;
namespace工资管理系统
{
publicpartialclassForm3:
Form
{
publicstaticintstring1,string2,string3,day;
publicForm3()
{
InitializeComponent();
}
privatevoidForm3_Load(objectsender,EventArgse)
{
loadUsers();
}
privatevoidloadUsers()
{//连接数据库
stringconnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";//access文件连接
stringOleDbString="select*from[Message]";
OleDbConnectionconnection=newOleDbConnection(connectionString);
DataSetds=newDataSet();
try
{
connection.Open();
OleDbDataAdaptercommand=newOleDbDataAdapter(OleDbString,connection);
command.Fill(ds,"Message");
}
catch(OleDbExceptionex)
{
thrownewException(ex.Message);
}
//将表绑定到dataGridView1控件
this.dataGridView1.DataSource=ds.Tables[0];
this.dataGridView1.Columns[0].ReadOnly=true;//先0列,即用户名列为关键定不许修改
connection.Close();
}
privatevoidpictureBox1_Click(objectsender,EventArgse)
{
}
privatevoidbtnDelete_Click(objectsender,EventArgse)
{
stringconnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";
stringSQLString="deletefrom[Message]where[sno]='"+this.dataGridView1.CurrentRow.Cells["Sno"].Value+"'";
OleDbConnectionconnection=newOleDbConnection(connectionString);
connection.Open();
OleDbCommandcommand=newOleDbCommand(SQLString,connection);
if(command.ExecuteNonQuery()==1)
MessageBox.Show("删除成功!
");
if(connection!
=null)
connection.Close();
loadUsers();
}
privatevoidAddbutton_Click(objectsender,EventArgse)
{//连接数据库实现添加操作。
if(textBox1.Text==""||textBox2.Text=="")
MessageBox.Show("请输入要添加的信息!
","提示信息");
else
{
stringconnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";
stringSQLString="insertinto[Message]([Sno],[员工姓名])values('"+this.textBox2.Text+"','"+this.textBox1.Text+"')";
OleDbConnectionconnection=newOleDbConnection(connectionString);
connection.Open();
OleDbCommandcommand=newOleDbCommand(SQLString,connection);
if(command.ExecuteNonQuery()==1)
MessageBox.Show("添加成功!
");
if(connection!
=null)
connection.Close();
}
loadUsers();
}
privatevoiddataGridView1_CellEndEdit(objectsender,DataGridViewCellEventArgse)
{//当前修改过的值
stringupdateValue=dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
//当前修改行的用户名(关键字)
stringusername=dataGridView1.Rows[e.RowIndex].Cells["Sno"].Value.ToString();
stringcolName=dataGridView1.Columns[e.ColumnIndex].Name;//修改值对应的列名
stringOleDbString="update[Message]set["+colName+"]='"+updateValue+"'whereSno='"+username+"'";
stringconnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";
OleDbConnectionconnection=newOleDbConnection(connectionString);
connection.Open();
OleDbCommandcommand=newOleDbCommand(OleDbString,connection);
if(command.ExecuteNonQuery()==1)
if(connection!
=null)
connection.Close();
}
privatevoidbutton4_Click(objectsender,EventArgse)
{//实现操作信息
if(MessageBox.Show("确定退出?
","确认信息",MessageBoxButtons.YesNo)==DialogResult.Yes)
Application.Exit();
}
privatevoidbutton5_Click(objectsender,EventArgse)
{
this.Hide();
Form4form4=newForm4();
form4.Show();
}
privatevoidbutton2_Click(objectsender,EventArgse)
{
loadUsers();
MessageBox.Show("更新成功");
}
privatevoidbutton1_Click(objectsender,EventArgse)
{
if(textBox1.Text==""||textBox2.Text=="")
MessageBox.Show("请输入要查找的信息!
","提示信息");
else
{
stringconnectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";//access文件
stringOleDbString="select*from[Message]whereSno='"+this.textBox2.Text+"'";
OleDbConnectionconnection=newOleDbConnection(connectionString);
DataSetds=newDataSet();
try
{
connection.Open();
OleDbDataAdaptercommand=newOleDbDataAdapter(OleDbString,connection);
command.Fill(ds,"Message");
}
catch(OleDbExceptionex)
{
thrownewException(ex.Message);
}
//将表绑定到dataGridView1控件
this.dataGridView1.DataSource=ds.Tables[0];
this.dataGridView1.Columns[0].ReadOnly=true;//先0列,即用户名列为关键定不许修改
connection.Close();
}
}
privatevoidForm3_FormClosing(objectsender,FormClosingEventArgse)
{
Application.Exit();
}
publicstringFindstring1()
{
stringAfile="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";//access文件
OleDbConnectionAconnStr=newOleDbConnection(Afile);
OleDbCommandAcmd=newOleDbCommand("select[基本工资]from[Message],[工资]whereSno='"+textBox2.Text+"'andMessage.员工工种=工资.员工工种andMessage.工资等级=工资.工资等级",AconnStr);
OleDbDataReaderodr=null;
AconnStr.Open();
try
{
odr=Acmd.ExecuteReader();
}
catch(Exceptionex)
{
if(ex!
=null)returnnull;
}
if(odr!
=null)
{
while(odr.Read())
{returnodr[0].ToString();}
odr.Close();
}
AconnStr.Close();
returnnull;
}
publicstringFindday()
{
stringAfile="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";//access文件
OleDbConnectionAconnStr=newOleDbConnection(Afile);
OleDbCommandAcmd=newOleDbCommand("select[考勤天数]from[Message]whereSno='"+textBox2.Text+"'",AconnStr);
OleDbDataReaderodr=null;
AconnStr.Open();
try
{
odr=Acmd.ExecuteReader();
}
catch(Exceptionex)
{
if(ex!
=null)returnnull;
}
if(odr!
=null)
{
while(odr.Read())
{returnodr[0].ToString();}
odr.Close();
}
AconnStr.Close();
returnnull;
}
publicstringFindstring2()
{
stringAfile="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";//access文件
OleDbConnectionAconnStr=newOleDbConnection(Afile);
OleDbCommandAcmd=newOleDbCommand("select[日工资]from[Message],[工资]whereSno='"+textBox2.Text+"'andMessage.员工工种=工资.员工工种andMessage.工资等级=工资.工资等级",AconnStr);
OleDbDataReaderodr=null;
AconnStr.Open();
try
{
odr=Acmd.ExecuteReader();
}
catch(Exceptionex)
{
if(ex!
=null)returnnull;
}
if(odr!
=null)
{
while(odr.Read())
{returnodr[0].ToString();}
odr.Close();
}
AconnStr.Close();
returnnull;
}
publicstringFindstring3()
{
stringAfile="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:
\\Users\\lenovo\\Desktop\\C#\\db.mdb;PersistSecurityInfo=True";//access文件
OleDbConnectionAconnStr=newOleDbConnection(Afile);
OleDbCommandAcmd=newOleDbCommand("select[员工津贴]from[Message],[工资]whereSno='"+textBox2.Text+"'andMessage.员工工种=工资.员工工种andMessage.工资等级=工资.工资等级",AconnStr);
OleDbDataReaderodr=null;
AconnStr.Open();
try
{
odr=Acmd.ExecuteReader();
}
catch(Exceptionex)
{
if(ex!
=null)returnnull;
}
if(odr!
=null)
{
while(odr.Read())
{returnodr[0].ToString();}
odr.Close();
}
AconnStr.Close();
returnnull;
}
privatevoidbutton3_Click(objectsender,EventArgse)
{
if(textBox1.Text==""||textBox2.Text=="")
MessageBox.Show("请输入要查找的信息!
","提示信息");
else
{
string1=int.Parse(Findstring1().ToString());
string2=int.Parse(Findstring2().ToString());
day=int.Parse(Findday().ToString());
string3=i
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 员工 工资管理 界面设计