📄 dholiday.cpp
字号:
if(sDuty.IsEmpty())
{
MessageBox("员工职务不能为空,请输入员工职务。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtDuty.SetFocus();
return;
}else if(sDuty.GetLength()>20)
{
MessageBox("员工职务输入的字数不能过长,请重新输入员工职务。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtDuty.SetFocus();
return;
}
if(sHolnum.IsEmpty())
{
MessageBox("请假天数不能为空,请输入请假天数。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtHolnum.SetFocus();
return;
}
if(sCouse.IsEmpty())
{
MessageBox("请假事由不能为空,请输入请假事由。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComCouse.SetFocus();
return;
}else if(sCouse!="事假"&&sCouse!="病假"&&sCouse!="探亲假"&&sCouse!="工伤假"&&sCouse!="丧假"&&sCouse!="婚假")
{
MessageBox("请假事由输入无效,请输入请假事由。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_ComCouse.SetFocus();
return;
}
if(sMan.IsEmpty())
{
MessageBox("批准人不能为空,请输入批准人姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtMan.SetFocus();
return;
}
if(sHandleman.IsEmpty())
{
MessageBox("经手人不能为空,请输入经手人姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtHandleman.SetFocus();
return;
}
if(sRemark.GetLength()>50)
{
MessageBox("输入的备注不能过长,请重新输入。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtRemark.SetFocus();
return;
}
RxRecordset namest,IDst,tst,manst;
CString namesql,IDsql,text1,text2,dutytext,mansql,man;
namesql.Format("SELECT * FROM StaffInfo WHERE Staff_name='%s'",sName);
IDsql.Format("SELECT * FROM StaffInfo WHERE Staff_ID='%s'",sSID);
mansql.Format("SELECT * FROM StaffInfo WHERE Staff_name='%s' and Duty!='职员'",sMan);
namest.Open(namesql,adCmdText);
IDst.Open(IDsql,adCmdText);
manst.Open(mansql,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;
}
text2=namest.GetFieldValue("Dep");
if(text2!=sDep)
{
MessageBox("您输入的用户不属于这个部门!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_Comdept.SetFocus();
return;
}
dutytext=namest.GetFieldValue("Duty");
if(dutytext!=sDuty)
{
MessageBox("您输入的用户的职务与输入的职务不匹配!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtDuty.SetWindowText("");
m_EdtDuty.SetFocus();
return;
}
if(manst.GetRecordCount()<1)
{
MessageBox("您输入的批准人不存在或者不是部门主管以上职务!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtMan.SetWindowText("");
m_EdtMan.SetFocus();
return;
}
if(AddOrChange==1)//添加操作
sSQL.Format("Insert Into HolidayInfo Values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')",sID,sSID,sDep,sDuty,sHolnum,sCouse,sSta,sEnd,sDes,sApp,sMan,sHandleman,sRemark);
else
sSQL.Format("Update HolidayInfo set Staff_ID='%s',Dep='%s',Duty='%s',\
Leave_days='%s',Leave_cause='%s',Start_time='%s',End_time='%s',Cancle_time='%s',\
Approval_time='%s',Approval_man='%s',Handle_man='%s',\
Remarks='%s' WHERE Holiday_ID='%s'",sSID,sDep,sDuty,sHolnum,sCouse,\
sSta,sEnd,sDes,sApp,sMan,sHandleman,sRemark,sID);
RxRecordset arst;
arst.Open(sSQL,adCmdText);
this->Enabled(false);
this->m_ButAdd.SetFocus();
}
void CDHoliday::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 CDHoliday::OnButexit()
{
// TODO: Add your control notification handler code here
this->OnCancel();
}
BOOL CDHoliday::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CDBaseQuery* ParentWnd=(CDBaseQuery*)FindWindow(NULL,"假期信息查询");
m_sID=ParentWnd->m_Grid.GetItemText(ParentWnd->m_Grid.GetRow(),0);
RxRecordset rs,ts;
rs.Open("部门视图");
m_Comdept.SetRecordset(rs,"部门名称");
m_Comstaffdep.SetRecordset(rs,"部门名称");
ts.Open("select 部门名称 from 部门视图");
m_Comstaffdep.SelectString(0,"所有部门");
m_Comdept.SetFieldset(ts);
m_Comstaffdep.SetFieldset(ts);
this->m_Comdept.m_CurrentFieldType="字符型";
this->m_Comstaffdep.m_CurrentFieldType="字符型";
m_Sql_Grid.ReadOnly(true);
m_Sql_Grid.SetDataBase("员工查询视图",adCmdTable);
this->Display(m_sID);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDHoliday::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 CDHoliday::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;
}
void CDHoliday::OnDblclkListGrid(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
RxRecordset rRst;
CString sSql,sname,sID,sdep,sduty;
if(m_Sql_Grid.GetHotItem()<0)
return;
m_tID=this->m_Sql_Grid.GetItemText(m_Sql_Grid.GetHotItem(),0);
sSql.Format("SELECT * FROM 员工查询视图 WHERE 编号='%s'",m_tID);
rRst.Open(sSql,adCmdText);
sID=rRst.GetFieldValue("编号");
sname=rRst.GetFieldValue("姓名");
sdep=rRst.GetFieldValue("部门");
sduty=rRst.GetFieldValue("职务");
m_EdtID.SetWindowText(sID);
m_EdtName.SetWindowText(sname);
m_Comdept.SetWindowText(sdep);
m_EdtDuty.SetWindowText(sduty);
*pResult = 0;
}
void CDHoliday::OnBtnsel()
{
// TODO: Add your control notification handler code here
CString sSQL,sName,sSID,sSdep;
this->m_Edtstaffname.GetWindowText(sName);
this->m_EdtstaffID.GetWindowText(sSID);
this->m_Comstaffdep.GetWindowText(sSdep);
if(sSdep=="所有部门")
{
if(sName.IsEmpty() && sSID.IsEmpty())
sSQL.Format("SELECT * FROM 员工查询视图");
if(!sName.IsEmpty())
{
if(sSID.IsEmpty())
sSQL.Format("SELECT * FROM 员工查询视图 where 姓名 LIKE '%%%s%%'",sName);
else
sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%' OR 姓名 LIKE '%%%s%%'",sSID,sName);
}
else
{
if(!sSID.IsEmpty())
sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%'",sSID);
}
}
if(sSdep!="所有部门")
{
if(sName.IsEmpty() && sSID.IsEmpty())
sSQL.Format("SELECT * FROM 员工查询视图 where 部门='%s'",sSdep);
if(!sName.IsEmpty())
{
if(sSID.IsEmpty())
sSQL.Format("SELECT * FROM 员工查询视图 where 姓名 LIKE '%%%s%%' AND 部门='%s'",sName,sSdep);
else
sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%' OR 姓名 LIKE '%%%s%%' AND 部门='%s'",sSID,sName,sSdep);
}
else
{
if(!sSID.IsEmpty())
sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%' AND 部门='%s'",sSID,sSdep);
}
}
RxRecordset rRst;
rRst.Open(sSQL,adCmdText);
m_Sql_Grid.AddCellValue(rRst);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -