📄 dzclb.cpp
字号:
// DZCLB.cpp : implementation file
//
#include "stdafx.h"
#include "gdzc.h"
#include "DZCLB.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDZCLB dialog
CDZCLB::CDZCLB(CString sCaption, CString sTipText, CString sDataBaseName,UINT adcmd,CWnd* pParent /*=NULL*/)
: CDialog(CDZCLB::IDD, pParent)
{
//{{AFX_DATA_INIT(CDZCLB)
//}}AFX_DATA_INIT
m_Caption=sCaption;
m_TipText=sTipText;
m_DataBaseName=sDataBaseName;
m_adCmd=adcmd;
}
void CDZCLB::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDZCLB)
DDX_Control(pDX, IDC_CHECK2, m_Chk);
DDX_Control(pDX, IDC_STATIT, m_StaTit);
DDX_Control(pDX, IDC_EDTTEXT, m_EdtText);
DDX_Control(pDX, IDC_LIST, m_Grid);
DDX_Control(pDX, IDC_BUTEXIT, m_BueExit);
DDX_Control(pDX, IDC_BUTDELE, m_ButDele);
DDX_Control(pDX, IDC_BUTADD, m_ButAdd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDZCLB, CDialog)
//{{AFX_MSG_MAP(CDZCLB)
ON_BN_CLICKED(IDC_BUTADD, OnButadd)
ON_BN_CLICKED(IDC_BUTDELE, OnButdele)
ON_BN_CLICKED(IDC_BUTEXIT, OnButexit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CDZCLB::OnOK()
{
// TODO: Add extra validation here
}
BOOL CDZCLB::OnInitDialog()
{
CDialog::OnInitDialog();
SetWindowText(m_Caption);
m_StaTit.SetWindowText(m_TipText);
if(m_Caption=="固定资产类别管理" ||m_Caption=="资产使用状况管理" )
m_Chk.EnableWindow(true);
m_Grid.ReadOnly(true);
m_Grid.SetDataBase(m_DataBaseName,m_adCmd);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDZCLB::OnButadd()
{
CString sName,sID,sSQL;
this->m_EdtText.GetWindowText(sName);
if(sName.IsEmpty())
{
MessageBox("请在上面[ "+m_TipText.Left(m_TipText.GetLength()-1)+" ]文本框内输入想要添加的新类别名称!","系统提示",MB_OK|MB_ICONSTOP);
m_EdtText.SetFocus();
return;
}
CString sMsg,sjt,sN;
int nChk=m_Chk.GetCheck();
if(nChk==1)
sjt="计提";
else
sjt="不计提";
if(m_Caption=="固定资产类别管理" )
sMsg.Format("确定资产类别[ %s ]在固定资产折旧时%s?",sName,sjt);
else
if(m_Caption=="资产使用状况管理" )
sMsg.Format("确定资产类别[ %s ]在固定资产折旧时%s?",sName,sjt);
else
sMsg.Format("确定保存记录吗?");
if(MessageBox(sMsg,"系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
if(m_DataBaseName.Right(4)=="视图")
{
sN=m_DataBaseName.Left(m_DataBaseName.GetLength()-4)+"表";
sID=ado.AutoNumber(sN,"编号","",1);
}
else
sID=ado.AutoNumber(m_DataBaseName,"编号","",1);
if(m_Caption=="固定资产类别管理" ||m_Caption=="资产使用状况管理" )
sSQL.Format("INSERT INTO %s values(%s,'%s',%d)",sN,sID,sName,nChk);
else
sSQL.Format("INSERT INTO %s values(%s,'%s')",m_DataBaseName,sID,sName);
rst.Open(sSQL,adCmdText);
rst.Open(m_DataBaseName);
m_Grid.AddCellValue(rst);
MessageBox("添加成功!","系统提示",MB_OK|MB_ICONQUESTION);
m_EdtText.SetWindowText("");
}
void CDZCLB::OnButdele()
{
CString sSQL,sText;
sText=m_Grid.GetItemText(m_Grid.GetRow(),0);
if(sText.IsEmpty())
{
MessageBox("请在左侧表格内选择一条要删除的记录!","系统提示",MB_OK|MB_ICONSTOP);
m_Grid.GetFocus();
return;
}
if(MessageBox("确定要删除此条记录吗?","系统提示",MB_OKCANCEL|MB_ICONQUESTION)!=1)
return;
if(m_Caption=="固定资产类别管理" ||m_Caption=="资产使用状况管理" )
sSQL.Format("DELETE FROM %s WHERE 名称='%s'",m_DataBaseName,sText);
else
sSQL.Format("DELETE FROM %s WHERE 编号=%s",m_DataBaseName,sText);
rst.Open(sSQL,adCmdText);
rst.Open(m_DataBaseName);
m_Grid.AddCellValue(rst);
}
void CDZCLB::OnButexit()
{
this->OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -