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

📄 productmoveform.cpp

📁 企业库存管理系统, 企业库存管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// ProductMoveForm.cpp : implementation file
//

#include "stdafx.h"
#include "Store.h"
#include "ProductMoveForm.h"
#include "SelectProduct.h"
#include "Affirm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CProductMoveForm dialog


CProductMoveForm::CProductMoveForm(CWnd* pParent /*=NULL*/)
	: CDialog(CProductMoveForm::IDD, pParent)
{
	//{{AFX_DATA_INIT(CProductMoveForm)
	m_productMoveFormID = _T("");
	m_storeHouseIn = _T("");
	m_storeHouseOut = _T("");
	m_dealer = _T("");
	m_houseOutType = _T("");
	m_formDate = COleDateTime::GetCurrentTime();
	m_remark = _T("");

	is_search=0;
	flag=1;
	//}}AFX_DATA_INIT
}


void CProductMoveForm::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CProductMoveForm)
	DDX_Control(pDX, IDC_houseOutType, m_houseOutTypeCombo);
	DDX_Control(pDX, IDC_dealer, m_dealerCombo);
	DDX_Control(pDX, IDC_storehouseOut, m_storeHouseOutCombo);
	DDX_Control(pDX, IDC_storehouseIn, m_storeHouseInCombo);
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Text(pDX, IDC_productMoveFormID, m_productMoveFormID);
	DDX_CBString(pDX, IDC_storehouseIn, m_storeHouseIn);
	DDX_CBString(pDX, IDC_storehouseOut, m_storeHouseOut);
	DDX_CBString(pDX, IDC_dealer, m_dealer);
	DDX_CBString(pDX, IDC_houseOutType, m_houseOutType);
	DDX_DateTimeCtrl(pDX, IDC_formDate, m_formDate);
	DDX_Text(pDX, IDC_remark, m_remark);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CProductMoveForm, CDialog)
	//{{AFX_MSG_MAP(CProductMoveForm)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList)
	ON_BN_CLICKED(IDC_add, OnAdd)
	ON_BN_CLICKED(IDC_modify, OnModify)
	ON_BN_CLICKED(IDC_delete, OnDelete)
	ON_BN_CLICKED(IDC_addLine, OnAddLine)
	ON_BN_CLICKED(IDC_deleteLine, OnDeleteLine)
	ON_BN_CLICKED(IDC_save, OnSave)
	ON_BN_CLICKED(IDC_cancelation, OnCancelation)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CProductMoveForm message handlers

