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

📄 sellentrydlg.cpp

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

#include "stdafx.h"
#include "heavenmis.h"
#include "SellEntryDlg.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

/////////////////////////////////////////////////////////////////////////////
// CSellEntryDlg dialog


CSellEntryDlg::CSellEntryDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSellEntryDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSellEntryDlg)
	m_datetime = COleDateTime::GetCurrentTime();
	m_intQuantity = 0;
	m_fAmount = 0.0f;
	//}}AFX_DATA_INIT
}


void CSellEntryDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSellEntryDlg)
	DDX_Control(pDX, IDC_COMBO_CUSTOMER, m_comboCus);
	DDX_Control(pDX, IDC_COMBO_EMPLOYEE, m_comboEmp);
	DDX_Control(pDX, IDC_COMBO_PRODUCT, m_comboProd);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_SELL, m_datetime);
	DDX_Text(pDX, IDC_EDIT_QUANTITY, m_intQuantity);
	DDX_Text(pDX, IDC_EDIT_AMOUNT, m_fAmount);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSellEntryDlg, CDialog)
	//{{AFX_MSG_MAP(CSellEntryDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSellEntryDlg message handlers

BOOL CSellEntryDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();	
	// TODO: Add extra initialization here
	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;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSellEntryDlg::OnOK() 
{
	UpdateData(TRUE);

	CString productName,empName,cusName;
	m_comboProd.GetWindowText(productName);
	CProduct product;
	int quantity;
	//获得该商品的当前数量
	quantity=product.GetAmountByName(productName);
	//判断要求销售量是否能够满足
	if(quantity<m_intQuantity)
	{	
		MessageBox("目前库存量不足!");
		return;
	}
	//获得商品、客户、员工的ID
	long productID=product.GetKeyByName(productName);
    m_comboCus.GetWindowText(cusName);
	CCustomer customer;
	long customerID=customer.GetKeyByName(cusName);
	m_comboEmp.GetWindowText(empName);
	CEmployee employee;
	int empID=employee.GetKeyByName(empName);
    //添加销售记录到tbSell
	CADORecordset* pRs=new CADORecordset(((CHeavenMISApp*)AfxGetApp())->pDB);
	pRs->Open("select * from tbSell",CADORecordset.openQuery);
	pRs->AddNew();
	pRs->SetFieldValue("SellDate",m_datetime);
	pRs->SetFieldValue("ProductID",productID);
	pRs->SetFieldValue("Quantity",m_intQuantity);
	pRs->SetFieldValue("Amount",m_fAmount);
	pRs->SetFieldValue("CustomerID",customerID);
	pRs->SetFieldValue("EmployeeID",empID);
	pRs->Update();
	//修改销售商品的当前数量
	product.SetCurAmount(quantity-m_intQuantity);
	product.SetAmountByName(productName);
	CDialog::OnOK();
}

⌨️ 快捷键说明

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