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

📄 dprovider.cpp

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

#include "stdafx.h"
#include "商品库存管理系统.h"
#include "DProvider.h"
#include "DClient_Edit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDProvider dialog
extern _ConnectionPtr cnn;
extern CMyApp theApp;

CDProvider::CDProvider(CWnd* pParent /*=NULL*/)
	: CDialog(CDProvider::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDProvider)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


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


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

/////////////////////////////////////////////////////////////////////////////
// CDProvider message handlers

void CDProvider::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(...)
	 {
	 }
	if(theApp.GetRecordCount(rst)>0)
	{
		this->m_Grid.SetRecordset(rst);
	}
	else
		m_Grid.Clear();	
}

BOOL CDProvider::OnInitDialog() 
{
	CDialog::OnInitDialog();
	//设置图标
	m_hIcon=::LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON10));
	this->SetIcon(m_hIcon,true);
		rst=cnn->Execute(L"供应商信息表",NULL,adCmdTable);
	if(theApp.GetRecordCount(rst)<=0)
	{
		this->OnCancel();
		CDClient_Edit dlg;
		dlg.DateBaseName="供应商信息表";
		dlg.WindowText="供应商信息管理";
		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 CDProvider::OnDblclkGrid(NMHDR* pNMHDR, LRESULT* pResult) 
{
	POSITION pos;
	pos=m_Grid.GetFirstSelectedItemPosition();
	if(pos)
	{
		CDClient_Edit dlg;
		CString ID;
		int Row=m_Grid.GetHotItem();
		ID=m_Grid.GetItemText(Row,0);
		dlg.DateBaseName="供应商信息表";
		dlg.WindowText="供应商信息管理";
		dlg.DisplayNumber=ID;
		dlg.DoModal();
		m_Grid.Refresh();
	}		
	*pResult = 0;
}

⌨️ 快捷键说明

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