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

📄 dclient.cpp

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

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


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


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


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

/////////////////////////////////////////////////////////////////////////////
// CDClient message handlers

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

void CDClient::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();	

}

void CDClient::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;
}

BOOL CDClient::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
}

⌨️ 快捷键说明

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