DialogFinanceQuery.cpp
上传用户:xiaoke98
上传日期:2014-06-29
资源大小:5718k
文件大小:6k
源码类别:
家庭/个人应用
开发平台:
Visual C++
- // DialogFinanceQuery.cpp : implementation file
- //
- #include "stdafx.h"
- #include "HomeFinanceManager.h"
- #include "DialogFinanceQuery.h"
- #include "DBOperator.h"
- #include "DialogRecord.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDialogFinanceQuery dialog
- CDialogFinanceQuery::CDialogFinanceQuery(CWnd* pParent /*=NULL*/)
- : CDialog(CDialogFinanceQuery::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDialogFinanceQuery)
- m_strTotalIn = _T("");
- m_dateEnd = 0;
- m_dateStart = 0;
- //}}AFX_DATA_INIT
- }
- void CDialogFinanceQuery::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDialogFinanceQuery)
- DDX_Control(pDX, IDC_BTN_QUERY, m_btnQuery);
- DDX_Text(pDX, IDC_TOTALIN, m_strTotalIn);
- DDX_DateTimeCtrl(pDX, IDC_DATE_END, m_dateEnd);
- DDX_DateTimeCtrl(pDX, IDC_DATE_START, m_dateStart);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDialogFinanceQuery, CDialog)
- //{{AFX_MSG_MAP(CDialogFinanceQuery)
- ON_BN_CLICKED(IDC_BTN_QUERY, OnBtnQuery)
- ON_WM_SHOWWINDOW()
- ON_NOTIFY(NM_DBLCLK, IDC_LISTCTRL_FIANCEDATE, OnClickDBgridFinanceIn)
- ON_NOTIFY(LVN_COLUMNCLICK, IDC_LISTCTRL_FIANCEDATE, OnColumnclickDBgridFinanceIn)
- //}}AFX_MSG_MAP
- ON_WM_ERASEBKGND()
- ON_WM_CTLCOLOR()
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDialogFinanceQuery message handlers
- void CDialogFinanceQuery::OnOK( )
- {
- }
- //-----------------------------------------------------------------------------
- BOOL CDialogFinanceQuery::OnInitDialog( )
- {
- CDialog::OnInitDialog();
- //显示收入dbgrid
- RECT rcClient;
- this->GetClientRect(&rcClient);
- rcClient.top += 200;
- rcClient.bottom += 90;
- m_dbgridFinanceIn.Create(LVS_REPORT, rcClient, this, IDC_LISTCTRL_FIANCEDATE);
- m_dbgridFinanceIn.ShowWindow(SW_SHOW);
- m_dateStart = CTime::GetCurrentTime();
- m_dateEnd = CTime::GetCurrentTime();
- this->UpdateData(FALSE);
- CButton* pRadio = (CButton*)GetDlgItem(IDC_ORDERBYASC);
- pRadio->SetCheck(TRUE);
- return TRUE;
- }
- //-----------------------------------------------------------------------------
- BOOL CDialogFinanceQuery::OnEraseBkgnd( CDC* pDC )
- {
- RECT rcClient;
- this->GetClientRect(&rcClient);
- HBRUSH hOldBrush;
- HBRUSH hBrush = ::CreateSolidBrush(RGB(213, 247, 209));
- hOldBrush = (HBRUSH)pDC->SelectObject(hBrush);
- pDC->Rectangle(&rcClient);
- pDC->SelectObject(hOldBrush);
- ::DeleteObject(hBrush);
- return TRUE;
- }
- //-----------------------------------------------------------------------------
- HBRUSH CDialogFinanceQuery::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- //改变控件的颜色
- if(nCtlColor == CTLCOLOR_STATIC)
- {
- pDC->SetBkMode(TRANSPARENT);
- pDC->SetTextColor(RGB(0,0,0));
- LOGBRUSH logBrush;
- logBrush.lbStyle = BS_HOLLOW;
- hbr = CreateBrushIndirect(&logBrush);
- }
- if(nCtlColor == CTLCOLOR_EDIT)
- {
- pDC->SetTextColor(RGB(255,0,0));//字体色
- //pDC->SetBkColor(RGB(170, 243, 162));
- }
- return hbr;
- }
- //-----------------------------------------------------------------------------
- void CDialogFinanceQuery::OnBtnQuery()
- {
- // TODO: Add your control notification handler code here
- CString strStart;
- CString strEnd;
- UpdateData(TRUE);
- strStart.Format("%d-%d-%d", m_dateStart.GetYear(),
- m_dateStart.GetMonth(),
- m_dateStart.GetDay());
- strEnd.Format("%d-%d-%d", m_dateEnd.GetYear(),
- m_dateEnd.GetMonth(),
- m_dateEnd.GetDay());
- CString strTotalIn;
- gDBOperator.selectFinanceIn(strStart, strEnd, m_dbgridFinanceIn, strTotalIn);
- m_strTotalIn = strTotalIn;
- UpdateData(FALSE);
- }
- //-----------------------------------------------------------------------------
- void CDialogFinanceQuery::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- CDialog::OnShowWindow(bShow, nStatus);
- // TODO: Add your message handler code here
- OnBtnQuery();
- }
- //-----------------------------------------------------------------------------
- void CDialogFinanceQuery::OnClickDBgridFinanceIn(NMHDR* pNMHDR, LRESULT* pResult)
- {
- for(int i = 0; i < m_dbgridFinanceIn.GetItemCount(); i++)
- {
- if(m_dbgridFinanceIn.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED)
- {
- char strID[50];
- char strSum[50];
- char strClass[50];
- char strDate[50];
- char strOperator[50];
- char strRemark[200];
- m_dbgridFinanceIn.GetItemText(i, 0, strID, 50);
- m_dbgridFinanceIn.GetItemText(i, 1, strSum, 50);
- m_dbgridFinanceIn.GetItemText(i, 2, strClass, 50);
- m_dbgridFinanceIn.GetItemText(i, 3, strDate, 50);
- m_dbgridFinanceIn.GetItemText(i, 4, strOperator, 50);
- m_dbgridFinanceIn.GetItemText(i, 5, strRemark, 200);
- CSysDataStruct::CClassInfo ClassInfo;
- gDBOperator.getMoneyInClassInfo(ClassInfo);
- CDialogRecord DialogRecord;
- DialogRecord.setRecordInfo(strID, strSum, strOperator, strClass, strDate, strRemark, ClassInfo);
- DialogRecord.IsMoneyIn(true);
- DialogRecord.DoModal();
- break;
- }
- }
- *pResult = 0;
- }
- //-----------------------------------------------------------------------------
- void CDialogFinanceQuery::OnColumnclickDBgridFinanceIn(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
- int iColumIndex = pNMListView->iSubItem;
- LVCOLUMN column;
- column.mask = LVCF_TEXT;
- char strTitle[256];
- column.pszText = strTitle;
- column.cchTextMax=256;
- int iResutl = m_dbgridFinanceIn.GetColumn(iColumIndex, &column);
- CString strStart;
- CString strEnd;
- UpdateData(TRUE);
- strStart.Format("%d-%d-%d", m_dateStart.GetYear(),
- m_dateStart.GetMonth(),
- m_dateStart.GetDay());
- strEnd.Format("%d-%d-%d", m_dateEnd.GetYear(),
- m_dateEnd.GetMonth(),
- m_dateEnd.GetDay());
- CButton* pRadio = (CButton*)GetDlgItem(IDC_ORDERBYASC);
- if(pRadio->GetCheck())
- {
- gDBOperator.ReOrderFinanceIn(strStart, strEnd, m_dbgridFinanceIn, m_strTotalIn,CString(strTitle), CString("asc"));
- }
- pRadio = (CButton*)GetDlgItem(IDC_ORDERBYDESC);
- if(pRadio->GetCheck())
- {
- gDBOperator.ReOrderFinanceIn(strStart, strEnd, m_dbgridFinanceIn, m_strTotalIn,CString(strTitle), CString("desc"));
- }
- UpdateData(FALSE);
- }