📄 titleset.cpp
字号:
// Titleset.cpp : implementation file
//
#include "stdafx.h"
#include "Rsglxt.h"
#include "Titleset.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTitleset dialog
CTitleset::CTitleset(CWnd* pParent /*=NULL*/)
: CDialog(CTitleset::IDD, pParent)
{
//{{AFX_DATA_INIT(CTitleset)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CTitleset::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTitleset)
DDX_Control(pDX, IDC_LIST_TITLE, m_Title_Grid);
DDX_Control(pDX, IDC_EDIT_TITLENAME, m_EdtTitleName);
DDX_Control(pDX, IDC_EDIT_TITLEMONEY, m_EdtTitleMoney);
DDX_Control(pDX, IDC_EDIT_TITLEID, m_EdtTitleID);
DDX_Control(pDX, IDC_BTN_UNDO, m_Btnundo);
DDX_Control(pDX, IDC_BTN_SAVE, m_Btnsave);
DDX_Control(pDX, IDC_BTN_EXIT, m_Btnexit);
DDX_Control(pDX, IDC_BTN_DEL, m_Btndel);
DDX_Control(pDX, IDC_BTN_CHANGE, m_Btnchange);
DDX_Control(pDX, IDC_BTN_ADD, m_Btnadd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTitleset, CDialog)
//{{AFX_MSG_MAP(CTitleset)
ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
ON_BN_CLICKED(IDC_BTN_CHANGE, OnBtnChange)
ON_BN_CLICKED(IDC_BTN_DEL, OnBtnDel)
ON_BN_CLICKED(IDC_BTN_SAVE, OnBtnSave)
ON_BN_CLICKED(IDC_BTN_UNDO, OnBtnUndo)
ON_BN_CLICKED(IDC_BTN_EXIT, OnBtnExit)
ON_NOTIFY(NM_DBLCLK, IDC_LIST_TITLE, OnDblclkListTitle)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTitleset message handlers
void CTitleset::OnBtnAdd()
{
// TODO: Add your control notification handler code here
CString NewID;
AddOrChange=1;
NewID=ado.AutoNumber("TitleInfo","Title_ID","",1);
m_EdtTitleID.SetWindowText(NewID);
this->ButtonEnable(true);
m_Title_Grid.EnableWindow(false);
this->Clear();
}
void CTitleset::OnBtnChange()
{
// TODO: Add your control notification handler code here
AddOrChange=2;
m_EdtTitleName.SetFocus();
this->ButtonEnable(true);
}
void CTitleset::OnBtnDel()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString sSQL;
sSQL.Format("DELETE FROM TitleInfo WHERE Title_ID='%s'",m_sID);
RxRecordset Drst;
Drst.Open(sSQL,adCmdText);
this->OnCancel();
}
void CTitleset::OnBtnSave()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要保存记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
CString titleID,titlename,titledep,titlemoney;
m_EdtTitleID.GetWindowText(titleID);
m_EdtTitleName.GetWindowText(titlename);
m_EdtTitleMoney.GetWindowText(titlemoney);
if(titlename.IsEmpty())
{
MessageBox("输入的职称名称不能为空!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtTitleName.SetFocus();
return;
}
if(titlemoney.IsEmpty())
{
MessageBox("输入的职称补贴不能为空!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtTitleMoney.SetFocus();
return;
}
CString SQL;
if(AddOrChange==1)
SQL.Format("Insert Into TitleInfo Values('%s','%s',%s)",titleID,titlename,titlemoney);
else
SQL.Format("Update TitleInfo set Title_name='%s',Title_money=%s WHERE Title_ID=%s",titlename,titlemoney,titleID);
RxRecordset qst;
qst.Open(SQL,adCmdText);
this->ButtonEnable(false);
m_Title_Grid.AddCellValue(rst);
}
void CTitleset::OnBtnUndo()
{
// TODO: Add your control notification handler code here
if(MessageBox("确定要撤消操作吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
// this->Display(m_sID);
this->m_Btnadd.SetFocus();
}
void CTitleset::OnBtnExit()
{
// TODO: Add your control notification handler code here
this->OnCancel();
}
void CTitleset::ButtonEnable(bool bEnabled)
{
m_EdtTitleID.EnableWindow(bEnabled);
m_EdtTitleName.EnableWindow(bEnabled);
m_EdtTitleMoney.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);
}
BOOL CTitleset::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
rst.Open("职称视图");
m_Title_Grid.ReadOnly(true);
m_Title_Grid.SetDataBase("职称视图",adCmdTable);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTitleset::OnDblclkListTitle(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
RxRecordset rRst;
CString sSql,sname,sID,smoney;
if(m_Title_Grid.GetHotItem()<0)
return;
m_sID=this->m_Title_Grid.GetItemText(m_Title_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_EdtTitleID.SetWindowText(sID);
m_EdtTitleName.SetWindowText(sname);
m_EdtTitleMoney.SetWindowText(smoney);
*pResult = 0;
}
void CTitleset::Clear()
{
m_EdtTitleName.SetWindowText("");
m_EdtTitleMoney.SetWindowText("");
}
void CTitleset::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 CTitleset::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 + -