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

📄 dlgstockadd.cpp

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

#include "stdafx.h"
#include "MIS.h"
#include "DlgStockAdd.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgStockAdd dialog


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


//##ModelId=46B6093802C1
void CDlgStockAdd::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgStockAdd)
	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_QUANTITY, m_dwQuantity);
	DDX_Text(pDX, IDC_EDIT_PRICE, m_fPrice);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_Time);
	DDX_Text(pDX, IDC_EDIT_MEMO, m_strMemo);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CDlgStockAdd message handlers

//##ModelId=46B60938034C
void CDlgStockAdd::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=46B6093703AC
void CDlgStockAdd::GetData(LPSTOCKINFO 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 -> dwProductID	   = m_dwProductID;
	CString strTemp;
	strTemp.Format("%d-%d-%d" , m_Time.GetYear() , m_Time.GetMonth() , m_Time.GetDay());
	pOut -> strDate = strTemp;
}

//设置进货信息
//##ModelId=46B6093703AE
void CDlgStockAdd::SetData(LPSTOCKINFO 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;

	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=46B6093703BA
void CDlgStockAdd::SetProductList( vector<LPPRODUCTINFO>& vIn)
{
	m_pvProductInfo = &vIn;
}

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

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

//将商品信息加入列表 
//##ModelId=46B60938034B
void CDlgStockAdd::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=46B60938035B
void CDlgStockAdd::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 + -