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

📄 dlgorderadd.cpp

📁 可以应用于企业商品管理
💻 CPP
字号:
// DlgOrderAdd.cpp : implementation file
//

#include "stdafx.h"
#include "MIS.h"
#include "DlgOrderAdd.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgOrderAdd dialog


//##ModelId=46B6093900BB
CDlgOrderAdd::CDlgOrderAdd(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgOrderAdd::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgOrderAdd)
	m_strProductName = _T("");
	m_strUnit = _T("");
	m_strType = _T("");
	m_strCustomerName = _T("");
	m_dwQuantity = 0;
	m_Time = CTime::GetCurrentTime();
	m_fPrice = 0.0f;
	m_fDiscount = 0.0f;
	m_strMemo = _T("");
	m_dwProductID = 0;
	//}}AFX_DATA_INIT
}


//##ModelId=46B60939010B
void CDlgOrderAdd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgOrderAdd)
	DDX_Control(pDX, IDC_COMBO2, m_ComboProductID);
	DDX_Text(pDX, IDC_EDIT_PRONAME, m_strProductName);
	DDX_Text(pDX, IDC_EDIT_UNIT, m_strUnit);
	DDX_Text(pDX, IDC_EDIT_TYPE, m_strType);
	DDX_Text(pDX, IDC_EDIT_CUSTOMERNAME, m_strCustomerName);
	DDX_Text(pDX, IDC_EDIT_QUANTITY, m_dwQuantity);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_Time);
	DDX_Text(pDX, IDC_EDIT_PRICE, m_fPrice);
	DDX_Text(pDX, IDC_EDIT_DISCOUNT, m_fDiscount);
	DDX_Text(pDX, IDC_EDIT_MEMO, m_strMemo);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgOrderAdd, CDialog)
	//{{AFX_MSG_MAP(CDlgOrderAdd)
	ON_BN_CLICKED(IDOK, OnOk)
	ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgOrderAdd message handlers

//##ModelId=46B609390139
void CDlgOrderAdd::OnOk() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_dwQuantity == 0)
	{
		MessageBox("销售数量不能为0");
		return;
	}
	if(m_fPrice < 0.01)
	{
		MessageBox("价格非法");
		return;
	}

	m_dwProductID = m_ComboProductID.GetItemData(m_ComboProductID.GetCurSel());
	CDialog::OnOK();	
	
}

//得到销售信息
//##ModelId=46B6093900CB
void CDlgOrderAdd::GetData(LPORDERINFO pOut)
{
	pOut -> strProductName = m_strProductName;
	pOut -> strUnit		   = m_strUnit;
	pOut -> strType		   = m_strType;
	pOut -> strMemo		   = m_strMemo;
	pOut -> dwQuantity     = m_dwQuantity;
	pOut -> fPrice		   = m_fPrice;
	pOut -> fDiscount	   = m_fDiscount;
	pOut -> strCustomerName= m_strCustomerName;
	pOut -> dwProductID	   = m_dwProductID;
	CString strTemp;
	strTemp.Format("%d-%d-%d" , m_Time.GetYear() , m_Time.GetMonth() , m_Time.GetDay());
	pOut -> strDate = strTemp;
}

//设置销售信息
//##ModelId=46B6093900CD
void CDlgOrderAdd::SetData(LPORDERINFO pIn)
{
	m_strProductName = pIn -> strProductName.c_str() ;
	m_strUnit		 = pIn -> strUnit.c_str()		;
	m_strType		 = pIn -> strUnit.c_str();
	m_strMemo		 = pIn -> strMemo.c_str();
	m_dwQuantity	 = pIn -> dwQuantity;
	m_fPrice		 = pIn -> fPrice;
	m_dwProductID	 = pIn -> dwProductID;
	m_fDiscount      = pIn -> fDiscount;
	m_strCustomerName= pIn -> strCustomerName.c_str();

	CString strYear , strMonth , strDay , strLast;
	CTime Timetemp;
//	wsscanf( pIn -> strDate ,"%s-%s-%s %s" , strYear , strMonth , strDay);
//	Timetemp.
	m_Time.Format(pIn -> strDate.c_str());
}


//设置商品信息列表
//##ModelId=46B6093900CF
void CDlgOrderAdd::SetProductList( vector<LPPRODUCTINFO>& vIn)
{
	m_pvProductInfo = &vIn;
}

//设置标题栏
//##ModelId=46B6093900BD
void CDlgOrderAdd::SetTitle(CHAR* lpszTitle)
{
	m_lpszTitle = lpszTitle;
}

//##ModelId=46B609390148
BOOL CDlgOrderAdd::OnInitDialog()
{
	CDialog::OnInitDialog();
	SetWindowText( m_lpszTitle );
	AddProductInfo();
	return TRUE;
}

//将商品信息加入列表 
//##ModelId=46B609390138
void CDlgOrderAdd::AddProductInfo()
{
	CString strList;
	size_t index = 0;

	for(size_t i = 0 ; i < m_pvProductInfo -> size() ; i++)
	{
		strList.Format("%ld  %s" , (*m_pvProductInfo)[i] -> dwProductID,
									(*m_pvProductInfo)[i] -> strProductName.c_str());

		m_ComboProductID.InsertString( i , strList);
		m_ComboProductID.SetItemData( i , (*m_pvProductInfo)[i] -> dwProductID);

		if( (*m_pvProductInfo)[i] -> dwProductID == m_dwProductID)
		{
			index = i;
		}

	}

	m_ComboProductID.SetCurSel(index);
	OnSelchangeCombo2();

}

//##ModelId=46B60939014A
void CDlgOrderAdd::OnSelchangeCombo2() 
{
	//当选择项改变时,就一起更新所有的商品信息。
	DWORD dwItem = m_ComboProductID.GetCurSel();
	m_strProductName = (*m_pvProductInfo)[dwItem] -> strProductName.c_str();
	m_strUnit		 = (*m_pvProductInfo)[dwItem] -> strUnit.c_str();
	m_strType		 = (*m_pvProductInfo)[dwItem] -> strType.c_str();
	UpdateData(FALSE);	
	
}

⌨️ 快捷键说明

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