📄 dcont.cpp
字号:
// DCont.cpp : implementation file
//
#include "stdafx.h"
#include "Rsglxt.h"
#include "DCont.h"
#include "DBaseQuery.h"
#include "ExternDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDCont dialog
CDCont::CDCont(CWnd* pParent /*=NULL*/)
: CDialog(CDCont::IDD, pParent)
{
//{{AFX_DATA_INIT(CDCont)
//}}AFX_DATA_INIT
}
void CDCont::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDCont)
// DDX_Control(pDX, IDC_BUTNAMESEL, m_ButNameSel);
DDX_Control(pDX, IDC_EDITTSALARY, m_EdtTsalary);
DDX_Control(pDX, IDC_EDITPSALARY, m_EdtPsalary);
DDX_Control(pDX, IDC_EDITREMARK, m_EdtRemark);
DDX_Control(pDX, IDC_EDITNAME, m_EdtName);
DDX_Control(pDX, IDC_EDITCID, m_EdtCID);
DDX_Control(pDX, IDC_EDITID, m_EdtID);
DDX_Control(pDX, IDC_EDITFILE, m_EdtFile);
DDX_Control(pDX, IDC_DATTDATE, m_DatTdate);
DDX_Control(pDX, IDC_DATFSTIME, m_DatFstime);
DDX_Control(pDX, IDC_DATFSTART, m_DatFstart);
DDX_Control(pDX, IDC_DATFEND, m_DatFend);
DDX_Control(pDX, IDC_DATENDTIME, m_DatEndtime);
DDX_Control(pDX, IDC_COMTYPE, m_ComType);
DDX_Control(pDX, IDC_COMSTAT, m_ComStatus);
DDX_Control(pDX, IDC_BUTUNDO, m_ButUndo);
DDX_Control(pDX, IDC_BUTSAVE, m_ButSave);
DDX_Control(pDX, IDC_BUTEXIT, m_ButExit);
DDX_Control(pDX, IDC_BUTDELE, m_ButDele);
DDX_Control(pDX, IDC_BUTCHANGE1, m_ButChange);
DDX_Control(pDX, IDC_BUTADD, m_ButAdd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDCont, CDialog)
//{{AFX_MSG_MAP(CDCont)
ON_BN_CLICKED(IDC_BUTADD, OnButadd)
ON_BN_CLICKED(IDC_BUTCHANGE1, OnButchange1)
ON_BN_CLICKED(IDC_BUTDELE, OnButdele)
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()
/////////////////////////////////////////////////////////////////////////////
// CDCont message handlers
void CDCont::Clear()
{
m_EdtCID.SetWindowText("");
m_EdtID.SetWindowText("");
m_EdtName.SetWindowText("");
m_EdtPsalary.SetWindowText("");
m_EdtFile.SetWindowText("");
m_EdtTsalary.SetWindowText("");
m_EdtPsalary.SetWindowText("");
m_EdtRemark.SetWindowText("");
}
void CDCont::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 sName,sSID,sDep,sStat,sType,sFstime,sFetime,sTetime,sStime,sTsalary,sPsalary,sFile,sRemark;
sName=drst.GetFieldValue("姓名");
sSID=drst.GetFieldValue("员工编号");
sStat=drst.GetFieldValue("合同状态");
sType=drst.GetFieldValue("合同类型");
CTime cFstime,cFetime,cStime,cTetime;
sFstime=drst.GetFieldValue("首签开始日期");
cFstime=CStringTOCTime(sFstime);
sFetime=drst.GetFieldValue("首签结束日期");
cFetime=CStringTOCTime(sFetime);
sStime=drst.GetFieldValue("首签开始日期");
cStime=CStringTOCTime(sStime);
sTetime=drst.GetFieldValue("试用结束日期");
cTetime=CStringTOCTime(sTetime);
sTsalary=drst.GetFieldValue("试用期工资");
sPsalary=drst.GetFieldValue("转正工资");
sFile=drst.GetFieldValue("合同文件");
sRemark=drst.GetFieldValue("备注");
m_EdtCID.SetWindowText(sID);
m_EdtID.SetWindowText(sSID);
m_EdtName.SetWindowText(sName);
m_EdtTsalary.SetWindowText(sTsalary);
m_EdtPsalary.SetWindowText(sPsalary);
m_EdtFile.SetWindowText(sFile);
m_EdtRemark.SetWindowText(sRemark);
m_ComStatus.SetWindowText(sStat);
m_ComType.SetWindowText(sType);
this->m_DatFstart.SetTime(&cFstime);
this->m_DatFend.SetTime(&cFetime);
this->m_DatTdate.SetTime(&cTetime);
this->m_DatEndtime.SetTime(&cFetime);
this->m_DatFstime.SetTime(&cFstime);
m_EdtCID.SetColour(RGB(0,0,0));//设置编辑框边框颜色
m_EdtID.SetColour(RGB(0,0,0));
m_EdtName.SetColour(RGB(0,0,0));
m_EdtTsalary.SetColour(RGB(0,0,0));
m_EdtPsalary.SetColour(RGB(0,0,0));
m_EdtFile.SetColour(RGB(0,0,0));
m_EdtRemark.SetColour(RGB(0,0,0));
}
void CDCont::Enabled(bool bEnabled)
{
//////////////////////////
m_EdtRemark.EnableWindow(bEnabled);
m_EdtName.EnableWindow(bEnabled);
m_EdtID.EnableWindow(bEnabled);
m_EdtFile.EnableWindow(bEnabled);
m_EdtTsalary.EnableWindow(bEnabled);
m_EdtPsalary.EnableWindow(bEnabled);
m_DatTdate.EnableWindow(bEnabled);
m_DatFstime.EnableWindow(bEnabled);
m_DatFstart.EnableWindow(bEnabled);
m_DatFend.EnableWindow(bEnabled);
m_DatEndtime.EnableWindow(bEnabled);
m_ComType.EnableWindow(bEnabled);
m_ComStatus.EnableWindow(bEnabled);
// m_ButNameSel.EnableWindow(bEnabled);
///////////////////////////////
m_ButUndo.EnableWindow(bEnabled);
m_ButSave.EnableWindow(bEnabled);
m_ButExit.EnableWindow(!bEnabled);
m_ButDele.EnableWindow(!bEnabled);
m_ButChange.EnableWindow(!bEnabled);
m_ButAdd.EnableWindow(!bEnabled);
}
void CDCont::OnButadd()
{
// TODO: Add your control notification handler code here
AddOrChange=1;
this->Enabled(true);
this->Clear();
CString NewID=ado.AutoNumber("ContractInfo","Contract_ID","HT",3);//HT为中文合同的头两个字母
m_EdtCID.SetWindowText(NewID);
m_EdtName.SetFocus();
}
void CDCont::OnButchange1()
{
// TODO: Add your control notification handler code here
AddOrChange=2;
this->Enabled(true);
m_EdtID.SetFocus();
}
void CDCont::OnButdele()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL;
sSQL.Format("DELETE FROM ContractInfo WHERE Contract_ID='%s'",m_sID);
RxRecordset Drst;
Drst.Open(sSQL,adCmdText);
this->OnCancel();
}
void CDCont::OnButsave()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL,sID,sSID,sName,sDep,sStat,sType,sFstime,sFetime,sTetime,sFetime1,sFstime1,sTsalary,sPsalary,sFile,sRemark;
m_EdtCID.GetWindowText(sID);
m_EdtID.GetWindowText(sSID);
m_EdtName.GetWindowText(sName);
m_EdtTsalary.GetWindowText(sTsalary);
m_EdtPsalary.GetWindowText(sPsalary);
m_EdtFile.GetWindowText(sFile);
m_EdtRemark.GetWindowText(sRemark);
m_ComStatus.GetWindowText(sStat);
m_ComType.GetWindowText(sType);
CTime cFstime,cFetime,cStime,cTetime;
m_DatFstart.GetTime(cFstime);
sFstime=CTimeToCString(cFstime);
m_DatFend.GetTime(cFetime);
sFetime=CTimeToCString(cFetime);
m_DatTdate.GetTime(cStime);
sTetime=CTimeToCString(cStime);
m_DatEndtime.GetTime(cFstime);
sFetime1=CTimeToCString(cFstime);
m_DatFstime.GetTime(cTetime);
sFstime1=CTimeToCString(cTetime);
if(sSID.IsEmpty())
{
MessageBox("员工编号不能为空,请输入员工编号。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtID.SetFocus();
return;
}
if(sName.IsEmpty())
{
MessageBox("员工姓名不能为空,请输入员工姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtName.SetFocus();
return;
}
if(sStat.IsEmpty())
{
MessageBox("合同状态不能为空,请重新输入合同状态。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComStatus.SetFocus();
return;
}
else if(sStat!="生效"&&sStat!="终止")
{
MessageBox("合同状态无效,请重新输入合同状态。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComStatus.SetFocus();
return;
}
if(sType.IsEmpty())
{
MessageBox("员工姓名不能为空,请输入员工姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComType.SetFocus();
return;
}
else if(sType!="短期合同"&&sType!="长期合同"&&sType!="退休返聘合同")
{
MessageBox("合同类型无效,请重新输入合同类型。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComType.SetFocus();
return;
}
if(sTsalary.IsEmpty())
{
MessageBox("试用期工资不能为空,请输入试用期工资。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtTsalary.SetFocus();
return;
}
else if(sTsalary.GetLength()>8)
{
MessageBox("试用期工资输入过多,请重新输入试用期工资。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtTsalary.SetFocus();
return;
}
if(sPsalary.IsEmpty())
{
MessageBox("转正工资不能为空,请输入转正工资。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtPsalary.SetFocus();
return;
}
else if(sPsalary.GetLength()>8)
{
MessageBox("转正工资输入过多,请重新输入转正工资。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtPsalary.SetFocus();
return;
}
if(sRemark.GetLength()>50)
{
MessageBox("输入备注的字数过多,请重新输入。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtRemark.SetFocus();
return;
}
RxRecordset namest,IDst,tst;
CString namesql,IDsql,text1,text2,text3;
namesql.Format("SELECT * FROM StaffInfo WHERE Staff_name='%s'",sName);
IDsql.Format("SELECT * FROM StaffInfo WHERE Staff_ID='%s'",sSID);
namest.Open(namesql,adCmdText);
IDst.Open(IDsql,adCmdText);
if(IDst.GetRecordCount()<1)
{
MessageBox("您输入的用户编号不存在!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtID.SetWindowText("");
m_EdtID.SetFocus();
return;
}
if(namest.GetRecordCount()<1)
{
MessageBox("您输入的用户名不存在!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtName.SetWindowText("");
m_EdtName.SetFocus();
return;
}
text1=namest.GetFieldValue("Staff_ID");
if(text1!=sSID)
{
MessageBox("您输入的用户名与用户编号不匹配!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtID.SetWindowText("");
m_EdtID.SetFocus();
return;
}
int num1,num2;
num1=atoi(sTsalary);
num2=atoi(sPsalary);
if(num1<0)
{
MessageBox("您输入的试用期工资不能小于0!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtTsalary.SetFocus();
return;
}
if(num2<0)
{
MessageBox("您输入的试用期工资不能小于0!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtPsalary.SetFocus();
return;
}
if(AddOrChange==1)//添加操作
sSQL.Format("Insert Into ContractInfo Values('%s','%s','%s','%s','%s','%s','%s','%s','%s',%s,%s,'%s','%s','%s')",sID,sName,sSID,sStat,sType,sFstime,sFetime,sTetime,sFetime1,sTsalary,sPsalary,sFile,sFstime1,sRemark);
else
sSQL.Format("Update ContractInfo set Staff_name='%s',Staff_ID='%s',\
Contract_state='%s',Contract_type='%s',First_sign_start_date='%s',\
First_sign_end_date='%s',Trial_end_date='%s',Contract_expi_time='%s',\
Probationary_wage=%s,Positive_wage=%s,Contract_file='%s',Contract_sign_date='%s',\
Remarks='%s' WHERE Contract_ID='%s'",sName,sSID,sStat,sType,sFstime,sFetime,\
sTetime,sFetime1,sTsalary,sPsalary,sFile,sFstime1,sRemark,sID);
RxRecordset arst;
arst.Open(sSQL,adCmdText);
this->Enabled(false);
this->m_ButAdd.SetFocus();
}
void CDCont::OnButundo()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
this->Enabled(false);
this->Clear();
this->Display(m_sID);
this->m_ButAdd.SetFocus();
}
void CDCont::OnButexit()
{
// TODO: Add your control notification handler code here
this->OnCancel();
}
BOOL CDCont::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CDBaseQuery* ParentWnd=(CDBaseQuery*)FindWindow(NULL,"合同信息查询");
m_sID=ParentWnd->m_Grid.GetItemText(ParentWnd->m_Grid.GetRow(),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 CDCont::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rect;
CBitmap bit;
CDC memDC;
this->GetClientRect(&rect);
bit.LoadBitmap(IDB_BIT_BJ);
memDC.CreateCompatibleDC(&dc);
memDC.SelectObject(&bit);
dc.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
memDC.DeleteDC();
::DeleteObject(&bit);
CDialog::OnPaint();
// Do not call CDialog::OnPaint() for painting messages
}
HBRUSH CDCont::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetBkColor(RGB(255,255,255));
pDC->SetTextColor(RGB(0,0,0));
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -