📄 selleventdlg.cpp
字号:
// SellEventDlg.cpp : implementation file
//
#include "stdafx.h"
#include "QGZX_InfoPlat.h"
#include "SellEventDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSellEventDlg dialog
CSellEventDlg::CSellEventDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSellEventDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSellEventDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_ds = new CData();
m_ds->InitData();
m_dsClass = new CData();
m_dsClass->InitData();
}
void CSellEventDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSellEventDlg)
DDX_Control(pDX, IDC_COMBO_MANAGERNAME, m_comboManagerName);
DDX_Control(pDX, IDC_COMBO_CLASSNAME, m_comboClassname);
DDX_Control(pDX, IDC_LIST_SELLEVENT, m_listSellEvent);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSellEventDlg, CDialog)
//{{AFX_MSG_MAP(CSellEventDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_BTN_PRINT, OnBtnPrint)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSellEventDlg message handlers
BOOL CSellEventDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CFont font;
font.CreatePointFont(350,_T("楷体"));
GetDlgItem(IDC_STATIC_TITLE)->SetFont(&font);
font.DeleteObject();
CString str_tmp1;
int nManagerCount = 0;
int nClassCount = 0;
//添加管理员到COMBOMANAGERNAME
m_comboManagerName.InsertString(0, "全部管理员");
m_ds->ExecuteSQL("Select * From _tSysManager");
nManagerCount = m_ds->GetRecordCount();
for(int i = 1; i <= nManagerCount; i++) //i从1计数,前面已经插入一项
{
str_tmp1 = m_ds->GetAsString("ManagerName");
m_comboManagerName.InsertString(i, str_tmp1);
m_ds->MoveNext();
}
m_comboManagerName.SetCurSel(0);
//添加分类到COMBOCLASSNAME
m_comboClassname.InsertString(0, "全部分类");
m_ds->ExecuteSQL("Select * From _tClass");
nClassCount = m_ds->GetRecordCount();
for(i = 1; i <= nClassCount; i++) //i从1计数,前面已经插入一项
{
str_tmp1 = m_ds->GetAsString("ClassName");
m_comboClassname.InsertString(i, str_tmp1);
m_ds->MoveNext();
}
m_comboClassname.SetCurSel(0);
//获取当前时间
int nRecordCount = 0;
int nCurRow = 0;
float fTodayIn = 0;
CString strClassName, strSQL, strTodayIn;
int nYear,nMonth,nDay;
CString sCurrentTime;
CTime time;
time=CTime::GetCurrentTime();
nYear=time.GetYear();
nMonth=time.GetMonth();
nDay=time.GetDay();
sCurrentTime.Format("%4d-%02d-%02d", nYear, nMonth, nDay); //保证日期格式
SetDlgItemText(IDC_STATIC_DATEFROM,sCurrentTime);
SetDlgItemText(IDC_STATIC_DATETO,sCurrentTime);
strSQL.Format("Select sum(SumMoney) as TodayIn From _tGoodsSellEvent Where SellDate = '%s'", sCurrentTime);
m_ds->ExecuteSQL(strSQL);
fTodayIn = m_ds->GetAsFloat("TodayIn");
strTodayIn.Format("%.2f 元",fTodayIn);
SetDlgItemText(IDC_STATIC_SUM, strTodayIn);
m_listSellEvent.SetBkColor(RGB(226,226,226));
m_listSellEvent.SetTextBkColor(RGB(226,226,226));
m_listSellEvent.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
this->m_listSellEvent.DeleteAllItems();
m_listSellEvent.InsertColumn(0,"销售编号",LVCFMT_LEFT,100);
m_listSellEvent.InsertColumn(1,"商品名称",LVCFMT_LEFT,150);
m_listSellEvent.InsertColumn(2,"销售单价",LVCFMT_LEFT,100);
m_listSellEvent.InsertColumn(3,"销售数量",LVCFMT_LEFT,70);
m_listSellEvent.InsertColumn(4,"小计",LVCFMT_LEFT,100);
m_listSellEvent.InsertColumn(5,"销售员",LVCFMT_LEFT,100);
m_dsClass->ExecuteSQL("Select ClassName From _tClass");
while(!m_dsClass->IsEOF())
{
strClassName = m_dsClass->GetAsString("ClassName");
m_dsClass->MoveNext();
nCurRow = m_listSellEvent.GetItemCount();
m_listSellEvent.InsertItem(nCurRow,"");
m_listSellEvent.SetItemText(nCurRow++,0,strClassName);
strSQL.Format("Select * From SellEvent Where ClassName = '%s' and SellDate = '%s'", strClassName, sCurrentTime);
m_ds->ExecuteSQL(strSQL);
nRecordCount = m_ds->GetRecordCount();
for(int i = 0; i < nRecordCount; i++)
{
m_listSellEvent.InsertItem(nCurRow, "");
m_listSellEvent.SetItemText(nCurRow, 0 , m_ds->GetAsString("GoodSellID"));
m_listSellEvent.SetItemText(nCurRow, 1 , m_ds->GetAsString("GoodName"));
m_listSellEvent.SetItemText(nCurRow, 2 , m_ds->GetAsString("Price") + "元");
m_listSellEvent.SetItemText(nCurRow, 3 , m_ds->GetAsString("Num") + "件");
m_listSellEvent.SetItemText(nCurRow, 4 , m_ds->GetAsString("SumMoney") + "元");
m_listSellEvent.SetItemText(nCurRow++, 5 , m_ds->GetAsString("ManagerName"));
m_ds->MoveNext();
}
m_listSellEvent.InsertItem(nCurRow++, "");
m_listSellEvent.InsertItem(nCurRow, "");
m_listSellEvent.SetItemText(nCurRow,0,"——————");
m_listSellEvent.SetItemText(nCurRow,1,"————————");
m_listSellEvent.SetItemText(nCurRow,2,"——————");
m_listSellEvent.SetItemText(nCurRow,3,"————");
m_listSellEvent.SetItemText(nCurRow,4,"——————");
m_listSellEvent.SetItemText(nCurRow++,5,"——————");
}
/*
m_ds->ExecuteSQL("Select * From SellEvent Where ClassName = '网络类'");
nRecordCount = m_ds->GetRecordCount();
m_listSellEvent.InsertItem(0, "");
m_listSellEvent.SetItemText(0, 0 , "网络类");
m_listSellEvent.InsertItem(1, "");
for(int i = 2; i <= nRecordCount+1; i++)
{
m_listSellEvent.InsertItem(i, "");
m_listSellEvent.SetItemText(i, 0 , m_ds->GetAsString("GoodSellID"));
m_listSellEvent.SetItemText(i, 1 , m_ds->GetAsString("GoodName"));
m_listSellEvent.SetItemText(i, 2 , m_ds->GetAsString("Price") + "元");
m_listSellEvent.SetItemText(i, 3 , m_ds->GetAsString("Num") + "件");
m_listSellEvent.SetItemText(i, 4 , m_ds->GetAsString("SumMoney") + "元");
m_listSellEvent.SetItemText(i, 5 , m_ds->GetAsString("ManagerName"));
m_ds->MoveNext();
}
*/
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSellEventDlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
/* int nYear, nMonth, nDay;
CString strCurDate;
CTime time;
time=CTime::GetCurrentTime();
nYear=time.GetYear();
nMonth=time.GetMonth();
nDay=time.GetDay();
strCurDate.Format("%4d-%02d-%02d", nYear, nMonth, nDay); //保证日期格式
CClientDC mydc(this);
dc.Rectangle(1,1,702,670);
CFont font;
font.CreatePointFont(180,_T("宋体"));
dc.SelectObject(font);
dc.TextOut(235,20,"信息中心销售日志");
dc.TextOut(550,80,strCurDate);*/
/*
mydc.MoveTo(30,30);
mydc.LineTo(700,30);
mydc.MoveTo(700,30);
mydc.LineTo(700,670);
mydc.MoveTo(30,30);
mydc.LineTo(30,670);
mydc.MoveTo(30,670);
mydc.LineTo(700,670);
*/
/*
CClientDC dc(this);
CBrush brush(HS_CROSS,RGB(200,100,200));
CBrush *pOldbrush=dc.SelectObject(&brush);
CPen pen(PS_SOLID,10,RGB(100,0,100));
CPen *pOldpen=dc.SelectObject(&pen);
dc.MoveTo(0,0);
dc.LineTo(100,100);
dc.Rectangle(0,0,300,300);
dc.RoundRect(0,0,300,300,300,300);
dc.Ellipse(300,300,600,600);
dc.SelectObject(&pOldpen);
*/
// Do not call CDialog::OnPaint() for painting messages
}
void CSellEventDlg::OnOK()
{
// TODO: Add extra validation here
CString strSQL, strTodayIn, strClassName;
float fTodayIn = 0.00;
int nRecordCount = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -