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