⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 duty.cpp

📁 一个有关人事系统的所有代码和有关文件包括里面小量数据库。
💻 CPP
字号:
// Duty.cpp : implementation file
//

#include "stdafx.h"
#include "Rsglxt.h"
#include "Duty.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDuty dialog


CDuty::CDuty(CWnd* pParent /*=NULL*/)
	: CDialog(CDuty::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDuty)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDuty::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDuty)
	DDX_Control(pDX, IDC_LIST_DUTY, m_Duty_Grid);
	DDX_Control(pDX, IDC_EDTID, m_EdtdutyID);
	DDX_Control(pDX, IDC_EDTDYTUMONEY, m_Edtdutymoney);
	DDX_Control(pDX, IDC_EDTDUTYNAME, m_Edtdutyname);
	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(CDuty, CDialog)
	//{{AFX_MSG_MAP(CDuty)
	ON_WM_CANCELMODE()
	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_NOTIFY(NM_DBLCLK, IDC_LIST_DUTY, OnDblclkListDuty)
	ON_WM_PAINT()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDuty message handlers

BOOL CDuty::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	rst.Open("职务视图");
	m_Duty_Grid.ReadOnly(true);
	m_Duty_Grid.SetDataBase("职务视图",adCmdTable);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDuty::OnCancelMode() 
{
	CDialog::OnCancelMode();
	
	// TODO: Add your message handler code here
	
}

void CDuty::ButtonEnable(bool bEnabled)
{
	m_EdtdutyID.EnableWindow(bEnabled);
	m_Edtdutyname.EnableWindow(bEnabled);
	m_Edtdutymoney.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 CDuty::Clear()
{
	m_Edtdutyname.SetWindowText("");
	m_Edtdutymoney.SetWindowText("");

}

void CDuty::OnBtnadd() 
{
	// TODO: Add your control notification handler code here
	CString NewID;
	AddOrChange=1;
	NewID=ado.AutoNumber("DutyInfo","Duty_ID","",1);
	m_EdtdutyID.SetWindowText(NewID);
	this->ButtonEnable(true);
	m_Duty_Grid.EnableWindow(false);
	this->Clear();
}

void CDuty::OnBtnchange() 
{
	// TODO: Add your control notification handler code here
	AddOrChange=2;
	m_Edtdutyname.SetFocus();
	this->ButtonEnable(true);
}

void CDuty::OnBtndel() 
{
	// TODO: Add your control notification handler code here
	if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString sSQL;
	sSQL.Format("DELETE FROM DutyInfo WHERE Duty_ID='%s'",m_sID);
	RxRecordset Drst;
	Drst.Open(sSQL,adCmdText);
	this->OnCancel();
}

void CDuty::OnBtnsave() 
{
	// TODO: Add your control notification handler code here
	if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
		return;
	CString dutyID,dutyname,dutymoney;

	m_EdtdutyID.GetWindowText(dutyID);
	m_Edtdutyname.GetWindowText(dutyname);
	m_Edtdutymoney.GetWindowText(dutymoney);

	if(dutyname.IsEmpty())
	{
		MessageBox("输入的职务称名称不能为空!","系统提示",MB_OK|MB_ICONSTOP);
		m_Edtdutyname.SetFocus();
		return;
	}
	if(dutymoney.IsEmpty())
	{
		MessageBox("输入的职务补贴不能为空!","系统提示",MB_OK|MB_ICONSTOP);
		m_Edtdutymoney.SetFocus();
		return;
	}

	CString SQL;
	if(AddOrChange==1)
		SQL.Format("Insert Into DutyInfo Values('%s','%s',%s)",dutyID,dutyname,dutymoney);
	else
		SQL.Format("Update DutyInfo set Duty_name='%s',Duty_money=%s WHERE Duty_ID=%s",dutyname,dutymoney,dutyID);
	RxRecordset qst;
	qst.Open(SQL,adCmdText);

	this->ButtonEnable(false);
	m_Duty_Grid.AddCellValue(rst);
}

void CDuty::OnBtnundo() 
{
	// TODO: Add your control notification handler code here
	
}

void CDuty::OnBtnexit() 
{
	// TODO: Add your control notification handler code here
	this->OnCancel();
}

void CDuty::OnDblclkListDuty(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	RxRecordset rRst;
	CString sSql,sname,sID,smoney;
	if(m_Duty_Grid.GetHotItem()<0)
		return;
	m_sID=this->m_Duty_Grid.GetItemText(m_Duty_Grid.GetHotItem(),0);
	sSql.Format("SELECT * FROM 职务视图 WHERE 编号='%s'",m_sID);
	rRst.Open(sSql,adCmdText);
	sID=rRst.GetFieldValue("编号");
	sname=rRst.GetFieldValue("职务名称");
	smoney=rRst.GetFieldValue("职务补贴");

	m_EdtdutyID.SetWindowText(sID);
	m_Edtdutyname.SetWindowText(sname);
	m_Edtdutymoney.SetWindowText(smoney);
	*pResult = 0;
}

void CDuty::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 CDuty::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 + -