📄 csperationinfo.cpp
字号:
// CSperationInfo.cpp : implementation file
//
#include "stdafx.h"
#include "Rsglxt.h"
#include "CSperationInfo.h"
#include "DBaseQuery.h"
#include "ExternDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString Hman;
/////////////////////////////////////////////////////////////////////////////
// CCSperationInfo dialog
CCSperationInfo::CCSperationInfo(CWnd* pParent /*=NULL*/)
: CDialog(CCSperationInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CCSperationInfo)
//}}AFX_DATA_INIT
}
void CCSperationInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCSperationInfo)
DDX_Control(pDX, IDC_EDTSTAFFNAME, m_Edtstaffname);
DDX_Control(pDX, IDC_LIST_GRID, m_Sql_Grid);
DDX_Control(pDX, IDC_EDTSTAFFID, m_EdtstaffID);
DDX_Control(pDX, IDC_COMSTAFFDEP, m_Comstaffdep);
DDX_Control(pDX, IDC_BUTUNDO, m_undo);
DDX_Control(pDX, IDC_BUTSAVE, m_save);
DDX_Control(pDX, IDC_BUTEXIT, m_exit);
DDX_Control(pDX, IDC_BUTDELE, m_delete);
DDX_Control(pDX, IDC_BUTCHANGE, m_change);
DDX_Control(pDX, IDC_BUTADD, m_add);
DDX_Control(pDX, IDC_EDIT31, m_Edtreason);
DDX_Control(pDX, IDC_EDIT29, m_EdtdoName);
DDX_Control(pDX, IDC_EDIT28, m_EdtpassName);
DDX_Control(pDX, IDC_COMBO5, m_Combotype);
DDX_Control(pDX, IDC_EDIT21, m_EdtSname);
DDX_Control(pDX, IDC_EDIT20, m_EdtSID);
DDX_Control(pDX, IDC_EDIT19, m_EdtID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCSperationInfo, CDialog)
//{{AFX_MSG_MAP(CCSperationInfo)
ON_BN_CLICKED(IDC_BUTADD, OnButadd)
ON_BN_CLICKED(IDC_BUTCHANGE, OnButchange)
ON_BN_CLICKED(IDC_BUTDELE, OnButdele)
ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
ON_BN_CLICKED(IDC_BUTSAVE, OnButsave)
ON_BN_CLICKED(IDC_BUTUNDO, OnButundo)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_BTNSEL, OnBtnsel)
ON_NOTIFY(NM_DBLCLK, IDC_LIST_GRID, OnDblclkListGrid)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCSperationInfo message handlers
void CCSperationInfo::OnButadd()//添加新的信息
{
// TODO: Add your control notification handler code here
AddOrChange=1;
this->ButtonEnabled(true);
this->ClearEdit();
CString NewID=ado.AutoNumber("SeparationInfo","Separation_ID","LZTX",3);
m_EdtID.SetWindowText(NewID);
m_EdtSID.SetFocus();
}
void CCSperationInfo::OnButchange() //修改该条信息
{
// TODO: Add your control notification handler code here
AddOrChange=2;
this->ButtonEnabled(true);
m_EdtSID.SetFocus();
}
void CCSperationInfo::OnButdele() //删除该条信息
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL;
sSQL.Format("DELETE FROM SeparationInfo WHERE Separation_ID='%s'",m_sID);
RxRecordset Drst;
Drst.Open(sSQL,adCmdText);
this->OnCancel();
}
void CCSperationInfo::OnButexit() //退出操作
{
// TODO: Add your control notification handler code here
this->OnCancel();
}
void CCSperationInfo::OnButsave() //保存该条信息
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString ID,SID,reason,Sname,type,doname,passname;
m_EdtID.GetWindowText(ID);//离职离休编号
m_EdtSID.GetWindowText(SID);//员工编号
m_EdtSname.GetWindowText(Sname);//员工姓名
// m_EdtdoName.GetWindowText(doname);//经办人
doname=Hman;
m_EdtpassName.GetWindowText(passname);//批准人
m_Combotype.GetWindowText(type);//离职类型
m_Edtreason.GetWindowText(reason);//离职离休原因
if(SID.IsEmpty())
{
MessageBox("员工编号不能为空,请输入员工编号。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtSID.SetFocus();
return;
}
if(Sname.IsEmpty())
{
MessageBox("员工姓名不能为空,请输入员工姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtSname.SetFocus();
return;
}
if(type.IsEmpty())
{
MessageBox("输入离职类型不能为空,请输入离职类型。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Combotype.SetFocus();
return;
}
else if(type!="离职"&&type!="离休"&&type!="退养")
{
MessageBox("输入离职类型无效,请重新输入离职类型。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Combotype.SetFocus();
return;
}
if(doname.IsEmpty())
{
MessageBox("经办人不能为空,请输入经办人姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtdoName.SetFocus();
return;
}
if(passname.IsEmpty())
{
MessageBox("批准人不能为空,请输入批准人姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtpassName.SetFocus();
return;
}
if(reason.IsEmpty())
{
MessageBox("离职离休原因不能为空,请输入离职离休原因。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Edtreason.SetFocus();
return;
}else if(reason.GetLength()>50)
{
MessageBox("输入离职离休原因的字数不能过长,请重新输入。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Edtreason.SetFocus();
return;
}
RxRecordset namest,IDst,manst;
CString namesql,IDsql,text1,text2,dutytext,mansql;
namesql.Format("SELECT * FROM StaffInfo WHERE Staff_name='%s'",Sname);
IDsql.Format("SELECT * FROM StaffInfo WHERE Staff_ID='%s'",SID);
mansql.Format("SELECT * FROM StaffInfo WHERE Staff_name='%s' and Duty!='职员'",passname);
namest.Open(namesql,adCmdText);
IDst.Open(IDsql,adCmdText);
manst.Open(mansql,adCmdText);
if(IDst.GetRecordCount()<1)
{
MessageBox("您输入的用户编号不存在!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtSID.SetWindowText("");
m_EdtSID.SetFocus();
return;
}
if(namest.GetRecordCount()<1)
{
MessageBox("您输入的用户名不存在!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtSname.SetWindowText("");
m_EdtSname.SetFocus();
return;
}
text1=namest.GetFieldValue("Staff_ID");
if(text1!=SID)
{
MessageBox("您输入的用户名与用户编号不匹配!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtSID.SetWindowText("");
m_EdtSID.SetFocus();
return;
}
if(manst.GetRecordCount()<1)
{
MessageBox("您输入的批准人不存在或者不是部门主管以上职务!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtpassName.SetWindowText("");
m_EdtpassName.SetFocus();
return;
}
CString sSQL,tSQL;
if(AddOrChange==1)//添加操作
{
sSQL.Format("Insert Into SeparationInfo Values('%s','%s','%s','%s','%s','%s','%s')",ID,SID,Sname,type,reason,passname,doname);
tSQL.Format("Update StaffInfo set Inservice_status='%s' where Staff_ID='%s'",type,SID);
}
else
{
sSQL.Format("Update SeparationInfo set Staff_name='%s',Staff_ID='%s',\
Separation_cause='%s',Separation_type='%s',Approval_man='%s',\
Handle_man='%s' WHERE Separation_ID='%s'",Sname,SID,reason,type,\
passname,doname,ID);
tSQL.Format("Update StaffInfo set Inservice_status='%s' where Staff_ID='%s'",type,SID);
}
RxRecordset arst,brst;
arst.Open(sSQL,adCmdText);
brst.Open(tSQL,adCmdText);
this->ButtonEnabled(false);
m_EdtSID.SetFocus();
}
void CCSperationInfo::OnButundo()// 撤消该编辑操作081005XLW
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
this->ButtonEnabled(false);
this->ClearEdit();
this->DisPlayInfo(m_sID);
this->m_add.SetFocus();
}
BOOL CCSperationInfo::OnInitDialog() //窗口初始化081004XLW
{
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_Comstaffdep.SetRecordset(rs,"部门名称");
ts.Open("select 部门名称 from 部门视图");
m_Comstaffdep.SetFieldset(ts);
m_Comstaffdep.SelectString(0,"所有部门");
this->m_Comstaffdep.m_CurrentFieldType="字符型";
m_Sql_Grid.ReadOnly(true);
m_Sql_Grid.SetDataBase("员工查询视图",adCmdTable);
this->DisPlayInfo(m_sID);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CCSperationInfo::DisPlayInfo(CString sID)//显示报表数据在窗口上081004XLW
{
RxRecordset drxt;
CString sSQL;
if(sID.IsEmpty())
return;
sSQL.Format("SELECT * FROM 员工离职离休视图 WHERE 离职离休编号 ='%s'",sID);
drxt.Open(sSQL,adCmdText);
//////////////////////////////
CString ID,SID,Sname,title,type,reason,phone,doname,duty,dept,address,sex,passname,number,timestart;
ID=drxt.GetFieldValue("离职离休编号");//离职离休编号
SID=drxt.GetFieldValue("员工编号");//员工编号
Sname=drxt.GetFieldValue("员工姓名");//员工姓名
sex=drxt.GetFieldValue("性别");//员工性别
number=drxt.GetFieldValue("身份证号");//
address=drxt.GetFieldValue("家庭住址");//家庭住址
phone=drxt.GetFieldValue("联系电话");//联系电话
dept=drxt.GetFieldValue("部门");//部门
duty=drxt.GetFieldValue("职务");//职务
title=drxt.GetFieldValue("职称");//职称
timestart=drxt.GetFieldValue("入职日期");//
reason=drxt.GetFieldValue("离职原因");//离职离休原因
type=drxt.GetFieldValue("离职类型");//离职类型
passname=drxt.GetFieldValue("批准人");//批准人
doname=drxt.GetFieldValue("经办人");//经办人
/////////////////////////
m_Combotype.SetWindowText(type);
/////////////////////////////
m_EdtID.SetWindowText(ID);
m_EdtSID.SetWindowText(SID);
m_EdtSname.SetWindowText(Sname);
m_EdtdoName.SetWindowText(doname);
m_EdtpassName.SetWindowText(passname);
m_Edtreason.SetWindowText(reason);
m_EdtID.SetColour(RGB(0,0,0));//设置编辑框边框颜色
m_EdtSID.SetColour(RGB(0,0,0));
m_EdtSname.SetColour(RGB(0,0,0));
m_EdtdoName.SetColour(RGB(0,0,0));
m_EdtpassName.SetColour(RGB(0,0,0));
m_Edtreason.SetColour(RGB(0,0,0));
// m_EdtID.SetColour(RGB(0,0,0));
}
void CCSperationInfo::ClearEdit()//清空文本内容
{
m_EdtID.SetWindowText("");
m_EdtSID.SetWindowText("");
m_EdtSname.SetWindowText("");
m_EdtdoName.SetWindowText("");
m_EdtpassName.SetWindowText("");
m_Edtreason.SetWindowText("");
}
void CCSperationInfo::ButtonEnabled(bool bEnabled)
{
m_EdtstaffID.EnableWindow(bEnabled);
m_EdtSID.EnableWindow(bEnabled);
m_EdtSname.EnableWindow(bEnabled);
m_Edtstaffname.EnableWindow(bEnabled);
m_Comstaffdep.EnableWindow(bEnabled);
m_Sql_Grid.EnableWindow(bEnabled);
m_EdtpassName.EnableWindow(bEnabled);
m_Edtreason.EnableWindow(bEnabled);
m_Combotype.EnableWindow(bEnabled);
m_add.EnableWindow(!bEnabled);
m_change.EnableWindow(!bEnabled);
m_delete.EnableWindow(!bEnabled);
m_exit.EnableWindow(!bEnabled);
m_save.EnableWindow(bEnabled);
m_undo.EnableWindow(bEnabled);
}
void CCSperationInfo::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 CCSperationInfo::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 CCSperationInfo::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);
}
void CCSperationInfo::OnDblclkListGrid(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
RxRecordset rRst;
CString sSql,sname,sID;
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("姓名");
m_EdtSID.SetWindowText(sID);
m_EdtSname.SetWindowText(sname);
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -