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

📄 checkbasicinfodlg.cpp

📁 库存管理信息系统
💻 CPP
字号:
// CheckBasicInfoDLG.cpp : implementation file
//

#include "stdafx.h"
#include "Material_MIS.h"
#include "CheckBasicInfoDLG.h"
#include "Material_MISView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CCheckBasicInfoDLG dialog


CCheckBasicInfoDLG::CCheckBasicInfoDLG(CWnd* pParent /*=NULL*/)
	: CDialog(CCheckBasicInfoDLG::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCheckBasicInfoDLG)
	m_bSpecChecked = FALSE;
	m_bNameChecked = FALSE;
	//}}AFX_DATA_INIT
}


void CCheckBasicInfoDLG::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCheckBasicInfoDLG)
	DDX_Check(pDX, IDC_CHECK2, m_bSpecChecked);
	DDX_Check(pDX, IDC_CHECK1, m_bNameChecked);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCheckBasicInfoDLG, CDialog)
	//{{AFX_MSG_MAP(CCheckBasicInfoDLG)
	ON_CBN_SELCHANGE(IDC_COMB_WZNAME, OnSelchangeCombWzname)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCheckBasicInfoDLG message handlers

void CCheckBasicInfoDLG::OnOK() 
{
	// TODO: Add extra validation here
	// ... modified by jackie ...
	UpdateData(TRUE);
	int index;

	if ( !m_bNameChecked && !m_bSpecChecked)
	{
		AfxMessageBox(_T("请选择查询条件!"), MB_ICONEXCLAMATION);
		return;
	}
	if (m_bNameChecked)
	{
		index = ((CComboBox*)GetDlgItem(IDC_COMB_WZNAME))->GetCurSel();
		((CComboBox*)GetDlgItem(IDC_COMB_WZNAME))->GetLBText(index,m_sName);
	}
	else
		m_sName="%";
	if (m_bSpecChecked)
	{
		index = ((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->GetCurSel();
		((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->GetLBText(index,m_sSpec);
	}
	else
		m_sSpec="%";

	_variant_t strQuery;
	strQuery = "select * from tblMaterial where fldWzname like '"+m_sName+"' and fldWzspec like '"+m_sSpec+"'";
	CMaterial_MISView* p = (CMaterial_MISView*)(((CMainFrame*)AfxGetMainWnd())->GetActiveView());
	p->RefreshMaterialWindow(strQuery);
	CDialog::OnOK();
}

BOOL CCheckBasicInfoDLG::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// ... add by jackie ... 
	SetWindowText("查询物资基本信息");
	_variant_t strQuery, Holder;
	int count,count2,i;
	strQuery = "select distinct fldWzname from tblMaterial";
	theApp.ADOExecute(theApp.m_pADOSet,strQuery);

	count = theApp.m_pADOSet->GetRecordCount();
	if(count>0)
	{
		theApp.m_pADOSet->MoveFirst();
		Holder = theApp.m_pADOSet->GetCollect("fldWzname");
		CString strName = Holder.bstrVal;

		theApp.m_pADOSet->MoveFirst();
		for(i = 0;i<count;i++)
		{
			Holder = theApp.m_pADOSet->GetCollect("fldWzname");
			((CComboBox*)GetDlgItem(IDC_COMB_WZNAME))->InsertString(i, Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
			theApp.m_pADOSet->MoveNext();
		}
		((CComboBox*)GetDlgItem(IDC_COMB_WZNAME))->SetCurSel(0);

		strQuery = "select * from tblMaterial where fldWzname='"+strName+"'";
		theApp.ADOExecute(theApp.m_pADOSet,strQuery);

		count2 = theApp.m_pADOSet->GetRecordCount();
		theApp.m_pADOSet->MoveFirst();
		for(i = 0;i<count2;i++)
		{
			Holder = theApp.m_pADOSet->GetCollect("fldWzspec");
			((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->InsertString(i, Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
			theApp.m_pADOSet->MoveNext();
		}
		((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->SetCurSel(0);
	}

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

void CCheckBasicInfoDLG::OnSelchangeCombWzname() 
{
	// TODO: Add your control notification handler code here
	// ... add by jackie ... 
	int i,index,count,count2;
	CString strText;
	_variant_t strQuery, Holder;

	index = ((CComboBox*)GetDlgItem(IDC_COMB_WZNAME))->GetCurSel();
	if(index != CB_ERR)
	{
		((CComboBox*)GetDlgItem(IDC_COMB_WZNAME))->GetLBText(index,strText);
		count2 = ((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->GetCount();
		for(i = 0;i<count2;i++)
		{
			((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->DeleteString(0);
		}

		strQuery = "select * from tblMaterial where fldWzname = '"+strText+"'";
		theApp.ADOExecute(theApp.m_pADOSet,strQuery);

		count = theApp.m_pADOSet->GetRecordCount();
		theApp.m_pADOSet->MoveFirst();
		for(i = 0;i<count;i++)
		{
			Holder = theApp.m_pADOSet->GetCollect("fldWzspec");
			((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->InsertString(i, Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
			theApp.m_pADOSet->MoveNext();
		}
		((CComboBox*)GetDlgItem(IDC_COMB_WZSPEC))->SetCurSel(0);
	}
}

⌨️ 快捷键说明

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