📄 employ.cpp
字号:
// Employ.cpp : implementation file
//
#include "stdafx.h"
#include "Rsglxt.h"
#include "Employ.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEmploy dialog
CEmploy::CEmploy(CWnd* pParent /*=NULL*/)
: CDialog(CEmploy::IDD, pParent)
{
//{{AFX_DATA_INIT(CEmploy)
//}}AFX_DATA_INIT
}
void CEmploy::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEmploy)
DDX_Control(pDX, IDC_COMDEP, m_Comdep);
DDX_Control(pDX, IDC_EDTMONEY, m_EdtEmmoney);
DDX_Control(pDX, IDC_EDTEMNAME, m_EdtEmname);
DDX_Control(pDX, IDC_EDTID, m_EdtEmID);
DDX_Control(pDX, IDC_Employ_Grid, m_Employ_Grid);
DDX_Control(pDX, IDC_BTNUNDO, m_Btnundo);
DDX_Control(pDX, IDC_BTNSAVE, m_Btnsave);
DDX_Control(pDX, IDC_BTNEXIT, m_Btnexit);
DDX_Control(pDX, IDC_BTNDEL, m_Btndel);
DDX_Control(pDX, IDC_BTNCHANGE, m_Btnchange);
DDX_Control(pDX, IDC_BTNADD, m_Btnadd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEmploy, CDialog)
//{{AFX_MSG_MAP(CEmploy)
ON_NOTIFY(NM_DBLCLK, IDC_Employ_Grid, OnDblclkEmployGrid)
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
ON_BN_CLICKED(IDC_BTNCHANGE, OnBtnchange)
ON_BN_CLICKED(IDC_BTNDEL, OnBtndel)
ON_BN_CLICKED(IDC_BTNSAVE, OnBtnsave)
ON_BN_CLICKED(IDC_BTNUNDO, OnBtnundo)
ON_BN_CLICKED(IDC_BTNEXIT, OnBtnexit)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEmploy message handlers
BOOL CEmploy::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
rst.Open("用工形式视图");
m_Employ_Grid.ReadOnly(true);
m_Employ_Grid.SetDataBase("用工形式视图",adCmdTable);
RxRecordset rs,ts;
rs.Open("部门视图");
m_Comdep.SetRecordset(rs,"部门名称");
ts.Open("select 部门名称 from 部门视图");
m_Comdep.SetFieldset(ts);
this->m_Comdep.m_CurrentFieldType="字符型";
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CEmploy::ButtonEnable(bool bEnabled)
{
m_EdtEmID.EnableWindow(bEnabled);
m_EdtEmname.EnableWindow(bEnabled);
m_Comdep.EnableWindow(bEnabled);
m_EdtEmmoney.EnableWindow(bEnabled);
m_Btnadd.EnableWindow(!bEnabled);
m_Btnchange.EnableWindow(!bEnabled);
m_Btndel.EnableWindow(!bEnabled);
m_Btnexit.EnableWindow(!bEnabled);
m_Btnsave.EnableWindow(bEnabled);
m_Btnundo.EnableWindow(bEnabled);
}
void CEmploy::Clear()
{
m_EdtEmname.SetWindowText("");
m_EdtEmmoney.SetWindowText("");
}
void CEmploy::OnDblclkEmployGrid(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
RxRecordset rRst;
CString sSql,sname,sID,smoney,sdep;
if(m_Employ_Grid.GetHotItem()<0)
return;
m_sID=this->m_Employ_Grid.GetItemText(m_Employ_Grid.GetHotItem(),0);
sSql.Format("SELECT * FROM 用工形式视图 WHERE 编号='%s'",m_sID);
rRst.Open(sSql,adCmdText);
sID=rRst.GetFieldValue("编号");
sdep=rRst.GetFieldValue("部门");
sname=rRst.GetFieldValue("用工形式名称");
smoney=rRst.GetFieldValue("用工形式补贴");
m_EdtEmID.SetWindowText(sID);
m_EdtEmname.SetWindowText(sname);
m_Comdep.SetWindowText(sdep);
m_EdtEmmoney.SetWindowText(smoney);
*pResult = 0;
}
void CEmploy::OnBtnadd()
{
// TODO: Add your control notification handler code here
CString NewID;
AddOrChange=1;
NewID=ado.AutoNumber("EmployFromInfo","EmployFrom_ID","",1);
m_EdtEmID.SetWindowText(NewID);
this->ButtonEnable(true);
m_Employ_Grid.EnableWindow(false);
this->Clear();
}
void CEmploy::OnBtnchange()
{
// TODO: Add your control notification handler code here
AddOrChange=2;
m_EdtEmname.SetFocus();
this->ButtonEnable(true);
}
void CEmploy::OnBtndel()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL;
sSQL.Format("DELETE FROM EmployFromInfo WHERE EmployFrom_ID='%s'",m_sID);
RxRecordset Drst;
Drst.Open(sSQL,adCmdText);
this->OnCancel();
}
void CEmploy::OnBtnsave()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString EmID,Emname,Emmoney,Emdep;
m_EdtEmID.GetWindowText(EmID);
m_EdtEmname.GetWindowText(Emname);
m_Comdep.GetWindowText(Emdep);
m_EdtEmmoney.GetWindowText(Emmoney);
if(Emname.IsEmpty())
{
MessageBox("输入的职称名称不能为空!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtEmname.SetFocus();
return;
}
if(Emmoney.IsEmpty())
{
MessageBox("输入的职称补贴不能为空!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtEmmoney.SetFocus();
return;
}
if(Emdep.IsEmpty())
{
MessageBox("输入的部门不能为空!","系统提示",MB_OK|MB_ICONSTOP);
m_Comdep.SetFocus();
return;
}
CString SQL;
if(AddOrChange==1)
SQL.Format("Insert Into EmployFromInfo Values('%s','%s','%s',%s)",EmID,Emdep,Emname,Emmoney);
else
SQL.Format("Update EmployFromInfo set EmployFrom_dep='%s',EmployFrom_name='%s',EmployFrom_money=%s WHERE EmployFrom_ID=%s",Emdep,Emname,Emmoney,EmID);
RxRecordset qst;
qst.Open(SQL,adCmdText);
this->ButtonEnable(false);
m_Employ_Grid.AddCellValue(rst);
UpdateData(true);
}
void CEmploy::OnBtnundo()
{
// TODO: Add your control notification handler code here
}
void CEmploy::OnBtnexit()
{
// TODO: Add your control notification handler code here
this->OnCancel();
}
void CEmploy::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 CEmploy::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 + -