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

📄 productoutputform.cpp

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CProductOutputForm dialog


CProductOutputForm::CProductOutputForm(CWnd* pParent /*=NULL*/)
	: CDialog(CProductOutputForm::IDD, pParent)
{
	//{{AFX_DATA_INIT(CProductOutputForm)
	m_productOutputFormID = _T("");
	m_storeHouse = _T("");
	m_department = _T("");
	m_seller = _T("");
	m_clientName = _T("");
	m_houseOutType = _T("");
	m_consignmentFormID = _T("");
	m_formDate = COleDateTime::GetCurrentTime();
	m_remark = _T("");

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


void CProductOutputForm::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CProductOutputForm)
	DDX_Control(pDX, IDC_consignmentFormID, m_consignmentFormIDCombo);
	DDX_Control(pDX, IDC_houseOutType, m_houseOutTypeCombo);
	DDX_Control(pDX, IDC_clientName, m_clientNameCombo);
	DDX_Control(pDX, IDC_seller, m_sellerCombo);
	DDX_Control(pDX, IDC_department, m_departmentCombo);
	DDX_Control(pDX, IDC_storeHouse, m_storeHouseCombo);
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Text(pDX, IDC_productOutputFormID, m_productOutputFormID);
	DDX_CBString(pDX, IDC_storeHouse, m_storeHouse);
	DDX_CBString(pDX, IDC_department, m_department);
	DDX_CBString(pDX, IDC_seller, m_seller);
	DDX_CBString(pDX, IDC_clientName, m_clientName);
	DDX_CBString(pDX, IDC_houseOutType, m_houseOutType);
	DDX_CBString(pDX, IDC_consignmentFormID, m_consignmentFormID);
	DDX_DateTimeCtrl(pDX, IDC_formDate, m_formDate);
	DDX_Text(pDX, IDC_remark, m_remark);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CProductOutputForm, CDialog)
	//{{AFX_MSG_MAP(CProductOutputForm)
	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()

/////////////////////////////////////////////////////////////////////////////
// CProductOutputForm message handlers

BOOL CProductOutputForm::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_productOutputFormID=GetDlgItem(IDC_productOutputFormID);
	tx_productOutputFormID->EnableWindow(false);

	tx_storeHouse=GetDlgItem(IDC_storeHouse);
	tx_department=GetDlgItem(IDC_department);
	tx_seller=GetDlgItem(IDC_seller);
	tx_clientName=GetDlgItem(IDC_clientName);
	tx_houseOutType=GetDlgItem(IDC_houseOutType);
	tx_consignmentFormID=GetDlgItem(IDC_consignmentFormID);
	tx_formDate=GetDlgItem(IDC_formDate);
	tx_remark=GetDlgItem(IDC_remark);

	HRESULT hTRes;
	_RecordsetPtr m_pRecordset;
	CString strSQL;
	strSQL="select distinct company from client";	
	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_clientNameCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("company")));
			m_pRecordset->MoveNext();
			}
		}
	}
	m_pRecordset->Close();

	strSQL="select distinct consignmentFormID from consignmentForm";	
//	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_consignmentFormIDCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("consignmentFormID")));
			m_pRecordset->MoveNext();
			}
		}
	}
	m_pRecordset->Close();

	strSQL="select distinct departmentName from department";	
//	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_departmentCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("departmentName")));
			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 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_sellerCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("staffName")));
				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_storeHouseCombo.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_pProductOutputFormRecordset;
		strSQL="select * from productOutputForm where productOutputFormID='";
		strSQL=strSQL+m_productOutputFormID+"'";
		HRESULT hTRes;
		hTRes = m_pProductOutputFormRecordset.CreateInstance(_T("ADODB.Recordset"));				
		hTRes = m_pProductOutputFormRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
		if(!(m_pProductOutputFormRecordset->adoEOF))
		{
			DATE dt;
			COleDateTime da;
			dt=m_pProductOutputFormRecordset->GetCollect("formDate").date;
			da=COleDateTime(dt); 
			m_formDate.SetDate(da.GetYear(),da.GetMonth(),da.GetDay());
			m_storeHouse = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductOutputFormRecordset->GetCollect("storeHouse"));
			m_department = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductOutputFormRecordset->GetCollect("sellDepartment"));
			m_seller = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductOutputFormRecordset->GetCollect("seller"));
			m_clientName = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductOutputFormRecordset->GetCollect("clientName"));
			m_houseOutType = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductOutputFormRecordset->GetCollect("houseOutType"));
			m_consignmentFormID = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductOutputFormRecordset->GetCollect("consignmentFormID"));
			m_remark = ((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductOutputFormRecordset->GetCollect("remark"));
			
			
			strSQL="select * from productOutputFormView where productOutputFormID='";
			strSQL=strSQL+m_productOutputFormID+"'";
			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_storeHouse->EnableWindow(false);
		tx_department->EnableWindow(false);
		tx_seller->EnableWindow(false);
		tx_clientName->EnableWindow(false);
		tx_houseOutType->EnableWindow(false);
		tx_consignmentFormID->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_storeHouse->EnableWindow(true);
		tx_department->EnableWindow(true);
		tx_seller->EnableWindow(true);
		tx_clientName->EnableWindow(true);
		tx_houseOutType->EnableWindow(true);
		tx_consignmentFormID->EnableWindow(true);
		tx_formDate->EnableWindow(true);
		tx_remark->EnableWindow(true);

		int formID=((CStoreApp*)AfxGetApp())->m_pIDRecordset->GetCollect("productOutputFormID").intVal;
		if(formID<10)
			m_productOutputFormID.Format("CPCK0000%d",formID);
		else if(formID<100&&formID>9)
			m_productOutputFormID.Format("CPCK000%d",formID);
		else if(formID<1000&&formID>99)
			m_productOutputFormID.Format("CPCK00%d",formID);

		CString str;
		str.Format("%d",formID+1);
		((CStoreApp*)AfxGetApp())->m_pIDRecordset->PutCollect("productOutputFormID",_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

⌨️ 快捷键说明

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