《数据库课程设计---人事管理系统.doc》由会员分享,可在线阅读,更多相关《数据库课程设计---人事管理系统.doc(137页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Four short words sum up what has lifted most successful individuals above the crowd: a little bit more.-author-date数据库课程设计-人事管理系统福 建 工 程 学 院福 建 工 程 学 院课程设计课 程: 数据库课程设计 题 目: 人事管理系统 专 业: 信息管理与信息系统 班 级: 0903 座 号: 01、02 姓 名: 王美荷 许飞宾 2011年 2 月 21 日一、系统定义一个公司的管理离不开人事管理,对于现代社会的公司管理,人事管理系统是不可或缺的一部分,它为人事管理部门
2、的工作人员提供多种方式的人事查询以及统计功能,另外还提供对企业的人事调动(包括添加新员工、人员退休、人员辞职等)、人员信息的改动(包括职工增加工资、给退休员工发放退休金等)以及查询企业员工信息等操作。二、需求分析1、系统功能的基本要求:1)员工各种信息的输入与修改,包括员工的基本信息、学历信息、婚姻状况信息、职称,简历,考核结果等。2)对于转出、辞职、辞退、退休员工信息的处理;3)按照一定的条件,查询、统计符合条件的员工信息;2、给出系统的逻辑模型:数据流程图、数据字典第一层数据流图 1 员工信息管理数据流图2 部门信息管理数据流图 3 人事调动数据流图 4 工资管理数据流第二层数据流三、系统
3、设计1、概念结构设计画出系统E-R图。各分E-R图2、逻辑结构设计员工(工号,名字,性别,出生日期,部门号,职务,学历,电话,ID)部门(部门号,部门名称,部门人数,职能描述)工资(工号,工资)加班(员工号,月份,姓名,天数,钱)奖金(员工号,月份,姓名,钱)出勤表(工号,考勤日期,全勤天数,迟到天数,病假天数,事假天数)用户表1(用户名,密码)用户表2(用户名,密码)考核表(工号,名字,考核时间,交际能力,专业能力,身体能力)离职表(工号,名字,性别,出生日期,部门号,职务,学历,电话,ID)3、系统功能模块图4、其它设计图形工具四、详细设计存储过程:Create procedure bum
4、engengxin1Dcount int,Dno char(2)as update department set Dcount=Dcount where Dno=Dnocreate procedure bumeninsertDno char(2),Dname char(10),Dcount int,Djianjie char(40)as insert into department values(Dno,Dname,Dcount,Djianjie)create PROCEDURE charu Eno char(10) , Dno char(10) , Ename char(20), Esex
5、char(2), Ebir char(20), Ezhiwu char(10), Exueli char(10), Etel char(11), EID char(18)AS INSERT INTO employee VALUES(Eno,Dno,ename,esex,ebir,ezhiwu,exueli,etel,eid)Create PROCEDURE chaxun Eno char(10) AS SELECT * FROM employee where Eno=Eno create procedure gengxinbno char(10),Eno char(10),Dno char(1
6、0) ,Ename char(20),Esex char(2),Ebir char(20),Ezhiwu char(10),Exueli char(10),Etel char(11),EID char(18)as update employee set Eno=Eno,Dno=Dno,Ename=Ename,Esex=Esex,Ebir=Ebir,Ezhiwu=Ezhiwu,Exueli=Exueli,Etel=Etel,EID=EIDwhere Eno=bnocreate procedure gengxin3Eno char(10),Ename char(20) ,data char(10)
7、,jiaoji char(4),zhuanye char(4),shenti char(4)as update kaohe set Eno=Eno,Ename=Ename,data=data,交际能力=jiaoji,专业技能=zhuanye,身体素质=shenti where Eno=Eno and data=datacreate procedure guanliyuan5Gno char(10),password char(10)as update guanliyuan set Gpassword=password where Gno=Gno -and Gpassword=passwordc
8、reate procedure Kcharueno char(10),ename char(20),data char(10),jineng1 char(10),jineng2 char(10),jineng3 char(10)as insert into kaohe values(eno,ename,data,jineng1,jineng2,jineng3) create procedure suangongziEno char(10),date char(2),gongzit char(5) outputas declare gongzi int,money1 int,money2 int
9、,chidao int,shijia int,bingjia int,gongzi1 int,Jmoney int,Amoney int select chidao=chidao,bingjia =bingjia,shijia= shijia,gongzi1= gongzi,Jmoney=Jmoney,Amoney=Amoney from yuegongzi where Eno=Eno and Jyuefen=date if chidao3begin set money1=(chidao-3)*10endelse set money1=0 set money2=(shijia+bingjia)
10、*50 set gongzi=gongzi1+Jmoney+Amoney-money1-money2 set gongzit=convert(varchar(5),gongzi) print 钱+gongzitcreate PROCEDURE tianjia Dno char(10) , Dname char(20), Dcount int, jianjie char(40)AS INSERT INTO department VALUES(Dno,dname,Dcount,jianjie)create procedure yuangong1Yno char(10),password char(
11、10)as update yuangong set Ypassword=password where Yno=Ynocreate procedure yuangongalterEno char(10),Ename char(10),Esex char(2),Etel char(11)asupdate employeeset Ename=Ename,Esex=Esex,Etel=Etelwhere Eno=Eno触发器CREATE TRIGGER trig_lizhi ON employee FOR DELETE AS print 开始备份数据,请稍后. IF NOT EXISTS(SELECT
12、 * FROM sysobjects WHERE name=lizhi) SELECT * INTO lizhi FROM deleted ELSE INSERT INTO lizhi SELECT * FROM deleted print 备份数据成功,备份表中的数据为: SELECT * FROM lizhi GO Create TRIGGER trig_zhuanchu ON employee FOR update AS declare zhiwu char(10),no char(10) SELECT zhiwu=Ezhiwu ,no=Dno FROM inserted CREATE
13、TRIGGER trig_jiaban ON yuegongzi FOR INSERT AS SELECT Eno,Ename,tianshu,Ayuefen,Amoney into jiaban FROM inserted select Eno,Ename,Jmoney,Jyuefen into jiangjin from inserted select Eno,Ename,Jyuefen,chidao,bingjia,shijia 创建月工资表select jiaban.Eno,jiaban.Ename,salary.gongzi,jiaban.tianshu,jiaban.Amoney,
14、chuqin.chidao,chuqin.bingjia,chuqin.shijia,jiangjin.Jmoney,jiangjin.Jyuefeninto yuegongzi from jiaban,jiangjin,chuqin,salary where salary.Eno=jiaban.Eno and jiaban.Eno=jiangjin.Eno and jiangjin.Eno=chuqin.Eno and jiaban.Ayuefen=chuqin.data and chuqin.data=jiangjin.JyuefenGROUP BY salary.Eno,jiaban.E
15、no,jiangjin.Eno,jiaban.tianshu,chuqin.Eno,jiaban.Ayuefen,chuqin.data,jiangjin.Jyuefen,salary.gongzi,jiaban.Amoney,chuqin.chidao,chuqin.bingjia,chuqin.shijia,jiangjin.Jmoney,jiangjin.Jyuefen,jiaban.Ename主要的表1、出勤表2、部门表3、员工表4、管理员登入用户表5、加班表6、奖金表7、考核表8、离职表9、固定工资表10、员工登入表11、算工资的表12、转出表五、系统实现与测试1、开发平台和工具选择
16、说明选择原因、环境要求等。2、系统测试连接数据库的代码:procedure TForm1.Button1Click(Sender: TObject);begindatamodule3.adoconnection1.Close;datamodule3.adoconnection1.ConnectionString:=provider=SQLOLEDB.1;Password=+edit3.Text+;Persist Security Info=true;User ID=+edit2.Text+;Initial Catalog=+combobox1.text+;Data Source=+edit1.
17、Text;datamodule3.adoquery1.Connection:=datamodule3.adoconnection1;datamodule3.adoconnection1.LoginPrompt:=false;datamodule3.datasource1.DataSet:=datamodule3.adoquery1;dbgrid1.DataSource:=datamodule3.datasource1; form2.show;end;procedure TForm1.ComboBox1DropDown(Sender: TObject);var i:integer;begin d
18、atamodule3.adoconnection1.ConnectionString:=provider=SQLOLEDB.1;Password=+edit3.Text+;Persist Security Info=true;User ID=+edit2.Text+;Initial Catalog=master;Data Source=+edit1.Text;datamodule3.adoconnection1.LoginPrompt:=false;datamodule3.adoquery2.Connection:=datamodule3.adoconnection1;datamodule3.
19、adoconnection1.LoginPrompt:=false;datamodule3.adoquery2.Close;datamodule3.adoquery2.sql.Clear;datamodule3.adoquery2.SQL.Add(select * from sysdatabases); datamodule3.adoquery2.Open;for i:=0 to datamodule3.adoquery2.RecordCount-1 dobegin combobox1.Items.Add(datamodule3.adoquery2.FieldValuesname);datam
20、odule3.adoquery2.Next;end;end;end.登入界面的代码:procedure TForm2.Button1Click(Sender: TObject);begin if radiobutton1.Checked then begin datamodule3.adoquery1.Close; datamodule3.adoquery1.SQL.Clear; datamodule3.adoquery1.SQL.Add(select *from guanliyuan); datamodule3.adoquery1.SQL.Add(where Gno=+edit1.text+
21、 and Gpassword=+edit2.Text+); datamodule3.adoquery1.Open; if datamodule3.adoquery1.RecordCount0 then begin form1.hide; form4.show; end else showmessage(用户名不存在或者权限错误,请查证后输入); edit2.Clear end else if radiobutton2.Checked then begin datamodule3.adoquery1.Close; datamodule3.adoquery1.SQL.clear; datamodu
22、le3.adoquery1.SQL.add(select * from yuangong); datamodule3.adoquery1.SQL.add(where Yno=+edit1.text+ and Ypassword=+edit2.text+); datamodule3.adoquery1.Open; if datamodule3.adoquery1.RecordCount0 then begin form1.hide; form5.show; end else showmessage(用户名不存在或者权限错误,请查证后输入); edit2.Clear; end;end;proced
23、ure TForm2.Button2Click(Sender: TObject);begin form2.Close;end;end.代码:procedure TForm4.N2Click(Sender: TObject);begin form6.show;end;procedure TForm4.RadioButton1Click(Sender: TObject);begin form6.Show;end;procedure TForm4.RadioButton2Click(Sender: TObject);begin form7.show;end;procedure TForm4.Radi
24、oButton6Click(Sender: TObject);begin form4.close;end;procedure TForm4.RadioButton3Click(Sender: TObject);begin form8.show; end;procedure TForm4.RadioButton4Click(Sender: TObject);begin form12.show;end;procedure TForm4.RadioButton5Click(Sender: TObject);begin form10.show;end;end.代码:procedure TForm5.R
25、adioButton5Click(Sender: TObject);begin form5.close;end;procedure TForm5.RadioButton1Click(Sender: TObject);begin form14.show; end;procedure TForm5.RadioButton4Click(Sender: TObject);begin form17.show;end;procedure TForm5.RadioButton3Click(Sender: TObject);begin form15.show;end;procedure TForm5.Radi
26、oButton2Click(Sender: TObject);begin form16.show;end;end.代码:procedure TForm6.Button5Click(Sender: TObject);beginform6.close;end;procedure TForm6.Button1Click(Sender: TObject);begin with DataModule3.ADOquery3 do begin Close; /修改SQL语句之前先关闭Query组件 SQL.Clear; / 清除旧的SQL语句 sql.Add(exec charu +edit1.text+,
27、+edit2.text+,+edit3.text+,+edit4.text+,+edit5.text+,+edit6.text+,+edit7.text+,+edit8.text+,+edit9.Text+); ExecSQL; Close; SQL.Clear; SQL.Add(SELECT * FROM employee ); Open; end;end;procedure TForm6.Button3Click(Sender: TObject);begin datamodule3.adoquery3.Connection:=datamodule3.adoconnection1; data
28、module3.datasource1.DataSet:=datamodule3.adoquery3; dbgrid1.DataSource:=datamodule3.datasource1; with DataModule3.ADOquery3 do begin Close; /修改SQL语句之前先关闭Query组件 SQL.Clear; / 清除旧的SQL语句 sql.Add(select *from employee); sql.Add(where Eno=+edit10.text+); open; end;end;procedure TForm6.Button2Click(Sender
29、: TObject);begin with DataModule3.ADOquery3 do begin Close; /修改SQL语句之前先关闭Query组件 SQL.Clear; / 清除旧的SQL语句 sql.Add(exec gengxin +edit10.text+,+edit1.text+,+edit2.text+,+edit3.text+,+edit4.text+,+edit5.text+,+edit6.text+,+edit7.text+,+edit8.text+,+edit9.Text+); ExecSQL; Close; SQL.Clear; SQL.Add(SELECT
30、* FROM employee ); sql.Add(where Eno=+edit10.text+); Open; end;end;procedure TForm6.Button4Click(Sender: TObject);begin form11.show;end;procedure TForm6.DBGrid1CellClick(Column: TColumn);begin Edit1.Text:=datamodule3.adoquery3.fieldbyname(Eno).AsString; Edit2.Text:=datamodule3.adoquery3.fieldbyname(
31、Dno).AsString; Edit3.Text:=datamodule3.adoquery3.fieldbyname(Ename).AsString; Edit4.Text:=datamodule3.adoquery3.fieldbyname(Esex).AsString; Edit5.Text:=datamodule3.adoquery3.fieldbyname(Ebir).AsString; Edit6.Text:=datamodule3.adoquery3.fieldbyname(Ezhiwu).AsString; Edit7.Text:=datamodule3.adoquery3.
32、fieldbyname(Exueli).AsString; Edit8.Text:=datamodule3.adoquery3.fieldbyname(Etel).AsString; Edit9.Text:=datamodule3.adoquery3.fieldbyname(EID).AsString;end;end.代码:procedure TForm7.Button1Click(Sender: TObject);begin datamodule3.adoquery3.Connection:=datamodule3.adoconnection1; datamodule3.datasource
33、1.DataSet:=datamodule3.adoquery3; dbgrid1.DataSource:=datamodule3.datasource1; with DataModule3.ADOquery3 do begin Close; /修改SQL语句之前先关闭Query组件 SQL.Clear; / 清除旧的SQL语句 sql.Add(exec bumeninsert +edit1.text+,+edit2.text+,+edit3.text+,+Memo1.lines0+); ExecSQL; Close; SQL.Clear; SQL.Add(SELECT * FROM depa
34、rtment ); Open; end;end;procedure TForm7.Button2Click(Sender: TObject);begin with DataModule3.ADOquery3 do begin Close; /修改SQL语句之前先关闭Query组件 SQL.Clear; / 清除旧的SQL语句 sql.Add(exec bumengengxin1 +edit3.text+,+edit1.text+); ExecSQL; Close; SQL.Clear; SQL.Add(SELECT * FROM department ); sql.Add(where Dno=
35、+edit1.text+); Open; end;end;procedure TForm7.Button3Click(Sender: TObject);begin datamodule3.adoquery3.Connection:=datamodule3.adoconnection1; datamodule3.datasource1.DataSet:=datamodule3.adoquery3; dbgrid1.DataSource:=datamodule3.datasource1; with DataModule3.ADOquery3 do begin Close; /修改SQL语句之前先关
36、闭Query组件 SQL.Clear; / 清除旧的SQL语句 sql.Add(select *from Department); sql.Add(where Dno=+edit1.text+); open; end;end;procedure TForm7.DBGrid1CellClick(Column: TColumn);begin Edit1.Text:=datamodule3.adoquery3.fieldbyname(Dno).AsString; Edit2.Text:=datamodule3.adoquery3.fieldbyname(Dname).AsString;Edit3.T
37、ext:=datamodule3.adoquery3.fieldbyname(Dcount).AsString; Memo1.lines0:=datamodule3.adoquery3.fieldbyname(Djianjie).AsString; end;end.代码:procedure TForm8.Button1Click(Sender: TObject);var a:string;begin datamodule3.adoquery3.Connection:=datamodule3.adoconnection1; datamodule3.datasource1.DataSet:=dat
38、amodule3.adoquery3; dbgrid1.DataSource:=datamodule3.datasource1; /a:=combobox1.text; with DataModule3.ADOquery3 do begin Close; /修改SQL语句之前先关闭Query组件 SQL.Clear; / 清除旧的SQL语句 sql.Add(select * from yuegongzi); sql.Add(where Eno=+edit1.text+ and Jyuefen=+edit10.text+); open; end;end;procedure TForm8.DBGr
39、id1CellClick(Column: TColumn);begin Edit1.Text:=datamodule3.adoquery3.fieldbyname(Eno).AsString; Edit2.Text:=datamodule3.adoquery3.fieldbyname(Ename).AsString; Edit3.Text:=datamodule3.adoquery3.fieldbyname(gongzi).AsString; Edit4.Text:=datamodule3.adoquery3.fieldbyname(tianshu).AsString; Edit5.Text:
40、=datamodule3.adoquery3.fieldbyname(Amoney).AsString; Edit6.Text:=datamodule3.adoquery3.fieldbyname(chidao).AsString; Edit7.Text:=datamodule3.adoquery3.fieldbyname(bingjia).AsString; Edit8.Text:=datamodule3.adoquery3.fieldbyname(shijia).AsString; Edit9.Text:=datamodule3.adoquery3.fieldbyname(Jmoney).
41、AsString; Edit10.Text:=datamodule3.adoquery3.fieldbyname(Jyuefen).AsString; datamodule3.ADOStoredProc1.Connection:=datamodule3.adoconnection1; datamodule3.datasource1.DataSet:=datamodule3.ADOStoredProc1; dbgrid1.DataSource:=datamodule3.datasource1; DataModule3.ADOStoredProc1.Close; DataModule3.ADOStoredProc1.ProcedureName:=suangongzi; DataModule3.ADOStoredProc1.Param