📄 staffinfo.cpp
字号:
// StaffInfo.cpp : implementation file
//
#include "stdafx.h"
#include "Rsglxt.h"
#include "StaffInfo.h"
#include "DBaseQuery.h"
#include "ExternDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStaffInfo dialog
CStaffInfo::CStaffInfo(CWnd* pParent /*=NULL*/)
: CDialog(CStaffInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CStaffInfo)
//}}AFX_DATA_INIT
}
void CStaffInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStaffInfo)
DDX_Control(pDX, IDC_COMSNATION, m_Comsnation);
DDX_Control(pDX, IDC_COMTITLE, m_Comtitle);
DDX_Control(pDX, IDC_COMDUTY, m_Comduty);
DDX_Control(pDX, IDC_COMYGXS, m_Comygxs);
DDX_Control(pDX, IDC_COMSQUALI, m_Comsquali);
DDX_Control(pDX, IDC_COMDEP, m_ComDep);
DDX_Control(pDX, IDC_EDIT_STEL, m_EdtStel);
DDX_Control(pDX, IDC_EDIT_SSID, m_EdtSSID);
DDX_Control(pDX, IDC_EDIT_SSCHOOL, m_EdtSschool);
DDX_Control(pDX, IDC_EDIT_SPRO, m_EdtSpro);
DDX_Control(pDX, IDC_EDIT_SNUM, m_EdtSnum);
DDX_Control(pDX, IDC_EDIT_SNAT, m_EdtSnat);
DDX_Control(pDX, IDC_EDIT_SNAM, m_EdtSname);
DDX_Control(pDX, IDC_EDIT_SIID, m_EdtSIID);
DDX_Control(pDX, IDC_EDIT_SID, m_EdtSID);
DDX_Control(pDX, IDC_EDIT_SADDRESS, m_EdtSaddress);
DDX_Control(pDX, IDC_EDIT_REMARK, m_EdtRemark);
DDX_Control(pDX, IDC_DATZTIME, m_DatZtime);
DDX_Control(pDX, IDC_DATTTIME, m_DatTtime);
DDX_Control(pDX, IDC_DATRTIME, m_DatRtime);
DDX_Control(pDX, IDC_BUTADD, m_Butadd);
DDX_Control(pDX, IDC_BUTCHANGE, m_Butchange);
DDX_Control(pDX, IDC_BUTDELETE, m_Butdelete);
DDX_Control(pDX, IDC_BUTEXIT, m_Butexit);
DDX_Control(pDX, IDC_BUTSAVE, m_Butsave);
DDX_Control(pDX, IDC_BUTUNDO, m_Butundo);
DDX_Control(pDX, IDC_COMBO_LEVER, m_ComLever);
DDX_Control(pDX, IDC_COMBO_SINSER, m_ComSinser);
DDX_Control(pDX, IDC_COMBO_SEX, m_ComSex);
DDX_Control(pDX, IDC_COMBO_SMARRY, m_ComSmarry);
DDX_Control(pDX, IDC_DATBIRDATE, m_DatBirtime);
DDX_Control(pDX, IDC_DATBTIME, m_DatBtime);
DDX_Control(pDX, IDC_DATLTIME, m_DatLtime);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStaffInfo, CDialog)
//{{AFX_MSG_MAP(CStaffInfo)
ON_BN_CLICKED(IDC_BUTADD, OnButadd)
ON_BN_CLICKED(IDC_BUTCHANGE, OnButchange)
ON_BN_CLICKED(IDC_BUTDELETE, OnButdelete)
ON_BN_CLICKED(IDC_BUTSAVE, OnButsave)
ON_BN_CLICKED(IDC_BUTUNDO, OnButundo)
ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStaffInfo message handlers
BOOL CStaffInfo::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CDBaseQuery* ParentWnd=(CDBaseQuery*)FindWindow(NULL,"员工档案信息查询");
m_sID=ParentWnd->m_Grid.GetItemText(ParentWnd->m_Grid.GetRow(),0);
m_Comsquali.SelectString(0,"高职");
RxRecordset rs,ts,dutyst,dts,titlest,tst;
rs.Open("部门视图");
m_ComDep.SetRecordset(rs,"部门名称");
ts.Open("select 部门名称 from 部门视图");
m_ComDep.SetFieldset(ts);
this->m_ComDep.m_CurrentFieldType="字符型";
dutyst.Open("职务视图");
m_Comduty.SetRecordset(dutyst,"职务名称");
dts.Open("select 职务名称 from 职务视图");
m_Comduty.SetFieldset(dts);
this->m_Comduty.m_CurrentFieldType="字符型";
titlest.Open("职称视图");
m_Comtitle.SetRecordset(titlest,"职称名称");
tst.Open("select 职称名称 from 职称视图");
m_Comtitle.SetFieldset(tst);
this->m_Comtitle.m_CurrentFieldType="字符型";
m_Comsnation.SelectString(0,"汉族");
this->Display(m_sID);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CStaffInfo::Clear()
{
m_EdtSSID.SetWindowText("");//档案号
m_EdtSID.SetWindowText(""); //员工号
m_EdtSname.SetWindowText(""); //姓名
m_EdtSIID.SetWindowText("");//身份证
m_EdtSnat.SetWindowText("");//籍贯
m_EdtStel.SetWindowText("");//联系方式
m_EdtSaddress.SetWindowText("");//家庭住址
m_EdtSschool.SetWindowText("");//毕业院校
m_EdtSpro.SetWindowText("");//专业
m_EdtRemark.SetWindowText("");//备注
m_EdtSnum.SetWindowText("");//工龄
}
void CStaffInfo::ButtonEnabled(bool bEnabled)
{
m_Comduty.EnableWindow(bEnabled);//档案号
m_Comtitle.EnableWindow(bEnabled); //员工号
m_EdtSname.EnableWindow(bEnabled); //姓名
m_ComDep.EnableWindow(bEnabled);//部门
m_EdtSIID.EnableWindow(bEnabled);//身份证
m_Comsnation.EnableWindow(bEnabled);//民族
m_EdtSnat.EnableWindow(bEnabled);//籍贯
m_EdtStel.EnableWindow(bEnabled);//联系方式
m_EdtSaddress.EnableWindow(bEnabled);//家庭住址
m_Comsquali.EnableWindow(bEnabled);//学历
m_EdtSschool.EnableWindow(bEnabled);//毕业院校
m_EdtSpro.EnableWindow(bEnabled);//专业
m_Comygxs.EnableWindow(bEnabled);//用工形式
m_EdtRemark.EnableWindow(bEnabled);//备注
m_EdtSnum.EnableWindow(bEnabled);//工龄
m_ComSinser.EnableWindow(bEnabled);//在职状态18
m_ComSex.EnableWindow(bEnabled);//性别19
m_ComSmarry.EnableWindow(bEnabled);//婚姻20
m_ComLever.EnableWindow(bEnabled);//工资等级21
m_DatTtime.EnableWindow(bEnabled);//退休日期
m_DatLtime.EnableWindow(bEnabled);//离职日期25
m_DatRtime.EnableWindow(bEnabled);//入职日期22
m_DatBtime.EnableWindow(bEnabled);//毕业时间23
m_DatBirtime.EnableWindow(bEnabled);//出生日期24
m_DatZtime.EnableWindow(bEnabled);//转正日期26
m_Butundo.EnableWindow(bEnabled);
m_Butsave.EnableWindow(bEnabled);
m_Butexit.EnableWindow(!bEnabled);
m_Butdelete.EnableWindow(!bEnabled);
m_Butchange.EnableWindow(!bEnabled);
m_Butadd.EnableWindow(!bEnabled);
}
void CStaffInfo::Display(CString sID)
{
if(sID.IsEmpty())
return;
CString sSQL;
RxRecordset drst;
sSQL.Format("SELECT * FROM 员工信息视图 WHERE 档案号='%s'",sID);
drst.Open(sSQL,adCmdText);
if(drst.GetRecordCount()<1)
return;
CString sSex,sMarry,sSinser,sLevel,sphoto;
CString sSIID, sName,sSID,sDep,sSschool,sStel,sStitle,sSduty,sSaddress,sSSID;
CString sSnation,sSnat,sSquali,sSpro,sSygxs,sSnum,sRemark;
sSSID=drst.GetFieldValue("档案号");//
sSID=drst.GetFieldValue("员工编号");//
sName=drst.GetFieldValue("姓名");//
sSex=drst.GetFieldValue("性别");//
sSnat=drst.GetFieldValue("籍贯");//
sSnation=drst.GetFieldValue("民族");//
sSIID=drst.GetFieldValue("身份证号");//
sMarry=drst.GetFieldValue("婚姻状况");//
sStel=drst.GetFieldValue("联系电话");//
sSaddress=drst.GetFieldValue("家庭住址");//
sSschool=drst.GetFieldValue("毕业院校");//
sSpro=drst.GetFieldValue("专业");//
sSquali=drst.GetFieldValue("学历");//
sDep=drst.GetFieldValue("部门");//
sSduty=drst.GetFieldValue("职务");//
sStitle=drst.GetFieldValue("职称");//
sSinser=drst.GetFieldValue("在职状态");//
sSygxs=drst.GetFieldValue("用工形式");//
sLevel=drst.GetFieldValue("工资等级");//
sSnum=drst.GetFieldValue("工龄");//
sRemark=drst.GetFieldValue("备注");//
CString time1,time2,time3,time4,timel,timet;
CTime Birtime,Btime,Rtime,Ztime,Ltime,Ttime,timeleave,timetx;
time1=drst.GetFieldValue("出生日期");
Birtime=CStringTOCTime(time1);
//
time2=drst.GetFieldValue("毕业时间");
Btime=CStringTOCTime(time2);
//
time3=drst.GetFieldValue("入职日期");
Rtime=CStringTOCTime(time3);
//
time4=drst.GetFieldValue("转正日期");
Ztime=CStringTOCTime(time4);
//
timel=drst.GetFieldValue("离职日期");
timeleave=CStringTOCTime(timel);
//
timet=drst.GetFieldValue("退休日期");
timetx=CStringTOCTime(timet);
m_EdtSSID.SetWindowText(sSSID);//档案号1
m_EdtSID.SetWindowText(sSID); //员工号2
m_EdtSname.SetWindowText(sName); //姓名3
m_ComDep.SetWindowText(sDep);//部门4
m_EdtSIID.SetWindowText(sSIID);//身份证5
m_Comsnation.SetWindowText(sSnation);//民族6
m_EdtSnat.SetWindowText(sSnat);//籍贯7
m_EdtStel.SetWindowText(sStel);//联系方式8
m_EdtSaddress.SetWindowText(sSaddress);//家庭住址9
m_Comsquali.SetWindowText(sSquali);//学历10
m_EdtSschool.SetWindowText(sSschool);//毕业院校11
m_EdtSpro.SetWindowText(sSpro);//专业12
m_EdtSnum.SetWindowText(sSnum);//工龄13
m_Comduty.SetWindowText(sSduty);//职务14
m_Comtitle.SetWindowText(sStitle);//职称15
m_Comygxs.SetWindowText(sSygxs);//用工形式16
m_EdtRemark.SetWindowText(sRemark);//备注17
/////080926xlw
m_ComSinser.SetWindowText(sSinser);//在职状态18
m_ComSex.SetWindowText(sSex);//性别19
m_ComSmarry.SetWindowText(sMarry);//婚姻20
m_ComLever.SetWindowText(sLevel);//工资等级21
/////080926xlw
this->m_DatTtime.SetTime(&timetx);//退休日期
this->m_DatLtime.SetTime(&timeleave);//离职日期25
this->m_DatRtime.SetTime(&Rtime);//入职日期22
this->m_DatBtime.SetTime(&Btime);//毕业时间23
this->m_DatBirtime.SetTime(&Birtime);//出生日期24
this->m_DatZtime.SetTime(&Ztime);//转正日期26
m_EdtSSID.SetColour(RGB(0,0,0));//设置编辑框边框颜色
m_EdtSID.SetColour(RGB(0,0,0));
m_EdtSname.SetColour(RGB(0,0,0));
m_EdtSIID.SetColour(RGB(0,0,0));
m_EdtSnat.SetColour(RGB(0,0,0));
m_EdtStel.SetColour(RGB(0,0,0));
m_EdtSaddress.SetColour(RGB(0,0,0));
m_EdtSschool.SetColour(RGB(0,0,0));
m_EdtSpro.SetColour(RGB(0,0,0));
m_EdtSnum.SetColour(RGB(0,0,0));
m_EdtRemark.SetColour(RGB(0,0,0));
}
void CStaffInfo::OnButadd()
{
// TODO: Add your control notification handler code here
CString NewID,NewID2;
AddOrChange=1;
this->ButtonEnabled(true);
this->Clear();
NewID=ado.AutoNumber("StaffInfo","Staff_ID","ST",2);
NewID2=ado.AutoNumber("StaffInfo","Staff_file_ID","DA",3);
m_EdtSID.SetWindowText(NewID);
m_EdtSSID.SetWindowText(NewID2);//修改08-11-10 添加了档案号自动添加功能
}
void CStaffInfo::OnButchange()
{
// TODO: Add your control notification handler code here
AddOrChange=2;
this->ButtonEnabled(true);
m_EdtSSID.SetFocus();
}
void CStaffInfo::OnButdelete()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL;
sSQL.Format("DELETE FROM StaffInfo WHERE Staff_file_ID='%s'",m_sID);
RxRecordset Drst;
Drst.Open(sSQL,adCmdText);
this->OnCancel();
}
void CStaffInfo::OnButsave()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSex,sMarry,sSinser,sLevel;
CString sSIID, sName,sSID,sDep,sSschool,sStel,sStitle,sSduty,sSaddress,sSSID;
CString sSnation,sSnat,sSquali,sSpro,sSygxs,sSnum,sRemark;
m_EdtSSID.GetWindowText(sSSID);//档案号1
m_EdtSID.GetWindowText(sSID); //员工号2
m_EdtSname.GetWindowText(sName); //姓名3
m_ComDep.GetWindowText(sDep);//部门4
m_EdtSIID.GetWindowText(sSIID);//身份证5
m_Comsnation.GetWindowText(sSnation);//民族6
m_EdtSnat.GetWindowText(sSnat);//籍贯7
m_EdtStel.GetWindowText(sStel);//联系方式8
m_EdtSaddress.GetWindowText(sSaddress);//家庭住址9
m_Comsquali.GetWindowText(sSquali);//学历10
m_EdtSschool.GetWindowText(sSschool);//毕业院校11
m_EdtSpro.GetWindowText(sSpro);//专业12
m_EdtSnum.GetWindowText(sSnum);//工龄13
m_Comduty.GetWindowText(sSduty);//职务14
m_Comtitle.GetWindowText(sStitle);//职称15
m_Comygxs.GetWindowText(sSygxs);//用工形式16
m_EdtRemark.GetWindowText(sRemark);//备注17
/////080926xlw
m_ComSinser.GetWindowText(sSinser);//在职状态18
m_ComSex.GetWindowText(sSex);//性别19
m_ComSmarry.GetWindowText(sMarry);//婚姻20
m_ComLever.GetWindowText(sLevel);//工资等级21
CString time1,time2,time3,time4,timel,timet;
CTime Birtime,Btime,Rtime,Ztime,Ltime,Ttime,timeleave,timetx;
m_DatTtime.GetTime(timetx);//退休日期
timet=CTimeToCString(timetx);
m_DatLtime.GetTime(timeleave);//离职日期25
timel=CTimeToCString(timeleave);
m_DatRtime.GetTime(Rtime);//入职日期22
time3=CTimeToCString(Rtime);
m_DatBtime.GetTime(Btime);//毕业时间23
time2=CTimeToCString(Btime);
m_DatBirtime.GetTime(Birtime);//出生日期24
time1=CTimeToCString(Birtime);
m_DatZtime.GetTime(Ztime);//转正日期26
time4=CTimeToCString(Ztime);
if(sSSID.IsEmpty())
{
MessageBox("档案号不能为空,请输入档案号。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtSSID.SetFocus();
return;
}
if(sName.IsEmpty())
{
MessageBox("员工姓名不能为空,请输入员工姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtSname.SetFocus();
return;
}
else
{
char ch;
int len;
len=sName.GetLength();
if(len>10)
{
MessageBox("员工姓名输入无效,请重新输入员工姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtSname.SetFocus();
return;
}
for(int i=0;i<len;i++)
{
ch=sName.GetAt(i);
if(ch==32||(ch>='0' && ch<='9'))//(ch>47 && ch<58)
{
MessageBox("员工姓名输入无效,请重新输入员工姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtSname.SetFocus();
return;
}
}
}
if(sSex.IsEmpty())
{
MessageBox("员工性别不能为空,请输入员工性别。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComSex.SetFocus();
return;
}
else if(sSex!="男"&&sSex!="女")
{
MessageBox("员工性别输入无效,请重新输入。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComSex.SetFocus();
return;
}
if(sDep.IsEmpty())
{
MessageBox("部门不能为空,请输入部门。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComDep.SetFocus();
return;
}
else if(sDep.GetLength()>15)
{
MessageBox("部门输入字数过多,请出现输入部门。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComDep.SetFocus();
return;
}
if(sSIID.IsEmpty())
{
MessageBox("身份证号不能为空,请输入身份证号。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtSIID.SetFocus();
return;
}
int len;
len=sSIID.GetLength();
if(len != 18)
{
MessageBox("身份证号只能是18位,请重新输入身份证号","系统提示",MB_OK|MB_ICONSTOP);
m_EdtSIID.SetFocus();
return;
}
else //if(len==18)
{
int num=0;
char ch;
for(int i=0;i<17;i++)
{
ch = sSIID.GetAt(i);
if(ch>47 && ch<58)
num++;
}
if(i==17)
{
ch = sSIID.GetAt(i);
if((ch>47 && ch<58) || (ch==88 || ch==120))
num++;
}
if(num != 18)
{
MessageBox("输入身份证号码无效","系统提示",MB_OK|MB_ICONSTOP);
m_EdtSIID.SetFocus();
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -