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

📄 selldlg.cpp

📁 玩具百货公司销售进货记录系统!界面比较齐全,功能完善
💻 CPP
字号:
// SellDlg.cpp : implementation file
//

#include "stdafx.h"
#include "heavenmis.h"
#include "SellDlg.h"
#include "product.h"
#include "customer.h"
#include "employee.h"


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

/////////////////////////////////////////////////////////////////////////////
// CSellDlg dialog


CSellDlg::CSellDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSellDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSellDlg)
	m_strCustomer = _T("");
	m_strEmployee = _T("");
	m_strProduct = _T("");
	//}}AFX_DATA_INIT
}


void CSellDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSellDlg)
	DDX_Control(pDX, IDC_COMBO_PRODUCT, m_comboProd);
	DDX_Control(pDX, IDC_COMBO_EMPLOYEE, m_comboEmp);
	DDX_Control(pDX, IDC_COMBO_CUSTOMER, m_comboCus);
	DDX_Control(pDX, IDC_ADODC1, m_adodcSell);
	DDX_CBString(pDX, IDC_COMBO_CUSTOMER, m_strCustomer);
	DDX_CBString(pDX, IDC_COMBO_EMPLOYEE, m_strEmployee);
	DDX_CBString(pDX, IDC_COMBO_PRODUCT, m_strProduct);
	DDX_Control(pDX, IDC_DATAGRID1, m_datagridSell);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSellDlg, CDialog)
	//{{AFX_MSG_MAP(CSellDlg)
	ON_BN_CLICKED(IDC_BUTTON_QUERY, OnButtonQuery)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSellDlg message handlers

BOOL CSellDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CADORecordset* pRs=new CADORecordset(((CHeavenMISApp*)AfxGetApp())->pDB);
	//查询所有商品名初始化comboBox中
	pRs->Open("select Name from tbProduct",CADORecordset.openQuery);
	CString temp;
	if(pRs->GetRecordCount()>0)
	{
		while(!pRs->IsEOF())
		{
			pRs->GetFieldValue("Name",temp);
			m_comboProd.AddString(temp);
			pRs->MoveNext();
		}
	}
	pRs->Close();
	//查询所有客户名初始化comboBox
	pRs->Open("select CompanyName from tbCustomer",CADORecordset.openQuery);
	if(pRs->GetRecordCount()>0)
	{
		while(!pRs->IsEOF())
		{
			pRs->GetFieldValue("CompanyName",temp);
			m_comboCus.AddString(temp);
			pRs->MoveNext();
		}
	}
	pRs->Close();
	//查询所有雇员名初始化comboBox控件
	pRs->Open("select Name from tbEmployee",CADORecordset.openQuery);
	if(pRs->GetRecordCount()>0)
	{
		while(!pRs->IsEOF())
		{
			pRs->GetFieldValue("Name",temp);
			m_comboEmp.AddString(temp);
			pRs->MoveNext();
		}
	}
	pRs->Close();
	delete pRs;
	return TRUE;  
}

void CSellDlg::OnButtonQuery() 
{
	UpdateData(TRUE);
	long cusID,prodID;
	int empID;
	CString strSQL,temp1,temp2,temp3;
	strSQL="select * from tbSell ";
	if(!m_strCustomer.IsEmpty())
	{
		CCustomer customer;
		cusID=customer.GetKeyByName(m_strCustomer);
		temp1.Format("where CustomerID=%d ",cusID);
		strSQL+=temp1;
	}
	if(!m_strProduct.IsEmpty())
	{
		CProduct product;
		prodID=product.GetKeyByName(m_strProduct);
		if(!m_strCustomer.IsEmpty())
			temp2.Format("and ProductID=%d ",prodID);
		else temp2.Format("where ProductID=%d ",prodID);

		strSQL+=temp2;
	}
	if(!m_strEmployee.IsEmpty())
	{
		CEmployee employee;
		empID=employee.GetKeyByName(m_strEmployee);
		if(m_strCustomer.IsEmpty()&&m_strProduct.IsEmpty())
			temp3.Format("where EmployeeID=%d",empID);
		else temp3.Format("and EmployeeID=%d",empID);
		strSQL+=temp3;
	}
	m_adodcSell.SetRecordSource(strSQL);
	m_adodcSell.Refresh();
}

⌨️ 快捷键说明

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