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

📄 pstatistics.cpp

📁 小型自选商场商品管理系统 要求:能对小型自选商场的商品进货、销售、库存等环节进行管理。主要有: 1)能记录每一笔进货
💻 CPP
字号:
// PStatistics.cpp : implementation file
//

#include "stdafx.h"
#include "ShopManage.h"
#include "PStatistics.h"

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


extern _RecordsetPtr Record1;
extern	_ConnectionPtr DataConn;
extern	_RecordsetPtr DataRecord;
extern	_CommandPtr Com;
/////////////////////////////////////////////////////////////////////////////
// PStatistics dialog


PStatistics::PStatistics(CWnd* pParent /*=NULL*/)
	: CDialog(PStatistics::IDD, pParent)
{
	//{{AFX_DATA_INIT(PStatistics)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void PStatistics::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(PStatistics)
	DDX_Control(pDX, IDC_PCOMBO, m_Month);
	DDX_Control(pDX, IDC_PurchaseLIST, m_PurchaseList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(PStatistics, CDialog)
	//{{AFX_MSG_MAP(PStatistics)
	ON_WM_CLOSE()
	ON_BN_CLICKED(IDC_StaticsClose, OnStaticsClose)
	ON_BN_CLICKED(IDC_LoadInformation, OnLoadInformation)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// PStatistics message handlers

void PStatistics::OnOK() 
{
	// TODO: Add extra validation here
	
	//CDialog::OnOK();
}

BOOL PStatistics::OnInitDialog()
{
	CDialog::OnInitDialog();
	
	m_PurchaseList.ModifyStyle(LVS_EDITLABELS,0);
	m_PurchaseList.ModifyStyle(0,LVS_REPORT);
	m_PurchaseList.ModifyStyle(0,LVS_SHOWSELALWAYS);
	m_PurchaseList.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_GRIDLINES|LVS_EX_ONECLICKACTIVATE|LVS_EX_FLATSB);

	m_PurchaseList.InsertColumn(0,"进货ID");
	m_PurchaseList.InsertColumn(1,"商品ID");
	m_PurchaseList.InsertColumn(2,"进价");
	m_PurchaseList.InsertColumn(3,"数量");
	m_PurchaseList.InsertColumn(4,"金额");
	m_PurchaseList.InsertColumn(5,"日期");
	//设置列宽度
	m_PurchaseList.SetColumnWidth(0,80);
	m_PurchaseList.SetColumnWidth(1,80);
	m_PurchaseList.SetColumnWidth(2,67);	
	m_PurchaseList.SetColumnWidth(3,68);
	m_PurchaseList.SetColumnWidth(4,80);
	m_PurchaseList.SetColumnWidth(5,100);

	LoadMonth();
	return TRUE;
}

void PStatistics::LoadMonth()
{
	CString str;
	for(int i=1;i<10;i++)
	{
		str = "";
		str+=char(i+48);
		m_Month.AddString(str);
	}
	m_Month.AddString("10");
	m_Month.AddString("11");
	m_Month.AddString("12");
}

void PStatistics::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
	//CDialog::OnClose();
}

void PStatistics::OnStaticsClose() 
{
	// TODO: Add your control notification handler code here
	EndDialog(0);
}

CString PStatistics::GetMonth(CString str)
{
	CString month = "";
	if(str.GetAt(5) != '0')
	{
		month+=str.GetAt(5);
		if(str.GetAt(6) != '/')
			month+=str.GetAt(6);
	}
	else
		month+=str.GetAt(6);
	return month;
}

void PStatistics::OnLoadInformation() 
{
	// TODO: Add your control notification handler code here
	CString date,month,sql,temp,Month;
	m_Month.GetWindowText(month);
	/*************************************/
	Record1->raw_Close();
	sql.Format("select * from Purchase");
	Record1->Open((_variant_t)sql,DataConn.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
	int row = 0;
	m_PurchaseList.DeleteAllItems();
	while (!Record1->adoEOF)
	{
		temp = (TCHAR*)(_bstr_t)Record1->GetFields()->GetItem((long)5)->Value;
		Month = GetMonth(temp);
		if(Month == month)
		{
			m_PurchaseList.InsertItem(100,"");
			for (int col = 0;col <6;col++)
			{
				m_PurchaseList.SetItemText(row,col,(TCHAR*)(_bstr_t)Record1->GetFields()->GetItem((long)col)->Value);
			}
			row += 1;	
		}
		Record1->MoveNext();
	}
}

⌨️ 快捷键说明

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