?? dunit.cpp
字號:
// DUnit.cpp : implementation file
//
#include "stdafx.h"
#include "商品庫存管理系統.h"
#include "DUnit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr cnn;
extern CMyApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CDUnit dialog
CDUnit::CDUnit(CWnd* pParent /*=NULL*/)
: CDialog(CDUnit::IDD, pParent)
{
//{{AFX_DATA_INIT(CDUnit)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDUnit::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDUnit)
DDX_Control(pDX, IDC_LSTUnit, m_LstUnit);
DDX_Control(pDX, IDC_EDTUnit, m_EdtUnit);
DDX_Control(pDX, IDC_BUTExit, m_ButExit);
DDX_Control(pDX, IDC_BUTDele, m_ButDele);
DDX_Control(pDX, IDC_BUTAdd, m_ButAdd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDUnit, CDialog)
//{{AFX_MSG_MAP(CDUnit)
ON_BN_CLICKED(IDC_BUTAdd, OnBUTAdd)
ON_BN_CLICKED(IDC_BUTExit, OnBUTExit)
ON_BN_CLICKED(IDC_BUTDele, OnBUTDele)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDUnit message handlers
void CDUnit::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}
BOOL CDUnit::OnInitDialog()
{
CDialog::OnInitDialog();
rst.CreateInstance(__uuidof(Recordset));
rst=cnn->Execute(L"計量單位表",NULL,adCmdTable);
if(theApp.GetRecordCount(rst)>0)
{
this->m_LstUnit.SetRecordset(rst,"名稱");
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDUnit::OnBUTAdd()
{
CString sUnit,sSQL;
m_EdtUnit.GetWindowText(sUnit);
if(sUnit.IsEmpty())
{
MessageBox("請輸入您要添加的計量單位!","系統提示",MB_OK|MB_ICONSTOP);
m_EdtUnit.SetFocus();
return;
}
int a=MessageBox("確定要保存此計量單位嗎?","系統提示",MB_OKCANCEL|MB_ICONQUESTION);
if(a==1)
{
int NewID=theApp.AutoNumber(0,"計量單位表");
sSQL.Format("Insert Into 計量單位表 values(%d,'%s')",NewID,sUnit);
cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
m_EdtUnit.SetWindowText("");
m_LstUnit.UpDating();
m_LstUnit.SetFocus();
}
}
void CDUnit::OnBUTExit()
{
this->OnCancel();
}
void CDUnit::OnBUTDele()
{
CString sUnit,sSQL;
m_LstUnit.GetText(m_LstUnit.GetCurSel(),sUnit);
if(sUnit.IsEmpty())
{
MessageBox("請選擇一個計量單位!","系統提示",MB_OK|MB_ICONSTOP);
m_LstUnit.SetFocus();
}
int a=MessageBox("確定要刪除此計量單位嗎?","系統提示",MB_OKCANCEL|MB_ICONQUESTION);
if(a==1)
{
sSQL.Format("Delete from 計量單位表 Where 名稱='%s'",sUnit);
try{
cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
}
catch(...)
{
MessageBox("無法刪除此計量單位!","系統提示",MB_OK|MB_ICONSTOP);
}
m_EdtUnit.SetWindowText("");
m_LstUnit.UpDating();
m_LstUnit.SetFocus();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -