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

📄 storehousesumanalysis.cpp

📁 完整功能的企业库存管理系统源码,vc++和sqlserver技术开发
💻 CPP
字号:
// StoreHouseSumAnalysis.cpp : implementation file
//

#include "stdafx.h"
#include "Store.h"
#include "StoreHouseSumAnalysis.h"

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

/////////////////////////////////////////////////////////////////////////////
// CStoreHouseSumAnalysis dialog


CStoreHouseSumAnalysis::CStoreHouseSumAnalysis(CWnd* pParent /*=NULL*/)
	: CDialog(CStoreHouseSumAnalysis::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStoreHouseSumAnalysis)
	m_year = _T("");
	m_monthBegin = _T("");
	m_monthEnd = _T("");
	m_storeHouse = _T("");
	m_productName = _T("");
	//}}AFX_DATA_INIT
}


void CStoreHouseSumAnalysis::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStoreHouseSumAnalysis)
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Control(pDX, IDC_storeHouse, m_storeHouseCombo);
	DDX_Control(pDX, IDC_productName, m_productNameCombo);
	DDX_CBString(pDX, IDC_year, m_year);
	DDX_CBString(pDX, IDC_monthBegin, m_monthBegin);
	DDX_CBString(pDX, IDC_monthEnd, m_monthEnd);
	DDX_CBString(pDX, IDC_storeHouse, m_storeHouse);
	DDX_CBString(pDX, IDC_productName, m_productName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStoreHouseSumAnalysis, CDialog)
	//{{AFX_MSG_MAP(CStoreHouseSumAnalysis)
	ON_BN_CLICKED(IDC_RADIO1, OnMaterial)
	ON_BN_CLICKED(IDC_RADIO2, OnProduct)
	ON_BN_CLICKED(IDC_BUTTON1, OnAnalysis)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStoreHouseSumAnalysis message handlers

void CStoreHouseSumAnalysis::OnMaterial() 
{
	// TODO: Add your control notification handler code here
	
}

void CStoreHouseSumAnalysis::OnProduct() 
{
	// TODO: Add your control notification handler code here
	
}

void CStoreHouseSumAnalysis::OnAnalysis() 
{
	UpdateData(true);//将对话框控件数据更新到变量
	m_list.DeleteAllItems();//清空列表框控件
	HRESULT hTRes;
	int flag=0;
	_RecordsetPtr m_pProductInputFormRecordset;
	CString strSQL;	
	hTRes=m_pProductInputFormRecordset.CreateInstance(_T("ADODB.Recordset"));
	_variant_t RecordsAffected;
	if(m_year==""||m_monthBegin==""||m_monthEnd=="")
	{
		AfxMessageBox("必须指定会计年度和会计期间!");
		return;
	}
	//构造执行存储过程的sql语句,根据不同的参数调用不同的存储过程

	if(m_productName!=""&&m_storeHouse=="")//指定产品名称
	{
		strSQL="exec allSummary01 '";
		strSQL=strSQL+m_year+"-"+m_monthBegin+"-1', "+"'"+m_year+"-"+m_monthEnd+"-1', '"+m_productName+"'";
	}
	else if(m_productName!=""&&m_storeHouse!="")//指定产品名称和仓库名称
	{
		strSQL="exec allSummary11 '";
		strSQL=strSQL+m_year+"-"+m_monthBegin+"-1', "+"'"+m_year+"-"+m_monthEnd+"-1', '"+m_productName+"' , '"+m_storeHouse+"'";
	}
	else if(m_productName=""&&m_storeHouse!="")//指定仓库名称
	{
		strSQL="exec allSummary10 '";
		strSQL=strSQL+m_year+"-"+m_monthBegin+"-1', "+"'"+m_year+"-"+m_monthEnd+"-1', '"+m_storeHouse+"'";
	}
	else if(m_productName==""&&m_storeHouse=="")//产品名称和仓库名称都不指定
	{
		strSQL="exec allSummary00 '";
		strSQL=strSQL+m_year+"-"+m_monthBegin+"-1', "+"'"+m_year+"-"+m_monthEnd+"-1'";
	}
	m_pProductInputFormRecordset=((CStoreApp*)AfxGetApp())->m_pConn->Execute((_bstr_t)strSQL,&RecordsAffected,adCmdText);//执行存储过程并返回结果记录集
	int i=0;
	//将执行结果显示再列表框中
	while(!(m_pProductInputFormRecordset->adoEOF))
	{
		m_list.InsertItem(i,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("storeHouse")));//仓库名称
		m_list.SetItemText(i,1,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("productID")));//产品编号
		m_list.SetItemText(i,2,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("productName")));//产品名称
		m_list.SetItemText(i,3,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("beginNum")));//期初数量
		m_list.SetItemText(i,4,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("beginPrice")));//期初单价
		m_list.SetItemText(i,5,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("beginTotal")));//期初金额
		m_list.SetItemText(i,6,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("inputNum")));//入库数量
		m_list.SetItemText(i,7,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("inputPrice")));//入库单价
		m_list.SetItemText(i,8,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("inputTotal")));//入库金额
		m_list.SetItemText(i,9,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("outputNum")));//出库数量
		m_list.SetItemText(i,10,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("outputPrice")));//出库单价
		m_list.SetItemText(i,11,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("outputTotal")));//出库金额
		m_list.SetItemText(i,12,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("sumNum")));//结存数量
		m_list.SetItemText(i,13,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("sumPrice")));//结存单价
		m_list.SetItemText(i,14,((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pProductInputFormRecordset->GetCollect("sumTotal")));//结存金额
		m_pProductInputFormRecordset->MoveNext();//记录集指针向后移动
		i++;
	}	
}

BOOL CStoreHouseSumAnalysis::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(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);

	m_list.InsertColumn(7,"入库数量",LVCFMT_LEFT,100);
	m_list.InsertColumn(8,"入库单价",LVCFMT_LEFT,100);
	m_list.InsertColumn(9,"入库金额",LVCFMT_LEFT,100);

	m_list.InsertColumn(10,"出库数量",LVCFMT_LEFT,100);
	m_list.InsertColumn(11,"出库单价",LVCFMT_LEFT,100);
	m_list.InsertColumn(12,"出库金额",LVCFMT_LEFT,100);

	m_list.InsertColumn(13,"结存数量",LVCFMT_LEFT,100);
	m_list.InsertColumn(14,"结存单价",LVCFMT_LEFT,100);
	m_list.InsertColumn(15,"结存金额",LVCFMT_LEFT,100);
		

	CString strSQL;
	HRESULT hTRes;
	_RecordsetPtr m_pRecordset;
	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();

	strSQL="select distinct productName from product";
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
		((CStoreApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
				adOpenDynamic,adLockPessimistic,adCmdText);
	if(SUCCEEDED(hTRes))
	{
		while(!(m_pRecordset->adoEOF))
		{		
			m_productNameCombo.AddString(((CStoreApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("productName")));
			m_pRecordset->MoveNext();
		}
	}
	m_pRecordset->Close();
	
	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 + -