www.gusucode.com > VC++毕业设计-库存管理系统(Access)-源码程序 > VC++毕业设计-库存管理系统(Access)-源码程序/code/源程序/DProvider.cpp
//Download by http://www.NewXing.com // 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; }