📄 accountmgrdlg.cpp
字号:
// AccountMgrDlg.cpp : implementation file
//
#include "stdafx.h"
#include "gasstation.h"
#include "AccountMgrDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAccountMgrDlg dialog
CAccountMgrDlg::CAccountMgrDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAccountMgrDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAccountMgrDlg)
m_strDayEnd = _T("");
m_strDayStart = _T("");
m_strMonthEnd = _T("");
m_strMonthStart = _T("");
m_strYearEnd = _T("");
m_strYearStart = _T("");
//}}AFX_DATA_INIT
}
void CAccountMgrDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAccountMgrDlg)
DDX_Control(pDX, IDC_LIST_STOCK, m_listStock);
DDX_Control(pDX, IDC_LIST_SELL, m_listSell);
DDX_CBString(pDX, IDC_COMBO_DAY_END, m_strDayEnd);
DDX_CBString(pDX, IDC_COMBO_DAY_START, m_strDayStart);
DDX_CBString(pDX, IDC_COMBO_MONTH_END, m_strMonthEnd);
DDX_CBString(pDX, IDC_COMBO_MONTH_START, m_strMonthStart);
DDX_CBString(pDX, IDC_COMBO_YEAR_END, m_strYearEnd);
DDX_CBString(pDX, IDC_COMBO_YEAR_START, m_strYearStart);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAccountMgrDlg, CDialog)
//{{AFX_MSG_MAP(CAccountMgrDlg)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BUTTON_QUERY, OnButtonQuery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAccountMgrDlg message handlers
BOOL CAccountMgrDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CComboBox *pComboBoxStart, *pComboBoxEnd;
pComboBoxStart = (CComboBox *)GetDlgItem(IDC_COMBO_YEAR_START);
pComboBoxEnd = (CComboBox *)GetDlgItem(IDC_COMBO_YEAR_END);
for (int i=2010;i>1980;i --) {
CString strYear;
strYear.Format("%d", i);
pComboBoxStart->AddString(strYear);
pComboBoxEnd->AddString(strYear);
}
pComboBoxStart = (CComboBox *)GetDlgItem(IDC_COMBO_MONTH_START);
pComboBoxEnd = (CComboBox *)GetDlgItem(IDC_COMBO_MONTH_END);
for (i=1;i<=12;i ++) {
CString strMonth;
strMonth.Format("%d", i);
pComboBoxStart->AddString(strMonth);
pComboBoxEnd->AddString(strMonth);
}
pComboBoxStart = (CComboBox *)GetDlgItem(IDC_COMBO_DAY_START);
pComboBoxEnd = (CComboBox *)GetDlgItem(IDC_COMBO_DAY_END);
for (i=1;i<=31;i ++) {
CString strDay;
strDay.Format("%d", i);
pComboBoxStart->AddString(strDay);
pComboBoxEnd->AddString(strDay);
}
//设置列表框控件
const char *stock_list_column[] =
{
"时间",
"油品",
"油库",
"总量",
"进货价格",
"进货员",
""
};
i=0;
while (*stock_list_column[i] != 0x00) {
int nWidth = (i==0)?120:50;
m_listStock.InsertColumn(i, stock_list_column[i++], LVCFMT_LEFT, nWidth);
}
m_listStock.SetExtendedStyle(LVS_EX_FULLROWSELECT);
//设置列表框控件
const char *sell_list_column[] =
{
"时间",
"油品",
"油库",
"总量",
"销售价格",
"销售员",
"客户",
"折扣",
""
};
i=0;
while (*sell_list_column[i] != 0x00) {
int nWidth = (i==0)?120:50;
m_listSell.InsertColumn(i, sell_list_column[i++], LVCFMT_LEFT, nWidth);
}
m_listSell.SetExtendedStyle(LVS_EX_FULLROWSELECT);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAccountMgrDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
CTime curTime = CTime::GetCurrentTime();
m_strYearStart.Format("%d", curTime.GetYear());
m_strMonthStart.Format("%d", 1);
m_strDayStart.Format("%d", 1);
m_strYearEnd.Format("%d", curTime.GetYear());
m_strMonthEnd.Format("%d", curTime.GetMonth());
m_strDayEnd.Format("%d", curTime.GetDay());
UpdateData(FALSE);
RefreshList();
}
void CAccountMgrDlg::RefreshList()
{
m_listStock.DeleteAllItems();
m_listSell.DeleteAllItems();
UpdateTime();
{
CStringArray strTime, strGasType, strDepot, strAmount, strPrice, strWorker;
int nCount;
nCount = ADOSQLServer.GetStockRecordsEx(strTime, strGasType, strDepot, strAmount, strPrice, strWorker, m_strTimeStart, m_strTimeEnd);
if (nCount > 0) {
for (int i=0;i<strTime.GetSize();i ++) {
int nItem = m_listStock.GetItemCount();
m_listStock.InsertItem(nItem, strTime.GetAt(i));
m_listStock.SetItemText(nItem, 1, strGasType.GetAt(i));
m_listStock.SetItemText(nItem, 2, strDepot.GetAt(i));
m_listStock.SetItemText(nItem, 3, strAmount.GetAt(i));
m_listStock.SetItemText(nItem, 4, strPrice.GetAt(i));
m_listStock.SetItemText(nItem, 5, strWorker.GetAt(i));
}
}
}
{
CStringArray strTime, strGasType, strDepot, strAmount, strPrice, strWorker, strClient, strAgio;
int nCount;
nCount = ADOSQLServer.GetSellRecordsEx(strTime, strGasType, strDepot, strAmount, strPrice, strWorker, strClient, strAgio, m_strTimeStart, m_strTimeEnd);
if (nCount > 0) {
for (int i=0;i<strTime.GetSize();i ++) {
int nItem = m_listSell.GetItemCount();
m_listSell.InsertItem(nItem, strTime.GetAt(i));
m_listSell.SetItemText(nItem, 1, strGasType.GetAt(i));
m_listSell.SetItemText(nItem, 2, strDepot.GetAt(i));
m_listSell.SetItemText(nItem, 3, strAmount.GetAt(i));
m_listSell.SetItemText(nItem, 4, strPrice.GetAt(i));
m_listSell.SetItemText(nItem, 5, strWorker.GetAt(i));
m_listSell.SetItemText(nItem, 6, strClient.GetAt(i));
m_listSell.SetItemText(nItem, 7, strAgio.GetAt(i));
}
}
}
}
void CAccountMgrDlg::UpdateTime()
{
UpdateData();
m_strTimeStart.Format(
"%s-%s-%s 00:00:00.000",
m_strYearStart,
m_strMonthStart,
m_strDayStart );
m_strTimeEnd.Format(
"%s-%s-%s 23:59:59.999",
m_strYearEnd,
m_strMonthEnd,
m_strDayEnd );
}
void CAccountMgrDlg::OnButtonQuery()
{
// TODO: Add your control notification handler code here
RefreshList();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -