程序设计文档.doc_第1页
程序设计文档.doc_第2页
程序设计文档.doc_第3页
程序设计文档.doc_第4页
程序设计文档.doc_第5页
已阅读5页,还剩1页未读 继续免费阅读

下载本文档

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

文档简介

数据库建表脚本CREATE TABLE employee ( Id varchar(4) NOT NULL,UserName varchar(50),Telephone varchar(50),office varchar(50),age int,sex varchar(4),salary float,pwd varchar(50);程序主界面员工信息录入窗口界面设计员工信息保存方法代码:void CUserDialog:OnBnClickedOk()/ TODO: 在此添加控件通知处理程序代码UpdateData(TRUE);if(m_strUserId.IsEmpty()AfxMessageBox(请输入工号);return;if(m_strSex.IsEmpty()AfxMessageBox(请输入性别);return;if(m_strUserName.IsEmpty()AfxMessageBox(请输入姓名);if(m_strAge.IsEmpty()AfxMessageBox(请输入年龄);return;if(m_strSalary.IsEmpty()AfxMessageBox(请输入工资数);if(m_strOffice.IsEmpty()AfxMessageBox(请输入岗位);m_bIsNewUser = true;std:ostringstream oss;oss select id from employee where id= m_strUserId execQuery(oss.str().c_str();if(!query.eof()m_bIsNewUser = false;oss.str();int ok = 0;if(m_bIsNewUser)oss insert into employee(Id,UserName,Telephone,office,age,sex,salary) values( m_strUserId , m_strUserName , m_strPhone , m_strOffice , m_strAge , m_strSex , m_strSalary execDML(oss.str().c_str();elseoss update employee set UserName= m_strUserName ,Telephone= m_strPhone ,office= m_strOffice ,age= m_strAge ,sex= m_strSex ,salary= m_strSalary where id= m_strUserId execDML(oss.str().c_str();if(ok GetListCtrl();int cnt = list.GetItemCount();for(int i=0;icnt;i+)list.DeleteItem(0);std:ostringstream oss;oss select Id,UserName,Telephone,office,age,sex,salary from employee where 1=1 ;if(!dlg.m_strUserId.IsEmpty()oss and id like % dlg.m_strUserId ;if(!dlg.m_strUserName.IsEmpty()oss and UserName like % dlg.m_strUserName ;if(!dlg.m_strOffice.IsEmpty()oss and office like % dlg.m_strOffice ;if(!dlg.m_strSortField.IsEmpty()oss order by dlg.m_strSortField execQuery(sql.c_str();while(!q.eof()int col =0;CString strUserId = q.getStringField(col+);CString strUserName = q.getStringField(col+);CString strPhone = q.getStringField(col+);CString strOffice = q.getStringField(col+);CString strAge = q.getStringField(col+);CString strSex = q.getStringField(col+);CString strSalary = q.getStringField(col+);AddOrUpdate(strUserId,strUserName,strSex,strAge,strOffice,strSalary,strPhone);q.nextRow();用户删除代码void CSalaryMgrView:OnDelUser()/ TODO: 在此添加命令处理程序代码CListCtrl& list = this-GetListCtrl();int index = -1;index = list.GetNextItem(-1,LVIS_SELECTED);if(index 0)AfxMessageBox(请选择要删除的行);return;if(AfxMessageBox(确定要删除当前员工吗?,MB_OKCANCEL) != IDOK)return;CString strId = list.GetItemText(index,0);std:ostringstream oss;oss delete from employee where id = (LPCTSTR)strId execDML(sql.c_str();if(ok 0)list.DeleteItem(index);数据库文件备份代码void CSalaryMgrView:OnBackup()/ TODO: 在此添加命令处理程序代码TCHAR pathnameMAX_PATH;GetModuleFileName(NULL,pathname,MAX_PATH);CString path = pathname;path = path.Left(path.ReverseFind()+1);CString strSrc = path + database.db;CString strDst = path;std:string strDBPath = CharsetConvert:GBToUTF8(strSrc);CppSQLite3DB:instance()-close();SYSTEMTIME st;:GetLocalTime(&st);CString strFileName;strFileName.Format(database%04d%02d%02d%02d%02d%02d.db,st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);strDst += strFileName;BOOL fok = :CopyFile(strSrc,strDst,FALSE);if(fok)CString strmsg;strmsg.Format(备份成功,备份文件存

温馨提示

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

评论

0/150

提交评论