1、数据库原理及应用课程设计报告 数据库原理及应用课程设计报告设计题目员工信息管理系统系统专业:计算机科学与技术班级:10计算机科学与技术(2)班姓名:曹 锋100312202程 昞100312206刘 劝100312223孙志强100312232王海川100312233谢 凯100312241指导老师:黄孝年 月日学号1003122020623323341姓名曹 锋程 昞刘 劝孙志强王海川谢 凯评价CCABBC开发背景 对于一个只有十个以下员工的企业来说,老板可以凭借自己的记忆力记住员工的基本信息、简历、工资信息等资料。 但是对于一个几十人、上百人、甚至上千人的企业来说,光凭管理者的记忆力肯定是
2、不够的,采用手工记账的方式会非常不方便。如果有一款管理软件能够完成公司员工信息的管理,这样会大大减轻管理者的负担。 需求分析 一个典型的员工信息管理系统需要有下面的功能: 需要有一个记录员工的员工编号、姓名、性别、籍贯、出生日期、住址等基本信息的员工基本信息管理模块; 需要有一个能够管理员工的学历、毕业院校、毕业时间、工作经历等信息的员工简历信息管理模块; 需要有一个能够管理员工的基本工资、奖金、个税、实发工资、发工资时间等信息的员工工资信息管理模块。绘制用例图设计系统功能 绘制用例图设计系统功能 系统开发环境 系统开发平台:Visual C+ 6.0。 数据库管理系统软件:Access 20
3、03。 运行平台:win7数据库分析 数据库概念设计 1,员工基本信息2.员工简历信息3. 员工工资信息数据库逻辑结构设计 1.“basicInfo”表的逻辑结构字段名数据类型是否主键描述id文本(varchar)是员工编号name文本(varchar否员工姓名sex文本(varchar)否性别home文本(varchar)否籍贯birthday文本(varchar)否出生日期phone_number文本(varchar)否电话号码status文本(varchar)否现任职务address文本(varchar)否家庭住址2.“work_resume”表的逻辑结构字段名数据类型是否主键描述id文
4、本(varchar)是员工编号name文本(varchar否员工姓名highest_degree文本(varchar)否最高学位highest_degree_time整数(int)否毕业时间college_school_name文本(varchar)否大学学校名称work_experience1文本(varchar)否工作经历1work_experience2文本(varchar)否工作经历2work_experience3文本(varchar)否工作经历33.“salary”表的逻辑结构字段名数据类型是否主键描述id文本(varchar)是员工编号name文本(varchar否员工姓名bas
5、ic整数(int)否基本工资bonus整数(int)否奖金tax整数(int)否个人税total整数(int)否实发工资year_month文本(varchar)否发工资年月应用系统界面的设计登陆口令登陆界面主界面员工基本信息添加信息修改性别删除该信息刘劝密码修改程序及代码登陆口令void CDlgLogin:OnOK() / TODO: Add extra validation hereCString username,password;/定义两个字符串变量m_edit_UserName.GetWindowText(username);/将文本框中的值赋给usernamem_edit_pas
6、sword.GetWindowText(password);/将文本框中的值赋给帕passwordm_logined_user = username; if(!m_database.IsOpen()/如果数据没有打开,则打开数据库if(m_database.Open(_T(StaffManageSystem)/如果正确打开数据库m_recordSet.m_pDatabase=&m_database;/将m_database对象赋给m_pDatabaseCString strSQL;strSQL.Format(select * from UserInfo where name=%s and pa
7、ssword=%s,username, password); m_recordSet.Open(CRecordset:forwardOnly,strSQL);/打开记录集if(m_recordSet.GetRecordCount()=0)/如果找不到记录MessageBox(密码错误,请重新输入,密码错误,MB_OK|MB_ICONWARNING);/提示密码错误 m_edit_password.SetWindowText();/清空密码文本框 m_edit_password.SetFocus();/设置用户名文本框为当前的焦点else/如果找到记录 CDialog:OnOK();/进入到主窗
8、口m_recordSet.Close();/关闭记录集m_database.Close();/关闭数据库else/如果没有正确打开数据库MessageBox(不能打开数据库);修改密码按键void CDlgAddUser:OnOK() / TODO: Add extra validation hereUpdateData();/判断新密码是是为空if(m_add_user_password.IsEmpty()|m_add_confirm_password.IsEmpty()MessageBox(密码不为空);elseif (m_add_confirm_password != m_add_use
9、r_password)MessageBox(两次输入密码不一致,请重新输入新密码);m_add_confirm_password.Empty();m_add_user_password.Empty();UpdateData(FALSE);elseCDialog:OnOK();添加员工基本信息void CCase1View:OnAddBasicinfo() / TODO: Add your command handler code herem_dlgBasicInfo.m_addFlag = true;m_dlgBasicInfo.m_editFlag = false;/-/ 调用“员工基本信息
10、管理”对话框if (IDCANCEL = m_dlgBasicInfo.DoModal()return;/-/ 新的员工基本信息写入数据库CString strSexInfo;if (m_dlgBasicInfo.m_sex = 0)strSexInfo = 男;else if (m_dlgBasicInfo.m_sex = 1)strSexInfo = 女;elseMessageBox(请选择员工性别);if(m_dlgBasicInfo.m_str_id.IsEmpty() | (m_dlgBasicInfo.m_str_name.IsEmpty()MessageBox(员工编号和姓名不能
11、为空);elseCString strSQL;strSQL.Format(INSERT INTO basicInfo (id, name, sex, home, birthday, phone_number, status, address) VALUES (%s, %s, %s, %s, %s, %s, %s, %s), m_dlgBasicInfo.m_str_id, m_dlgBasicInfo.m_str_name, strSexInfo, m_dlgBasicInfo.m_str_home, m_dlgBasicInfo.m_str_birth_day,m_dlgBasicInfo.
12、m_str_phone, m_dlgBasicInfo.m_str_status, m_dlgBasicInfo.m_str_address);m_Db.ExecuteSQL(strSQL); AfxMessageBox(员工基本信息添加完毕!);strSQL = select * from basicInfo;DrawBasicInfoList(strSQL);员工简历信息按键void CCase1View:OnAddResume() / TODO: Add your command handler code herem_dlgResume.m_addFlag = true;m_dlgRes
13、ume.m_editFlag = false;/-/打开“员工简历管理”对话框if (IDCANCEL = m_dlgResume.DoModal()return;/-/ 新的简历信息写入数据库if(m_dlgResume.m_str_id.IsEmpty() | (m_dlgResume.m_str_name.IsEmpty()MessageBox(员工编号和姓名不能为空);elseCString strSQL;strSQL.Format(INSERT INTO work_resume (id, name, highest_degree, highest_degree_time, colle
14、ge_school_name, work_experience1, work_experience2, work_experience3) VALUES (%s, %s, %s, %d, %s, %s, %s, %s), m_dlgResume.m_str_id, m_dlgResume.m_str_name, m_dlgResume.m_str_degree,atoi(m_dlgResume.m_str_grad_year), m_dlgResume.m_str_school, m_dlgResume.m_str_work_exp1, m_dlgResume.m_str_work_exp2,
15、 m_dlgResume.m_str_work_exp3);m_Db.ExecuteSQL(strSQL);AfxMessageBox(员工简历信息添加完毕!);strSQL = select * from work_resume;DrawResumeList(strSQL);/-员工工资信息按键void CCase1View:OnAddSalary() / TODO: Add your command handler code herem_dlgSalary.m_addFlag = true;m_dlgSalary.m_editFlag = false;/-/打开“员工工资管理”对话框if
16、(IDCANCEL = m_dlgSalary.DoModal()return;/-/ 新的工资信息写入数据库if(m_dlgSalary.m_str_id.IsEmpty() | (m_dlgSalary.m_str_name.IsEmpty()MessageBox(员工编号和姓名不能为空);elseint i_total = atoi(m_dlgSalary.m_str_basic_salary) + atoi(m_dlgSalary.m_str_bonus) - atoi(m_dlgSalary.m_str_tax);CString strSQL;strSQL.Format(INSERT
17、 INTO salary (id, name, basic, bonus, tax, total, year_month) VALUES (%s, %s, %d, %d, %d, %d, %s), m_dlgSalary.m_str_id, m_dlgSalary.m_str_name, atoi(m_dlgSalary.m_str_basic_salary),atoi(m_dlgSalary.m_str_bonus), atoi(m_dlgSalary.m_str_tax),i_total, m_dlgSalary.m_str_date);m_Db.ExecuteSQL(strSQL);Af
18、xMessageBox(员工工资信息添加完毕!);strSQL = select * from salary;DrawSalaryList(strSQL);/-员工基本信息表修改按键void CCase1View:OnEditBasicinfo() / TODO: Add your command handler code herem_dlgBasicInfo.m_addFlag = false;m_dlgBasicInfo.m_editFlag = true;/-/ 获取用户要编辑的记录的行号int row= -1;row= m_list_basicinfo.GetSelectionMark
19、();if (-1 = row)AfxMessageBox(请在列表框中选择要修改的用户记录!);/-/ 将显示员工基本信息的列表框中的第row行记录赋值到“员工基本信息管理”对话框中相应的控件变量中CString strTemp;strTemp = m_list_basicinfo.GetItemText(row, 0);m_dlgBasicInfo.m_str_id = strTemp;strTemp = m_list_basicinfo.GetItemText(row, 1);m_dlgBasicInfo.m_str_name = strTemp;strTemp = m_list_bas
20、icinfo.GetItemText(row, 2);if (男 = strTemp)m_dlgBasicInfo.m_sex = 0;else m_dlgBasicInfo.m_sex = 1;strTemp = m_list_basicinfo.GetItemText(row, 3);m_dlgBasicInfo.m_str_home = strTemp;strTemp = m_list_basicinfo.GetItemText(row, 4);m_dlgBasicInfo.m_str_birth_day = strTemp;strTemp = m_list_basicinfo.GetI
21、temText(row, 5);m_dlgBasicInfo.m_str_phone = strTemp;strTemp = m_list_basicinfo.GetItemText(row, 6);m_dlgBasicInfo.m_str_status = strTemp;strTemp = m_list_basicinfo.GetItemText(row, 7);m_dlgBasicInfo.m_str_address = strTemp;/-/ 调用“员工基本信息管理”对话框if (IDCANCEL = m_dlgBasicInfo.DoModal()return;/-/ 将“员工基本信
22、息管理”对话框中更改后的数据写入数据库CString strSexInfo;if (m_dlgBasicInfo.m_sex =0)strSexInfo = 男;else if (m_dlgBasicInfo.m_sex = 1)strSexInfo = 女;elseMessageBox(请选择员工性别);if(m_dlgBasicInfo.m_str_id.IsEmpty() | (m_dlgBasicInfo.m_str_name.IsEmpty()MessageBox(员工编号和姓名不能为空);elseCString strSQL;strSQL.Format(UPDATE basicIn
23、fo SET name=%s, sex=%s, home=%s, birthday=%s, phone_number=%s, status=%s, address=%s WHERE id = %s,m_dlgBasicInfo.m_str_name, strSexInfo, m_dlgBasicInfo.m_str_home, m_dlgBasicInfo.m_str_birth_day, m_dlgBasicInfo.m_str_phone, m_dlgBasicInfo.m_str_status, m_dlgBasicInfo.m_str_address, m_dlgBasicInfo.m
24、_str_id);m_Db.ExecuteSQL(strSQL);AfxMessageBox(员工基本信息修改完毕!);strSQL = select * from basicInfo;DrawBasicInfoList(strSQL);/-员工基本信息表删除按键void CCase1View:OnDeleteBasicinfo() / TODO: Add your command handler code here/-/ 获取用户要删除的记录的行号int row= -1;row= m_list_basicinfo.GetSelectionMark();if (-1 = row)AfxMess
25、ageBox(请在列表框中选择要修改的用户记录!);/-/ 获取用户要删除的员工的员工编号CString strTemp;strTemp = m_list_basicinfo.GetItemText(row, 0);/-/ 删除所选记录CString strSql;if(IDYES = AfxMessageBox(确定要删除该记录吗?, MB_YESNO)strSql.Format(DELETE FROM basicInfo WHERE id = %s, strTemp);m_Db.ExecuteSQL(strSql);AfxMessageBox(该记录已删除!);strSql = selec
26、t * from basicInfo;DrawBasicInfoList(strSql);/-void CCase1View:OnDeleteResume() / TODO: Add your command handler code here/-/ 获取用户要删除的记录的行号int row= -1;row= m_list_resume.GetSelectionMark();if (-1 = row)AfxMessageBox(请在列表框中选择要修改的用户记录!);/-/ 获取用户要删除的员工的员工编号CString strTemp;strTemp = m_list_resume.GetIte
27、mText(row, 0);/-/ 删除所选记录CString strSql;if(IDYES = AfxMessageBox(确定要删除该记录吗?, MB_YESNO)strSql.Format(DELETE FROM work_resume WHERE id = %s, strTemp);m_Db.ExecuteSQL(strSql);AfxMessageBox(该记录已删除!);strSql = select * from work_resume;DrawResumeList(strSql);/-void CCase1View:OnDeleteSalary() / TODO: Add y
28、our command handler code here/-/ 获取用户要删除的记录的行号int row= -1;row= m_list_salary.GetSelectionMark();if (-1 = row)AfxMessageBox(请在列表框中选择要修改的用户记录!);/-/ 获取用户要删除的员工的员工编号CString strTemp;strTemp = m_list_salary.GetItemText(row, 0);/-/ 删除所选记录CString strSql;if(IDYES = AfxMessageBox(确定要删除该记录吗?, MB_YESNO)strSql.F
29、ormat(DELETE FROM salary WHERE id = %s, strTemp);m_Db.ExecuteSQL(strSql);AfxMessageBox(该记录已删除!);strSql = select * from salary;DrawSalaryList(strSql);/-员工简历信息表修改按键void CCase1View:OnEditResume() / TODO: Add your command handler code herem_dlgResume.m_addFlag = false;m_dlgResume.m_editFlag = true;/-/ 获
30、取用户要编辑的记录的行号int row= -1;row= m_list_resume.GetSelectionMark();if (-1 = row)AfxMessageBox(请在列表框中选择要修改的用户记录!);return;/-/ 将显示员工基本信息的列表框中的第row行记录赋值到“员工简历管理”对话框中相应的控件变量中CString strTemp;strTemp = m_list_resume.GetItemText(row, 0);m_dlgResume.m_str_id = strTemp;strTemp = m_list_resume.GetItemText(row, 1);m
31、_dlgResume.m_str_name = strTemp;strTemp = m_list_resume.GetItemText(row, 2);m_dlgResume.m_str_degree = strTemp;strTemp = m_list_resume.GetItemText(row, 3);m_dlgResume.m_str_grad_year = strTemp;strTemp = m_list_resume.GetItemText(row, 4);m_dlgResume.m_str_school = strTemp;strTemp = m_list_resume.GetI
32、temText(row, 5);m_dlgResume.m_str_work_exp1 = strTemp;strTemp = m_list_resume.GetItemText(row, 6);m_dlgResume.m_str_work_exp2 = strTemp;strTemp = m_list_resume.GetItemText(row, 7);m_dlgResume.m_str_work_exp3 = strTemp;/-/打开“员工简历管理”对话框if (IDCANCEL = m_dlgResume.DoModal()return;/-/ 新的简历信息写入数据库if(m_dlg
33、Resume.m_str_id.IsEmpty() | (m_dlgResume.m_str_name.IsEmpty()MessageBox(员工编号和姓名不能为空);elseCString strSQL;strSQL.Format(UPDATE work_resume SET name=%s, highest_degree=%s, highest_degree_time=%d, college_school_name=%s, work_experience1=%s, work_experience2=%s, work_experience3=%s WHERE id = %s,m_dlgRe
34、sume.m_str_name, m_dlgResume.m_str_degree, atoi(m_dlgResume.m_str_grad_year),m_dlgResume.m_str_school, m_dlgResume.m_str_work_exp1,m_dlgResume.m_str_work_exp2, m_dlgResume.m_str_work_exp3, m_dlgResume.m_str_id);m_Db.ExecuteSQL(strSQL);AfxMessageBox(员工简历信息修改完毕!);strSQL = select * from work_resume;DrawResumeList(strSQL);/-员工工资信息表修改按键void CCase1View:OnEditSalary() / TODO: Add your command handler code herem_dlgSalary.m_addFlag = false;m_dlgSalary.m_editFlag = true;/-/ 获取用户要编辑的记录的行号int row= -1;row= m_list_salary.GetSelectionMark();if (-1 = row)AfxMessageBox(请在列表框中选择要修改的用户记录!);return;/-/ 将显示员工基本信息