BOOL CProductMoveForm::OnInitDialog() 
{
	CDialog::OnInitDialog();

	DWORD style;
	style=m_list.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_list.SetExtendedStyle(style);
	
	m_list.InsertColumn(0,"产品编号",LVCFMT_LEFT,100);
	m_list.InsertColumn(1,"产品名称",LVCFMT_LEFT,100);
	m_list.InsertColumn(2,"产品单位",LVCFMT_LEFT,100);
	m_list.InsertColumn(3,"产品型号",LVCFMT_LEFT,100);
	m_list.InsertColumn(4,"数量",LVCFMT_LEFT,100);
	m_list.InsertColumn(5,"单价",LVCFMT_LEFT,100);
	m_list.InsertColumn(6,"金额",LVCFMT_LEFT,100);

	bt_add=GetDlgItem(IDC_add);
	bt_delete=GetDlgItem(IDC_delete);
	bt_modify=GetDlgItem(IDC_modify);
	bt_addLine=GetDlgItem(IDC_addLine);
	bt_deleteLine=GetDlgItem(IDC_deleteLine);
	bt_save=GetDlgItem(IDC_save);
	bt_cancelation=GetDlgItem(IDC_cancelation);

	tx_productMoveFormID=GetDlgItem(IDC_productMoveFormID);
	tx_storeHouseIn=GetDlgItem(IDC_storehouseIn);
	tx_storeHouseOut=GetDlgItem(IDC_storehouseOut);
	tx_dealer=GetDlgItem(IDC_dealer);
	tx_houseOutType=GetDlgItem(IDC_houseOutType);
	tx_formDate=GetDlgItem(IDC_formDate);
	tx_remark=GetDlgItem(IDC_remark);

	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	CString strSQL;
	strSQL="select distinct staffName from staff";	
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		//----------------------------------------------------
		hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			while(!(m_pRecordset->adoEOF))
			{		
			m_dealerCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
			m_pRecordset->MoveNext();
			}
		}
	}
	m_pRecordset->Close();

	strSQL="select distinct houseOutTypeName from houseOutType";	
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		//----------------------------------------------------
		hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			while(!(m_pRecordset->adoEOF))
			{		
			m_houseOutTypeCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("houseOutTypeName")));
			m_pRecordset->MoveNext();
			}
		}
	}
	m_pRecordset->Close();

	strSQL="select distinct storeHouseName from storeHouse";	
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		//----------------------------------------------------
		hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
		if(SUCCEEDED(hTRes))
		{
			while(!(m_pRecordset->adoEOF))
			{		
			m_storeHouseInCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("storeHouseName")));
			m_storeHouseOutCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("storeHouseName")));
			m_pRecordset->MoveNext();
			}
		}
	}
	m_pRecordset->Close();


	if(is_search==1)
	{
		bt_add->EnableWindow(true);
		bt_delete->EnableWindow(true);
		bt_modify->EnableWindow(true);	
		bt_addLine->EnableWindow(false);
		bt_deleteLine->EnableWindow(false);
		bt_save->EnableWindow(false);
		bt_cancelation->EnableWindow(false);

		CString strSQL;
		_RecordsetPtr m_pRecordset;    //用于创建一个查询记录集
		_RecordsetPtr m_pProductMoveFormRecordset;
		strSQL="select * from productMoveForm where productMoveFormID='";
		strSQL=strSQL+m_productMoveFormID+"'";
		HRESULT hTRes;
		hTRes = m_pProductMoveFormRecordset.CreateInstance(_T("ADODB.Recordset"));				
		hTRes = m_pProductMoveFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
		if(!(m_pProductMoveFormRecordset->adoEOF))
		{
			DATE dt;
			COleDateTime da;
			dt=m_pProductMoveFormRecordset->GetCollect("formDate").date;
			da=COleDateTime(dt); 
			m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
			m_storeHouseIn = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductMoveFormRecordset->GetCollect("storehouseIn"));
			m_storeHouseOut = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductMoveFormRecordset->GetCollect("storehouseOut"));
			m_dealer = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductMoveFormRecordset->GetCollect("dealer"));
			m_houseOutType = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductMoveFormRecordset->GetCollect("houseOutType"));			
			m_remark = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductMoveFormRecordset->GetCollect("remark"));
			
			
			strSQL="select * from productMoveFormView where productMoveFormID='";
			strSQL=strSQL+m_productMoveFormID+"'";
			hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));				
			hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
				((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
			int i=0;
			while(!(m_pRecordset->adoEOF))
			{
				m_list.InsertItem(i,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productID")));
				m_list.SetItemText(i,1,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productName")));
				m_list.SetItemText(i,2,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("unit")));
				m_list.SetItemText(i,3,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("model")));
				m_list.SetItemText(i,4,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("num")));
				m_list.SetItemText(i,5,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("price")));
				m_list.SetItemText(i,6,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("total")));
				i++;
				m_pRecordset->MoveNext();
			}			
		}
		tx_productMoveFormID->EnableWindow(false);
		tx_storeHouseIn->EnableWindow(false);
		tx_storeHouseOut->EnableWindow(false);
		tx_dealer->EnableWindow(false);
		tx_houseOutType->EnableWindow(false);
		tx_formDate->EnableWindow(false);
		tx_remark->EnableWindow(false);
	}
	else
	{
		bt_add->EnableWindow(false);
		bt_delete->EnableWindow(false);
		bt_modify->EnableWindow(false);
		bt_addLine->EnableWindow(true);
		bt_deleteLine->EnableWindow(true);
		bt_save->EnableWindow(true);
		bt_cancelation->EnableWindow(true);

		tx_productMoveFormID->EnableWindow(true);
		tx_storeHouseIn->EnableWindow(true);
		tx_storeHouseOut->EnableWindow(true);
		tx_dealer->EnableWindow(true);
		tx_houseOutType->EnableWindow(true);
		tx_formDate->EnableWindow(true);
		tx_remark->EnableWindow(true);

		int formID=((CStoreApp*)AfxGetApp())->m_pIDRecordset->GetCollect("productMoveFormID").intVal;
		if(formID<10)
			m_productMoveFormID.Format("CPDB0000%d",formID);
		else if(formID<100&&formID>9)
			m_productMoveFormID.Format("CPDB000%d",formID);
		else if(formID<1000&&formID>99)
			m_productMoveFormID.Format("CPDB00%d",formID);

		CString str;
		str.Format("%d",formID+1);
		((CStoreApp*)AfxGetApp())->m_pIDRecordset->PutCollect("productMoveFormID",_variant_t(str));
		((CStoreApp*)AfxGetApp())->m_pIDRecordset->Update();
	}
	
	
	UpdateData(false);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CProductMoveForm::OnClickList(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

void CProductMoveForm::OnAdd() 
{
	flag=1;
	bt_add->EnableWindow(false);
	bt_delete->EnableWindow(false);
	bt_save->EnableWindow(true);
	bt_modify->EnableWindow(false);	
	bt_addLine->EnableWindow(true);
	bt_deleteLine->EnableWindow(true);
	bt_cancelation->EnableWindow(true);

	tx_productMoveFormID->EnableWindow(true);
	tx_storeHouseIn->EnableWindow(true);
	tx_storeHouseOut->EnableWindow(true);
	tx_dealer->EnableWindow(true);
	tx_houseOutType->EnableWindow(true);
	tx_formDate->EnableWindow(true);
	tx_remark->EnableWindow(true);

⌨️ 快捷键说明

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