⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dware.cpp

📁 一个VC++写的商品库存管理系统
💻 CPP
字号:
// DWare.cpp : implementation file
//

#include "stdafx.h"
#include "商品库存管理系统.h"
#include "DWare.h"
#include "ExtendEdit_Grid.h"
#include "DWare_Edit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _ConnectionPtr cnn;
extern CMyApp theApp;
////////////////////////////////////////////////////////////////////////////
// CDWare dialog


CDWare::CDWare(CWnd* pParent /*=NULL*/)
	: CDialog(CDWare::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDWare)
	//}}AFX_DATA_INIT
}


void CDWare::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDWare)
	DDX_Control(pDX, IDC_BUTQuery, m_ButQuery);
	DDX_Control(pDX, IDC_COMField, m_ComField);
	DDX_Control(pDX, IDC_COMEmblem, m_ComEmblem);
	DDX_Control(pDX, IDC_EDTCondition, m_EdtCondition);
	DDX_Control(pDX, IDC_Grid, m_Grid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDWare, CDialog)
	//{{AFX_MSG_MAP(CDWare)
	ON_BN_CLICKED(IDC_BUTQuery, OnBUTQuery)
	ON_NOTIFY(NM_DBLCLK, IDC_Grid, OnDblclkGrid)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDWare message handlers

void CDWare::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

BOOL CDWare::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//设置图标
	m_hIcon=::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1));
	this->SetIcon(m_hIcon,true);
	rst=cnn->Execute(L"商品信息表",NULL,adCmdTable);
	if(theApp.GetRecordCount(rst)<=0)
	{
		this->OnCancel();
		CDWare_Edit dlg;
		rst->Close();
		dlg.DoModal();
	}
	this->OnBUTQuery();

  return TRUE;  // return TRUE unless you set the focus to a control	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDWare::OnBUTQuery() 
{
	CString sField,sEmblem,sCondition,sSQL;
	m_Grid.DeleAllCol(); 
	m_ComField.GetWindowText(sField);
	 m_ComEmblem.GetWindowText(sEmblem);
	 m_EdtCondition.GetWindowText(sCondition);
	 if(sEmblem!="LIKE")
		sSQL.Format("SELECT * from 商品信息查询 WHERE %s %s '%s'",sField,sEmblem,sCondition);
	 else
		sSQL.Format("SELECT * from 商品信息查询 WHERE %s LIKE '%s%%'",sField,sCondition);
	 try{
	 rst=cnn->Execute((_bstr_t)sSQL,NULL,adCmdText);
	 }
	 catch(...)
	 {
		 theApp.ADOError(rst);
	 }
	if(theApp.GetRecordCount(rst)>0)
	{
		this->m_Grid.SetRecordset(rst);
	}
	else
		m_Grid.Clear();
}
BOOL CDWare::PreTranslateMessage(MSG* pMsg) 
{
	return CDialog::PreTranslateMessage(pMsg);
}

void CDWare::OnDblclkGrid(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if(m_Grid.GetSelectionMark()!=-1)
	{
		CDWare_Edit dlg;
		CString ID;
		int Row=m_Grid.GetSelectionMark();
		ID=m_Grid.GetItemText(Row,0);
		dlg.DisplayNumber=ID;
		dlg.DoModal();
		m_Grid.Refresh();	
	}
	*pResult = 0;
}

void CDWare::OnBUTUpdating() 
{
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -