📄 cevaluationinfo.cpp
字号:
// CEvaluationInfo.cpp : implementation file
//
#include "stdafx.h"
#include "Rsglxt.h"
#include "CEvaluationInfo.h"
#include "DBaseQuery.h"
#include "ExternDllHeader.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCEvaluationInfo dialog
//////////////////////////////////
//员工职称评定考核信息
//编写:XLW
//日期:08-10-05
/////////////////////////////////////////////////////////////////////
CCEvaluationInfo::CCEvaluationInfo(CWnd* pParent /*=NULL*/)
: CDialog(CCEvaluationInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CCEvaluationInfo)
//}}AFX_DATA_INIT
}
void CCEvaluationInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCEvaluationInfo)
DDX_Control(pDX, IDC_BTNSEL, m_Btnsel);
DDX_Control(pDX, IDC_COMSTAFFDEP, m_Comstaffdep);
DDX_Control(pDX, IDC_LIST_GRID, m_Sql_Grid);
DDX_Control(pDX, IDC_EDTSTAFFNAME, m_Edtstaffname);
DDX_Control(pDX, IDC_EDTSTAFFID, m_EdtstaffID);
DDX_Control(pDX, IDC_COMDept, m_Comdept);
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_BUTDELETE, m_delete);
DDX_Control(pDX, IDC_BUTCHANGE, m_change);
DDX_Control(pDX, IDC_BUTADD, m_add);
DDX_Control(pDX, IDC_EDIT8, m_Edtremark);
DDX_Control(pDX, IDC_EDIT7, m_Edtvalue);
DDX_Control(pDX, IDC_EDIT6, m_Edtscore);
DDX_Control(pDX, IDC_EDIT4, m_Edtname);
DDX_Control(pDX, IDC_EDIT3, m_EdtID);
DDX_Control(pDX, IDC_EDIT2, m_EdtItem);
DDX_Control(pDX, IDC_EDIT1, m_EdtcheckID);
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_Timecheck);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCEvaluationInfo, CDialog)
//{{AFX_MSG_MAP(CCEvaluationInfo)
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()
ON_BN_CLICKED(IDC_BTNSEL, OnBtnsel)
ON_NOTIFY(NM_DBLCLK, IDC_LIST_GRID, OnDblclkListGrid)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCEvaluationInfo message handlers
void CCEvaluationInfo::OnButadd() //增加一新的信息
{
// TODO: Add your control notification handler code here
AddOrChange=1;
this->ButtonEnabled(true);
this->ClearEdit();
CString NewID=ado.AutoNumber("EvaluationInfo","Evaluation_ID","PD",3);//PD 为中文评定的首字母,职称评定考核编号采用日期时间型
m_EdtcheckID.SetWindowText(NewID);
m_EdtID.SetFocus();
}
void CCEvaluationInfo::OnButchange() //修改该条信息
{
// TODO: Add your control notification handler code here
AddOrChange=2;
this->ButtonEnabled(true);
m_EdtID.SetFocus();
}
void CCEvaluationInfo::OnButdelete() //删除该条信息
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL;
sSQL.Format("DELETE FROM EvaluationInfo WHERE Evaluation_ID='%s'",m_sID);
RxRecordset Drst;
Drst.Open(sSQL,adCmdText);
this->OnCancel();
}
void CCEvaluationInfo::OnButsave() //保存该条信息
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL,kID,kItem,ksID,kName,kDept,kScore,kValue,kRemark,kDate;
m_EdtcheckID.GetWindowText(kID);//考核编号
m_EdtItem.GetWindowText(kItem);//考核项目
m_EdtID.GetWindowText(ksID);//员工编号
m_Edtname.GetWindowText(kName);//员工姓名
m_Comdept.GetWindowText(kDept);//部门
m_Edtscore.GetWindowText(kScore);//考核分值
m_Edtvalue.GetWindowText(kValue);//考核评价
m_Edtremark.GetWindowText(kRemark);//备注
////////////////////////
CTime time;
m_Timecheck.GetTime(time);
kDate=CTimeToCString(time);
//////////////////////////////////
if(kItem.IsEmpty())
{
MessageBox("考核项目不能为空,请输入考核项目。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtItem.SetFocus();
return;
}else if(kItem.GetLength()>10)
{
MessageBox("考核项目字数不能过长,请重新输入考核项目。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtItem.SetFocus();
return;
}
if(ksID.IsEmpty())
{
MessageBox("员工编号不能为空,请输入员工编号。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_EdtID.SetFocus();
return;
}
if(kName.IsEmpty())
{
MessageBox("员工姓名不能为空,请输入员工姓名。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Edtname.SetFocus();
return;
}
if(kDept.IsEmpty())
{
MessageBox("员工部门不能为空,请输入员工部门。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Comdept.SetFocus();
return;
}
if(kScore.IsEmpty())
{
MessageBox("考核分值不能为空,请输入考核分值。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Edtscore.SetFocus();
return;
}else
{
int len;
len=atoi(kScore);
if(len>100)
{
MessageBox("考核分值不能超过100分,请重新输入考核分值。","系统提示",MB_OKCANCEL|MB_ICONQUESTION!=1);
m_Edtscore.SetFocus();
return;
}
}
if(kRemark.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'",kName);
IDsql.Format("SELECT * FROM StaffInfo WHERE Staff_ID='%s'",ksID);
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!=ksID)
{
MessageBox("您输入的用户名与用户编号不匹配!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtID.SetWindowText("");
m_EdtID.SetFocus();
return;
}
text2=namest.GetFieldValue("Dep");
if(text2!=kDept)
{
MessageBox("您输入的用户不属于这个部门!请重新输入!","系统提示",MB_OK|MB_ICONSTOP);
m_Comdept.SetFocus();
return;
}
if(AddOrChange==1)//添加操作
sSQL.Format("Insert Into EvaluationInfo Values('%s','%s','%s','%s','%s','%s','%s')",kID,ksID,kItem,kDate,kScore,kValue,kRemark);
else
sSQL.Format("Update EvaluationInfo set Staff_ID='%s',Assessment_Project='%s',\
Appraisal_time='%s',Assessment_score='%s',Assessment_Evaluat='%s',\
Remarks='%s' WHERE Evaluation_ID='%s'",ksID,kItem,kDate,kScore,kValue,\
kRemark,kID);
RxRecordset arst;
arst.Open(sSQL,adCmdText);
this->ButtonEnabled(false);
this->m_add.SetFocus();
}
void CCEvaluationInfo::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();
}
void CCEvaluationInfo::OnButexit() //退出对话框编辑081005XLW
{
// TODO: Add your control notification handler code here
this->OnCancel();
}
BOOL CCEvaluationInfo::OnInitDialog() //对话框初始化081003XLW
{
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_Comdept.SetFieldset(ts);
m_Comstaffdep.SetFieldset(ts);
m_Comstaffdep.SelectString(0,"所有部门");
this->m_Comdept.m_CurrentFieldType="字符型";
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 CCEvaluationInfo::DisPlayInfo(CString ID)
{
RxRecordset drxt;
CString sSQL;
if(ID.IsEmpty())
return;
sSQL.Format("SELECT * FROM 员工职称评定考核视图 WHERE 考核编号 ='%s'",ID);
drxt.Open(sSQL,adCmdText);
if(drxt.GetRecordCount()<1)
return;
CString kID,kItem,ksID,kName,kDept,kScore,kValue,kRemark,kDate;
kID=drxt.GetFieldValue("考核编号");
kItem=drxt.GetFieldValue("考核项目");
ksID=drxt.GetFieldValue("员工编号");
kName=drxt.GetFieldValue("员工姓名");
kDept=drxt.GetFieldValue("部门");
kScore=drxt.GetFieldValue("考核分值");
kValue=drxt.GetFieldValue("考核评价");
kRemark=drxt.GetFieldValue("备注");
kDate=drxt.GetFieldValue("考核时间");
m_EdtcheckID.SetWindowText(kID);
m_EdtItem.SetWindowText(kItem);
m_EdtID.SetWindowText(ksID);
m_Edtname.SetWindowText(kName);
m_Comdept.SetWindowText(kDept);
m_Edtscore.SetWindowText(kScore);
m_Edtvalue.SetWindowText(kValue);
m_Edtremark.SetWindowText(kRemark);
CTime time;//日期转换
time=CStringTOCTime(kDate);
this->m_Timecheck.SetTime(&time);
m_EdtcheckID.SetColour(RGB(0,0,0));//设置编辑框边框颜色
m_EdtItem.SetColour(RGB(0,0,0));
m_EdtID.SetColour(RGB(0,0,0));
m_Edtname.SetColour(RGB(0,0,0));
// m_Edtdept.SetColour(RGB(0,0,0));
m_Edtscore.SetColour(RGB(0,0,0));
m_Edtvalue.SetColour(RGB(0,0,0));
m_Edtremark.SetColour(RGB(0,0,0));
}
void CCEvaluationInfo::ClearEdit()//清空文本内容
{
m_EdtcheckID.SetWindowText("");
m_EdtItem.SetWindowText("");
m_EdtID.SetWindowText("");
m_Edtname.SetWindowText("");
// m_Edtdept.SetWindowText("");
m_Edtscore.SetWindowText("");
m_Edtvalue.SetWindowText("");
m_Edtremark.SetWindowText("");
}
void CCEvaluationInfo::ButtonEnabled(bool bEnabled)
{
m_EdtItem.EnableWindow(bEnabled);
m_Timecheck.EnableWindow(bEnabled);
m_EdtID.EnableWindow(bEnabled);
m_Edtname.EnableWindow(bEnabled);
m_Comdept.EnableWindow(bEnabled);
m_Edtscore.EnableWindow(bEnabled);
m_Edtvalue.EnableWindow(bEnabled);
m_Edtremark.EnableWindow(bEnabled);
m_EdtstaffID.EnableWindow(bEnabled);
m_Edtstaffname.EnableWindow(bEnabled);
m_Comstaffdep.EnableWindow(bEnabled);
m_Sql_Grid.EnableWindow(bEnabled);
////////////////////
m_add.EnableWindow(!bEnabled);
m_change.EnableWindow(!bEnabled);
m_delete.EnableWindow(!bEnabled);
m_exit.EnableWindow(!bEnabled);
// m_Btnsel.EnableWindow(!bEnabled);
m_save.EnableWindow(bEnabled);
m_undo.EnableWindow(bEnabled);
}
void CCEvaluationInfo::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 CCEvaluationInfo::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 CCEvaluationInfo::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 CCEvaluationInfo::OnDblclkListGrid(NMHDR* pNMHDR, LRESULT* pResult) //双击列表函数
{
// TODO: Add your control notification handler code here
RxRecordset rRst;
CString sSql,sname,sID,sdep;
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("部门");
m_EdtID.SetWindowText(sID);
m_Edtname.SetWindowText(sname);
m_Comdept.SetWindowText(sdep);
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -