?? 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 + -