DialogFinanceOutQuery.cpp
上传用户:xiaoke98
上传日期:2014-06-29
资源大小:5718k
文件大小:7k
源码类别:
家庭/个人应用
开发平台:
Visual C++
- // DialogFinanceOutQuery.cpp : implementation file
- //
- #include "stdafx.h"
- #include "HomeFinanceManager.h"
- #include "DialogFinanceOutQuery.h"
- #include "DBOperator.h"
- #include "DialogRecord.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDialogFinanceOutQuery dialog
- CDialogFinanceOutQuery::CDialogFinanceOutQuery(CWnd* pParent /*=NULL*/)
- : CDialog(CDialogFinanceOutQuery::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDialogFinanceOutQuery)
- m_strTotalIn = _T("");
- m_dateEnd = 0;
- m_dateStart = 0;
- //}}AFX_DATA_INIT
- }
- void CDialogFinanceOutQuery::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDialogFinanceOutQuery)
- 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(CDialogFinanceOutQuery, CDialog)
- //{{AFX_MSG_MAP(CDialogFinanceOutQuery)
- ON_BN_CLICKED(IDC_BTN_QUERY, OnBtnQuery)
- ON_WM_SHOWWINDOW()
- ON_NOTIFY(NM_DBLCLK, IDC_LISTCTRL_FIANCEDATE, OnClickDBgridFinanceOut)
- ON_NOTIFY(LVN_COLUMNCLICK, IDC_LISTCTRL_FIANCEDATE, OnColumnclickDBgridFinanceOut)
- //}}AFX_MSG_MAP
- ON_WM_ERASEBKGND()
- ON_WM_CTLCOLOR()
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDialogFinanceOutQuery message handlers
- void CDialogFinanceOutQuery::OnOK( )
- {
- }
- //-----------------------------------------------------------------------------
- void CDialogFinanceOutQuery::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- CDialog::OnShowWindow(bShow, nStatus);
- // TODO: Add your message handler code here
- OnBtnQuery();
- }
- //-----------------------------------------------------------------------------
- BOOL CDialogFinanceOutQuery::OnInitDialog( )
- {
- CDialog::OnInitDialog();
- //显示收入dbgrid
- RECT rcClient;
- this->GetClientRect(&rcClient);
- rcClient.top += 200;
- rcClient.bottom += 90;
- m_dbgridFinanceOut.Create(LVS_REPORT, rcClient, this, IDC_LISTCTRL_FIANCEDATE);
- m_dbgridFinanceOut.ShowWindow(SW_SHOW);
- m_dateStart = CTime::GetCurrentTime();
- m_dateEnd = CTime::GetCurrentTime();
- UpdateData(FALSE);
- CButton* pRadio = (CButton*)GetDlgItem(IDC_ORDERBYASC);
- pRadio->SetCheck(TRUE);
- return TRUE;
- }
- //-----------------------------------------------------------------------------
- BOOL CDialogFinanceOutQuery::OnEraseBkgnd( CDC* pDC )
- {
- RECT rcClient;
- this->GetClientRect(&rcClient);
- HBRUSH hOldBrush;
- HBRUSH hBrush = ::CreateSolidBrush(RGB(208, 231, 240));
- hOldBrush = (HBRUSH)pDC->SelectObject(hBrush);
- pDC->Rectangle(&rcClient);
- pDC->SelectObject(hOldBrush);
- ::DeleteObject(hBrush);
- return TRUE;
- }
- //-----------------------------------------------------------------------------
- HBRUSH CDialogFinanceOutQuery::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 CDialogFinanceOutQuery::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());
- //CButton* pBtnDateRadio = (CButton*)GetDlgItem(IDC_ORDERBYDATE);
- //if(pBtnDateRadio->GetCheck())
- {
- gDBOperator.selectFinanceOut(strStart, strEnd, m_dbgridFinanceOut, m_strTotalIn, enDate);
- }
- UpdateData(FALSE);
- }
- //-----------------------------------------------------------------------------
- //响应单击dbGrid事件
- void CDialogFinanceOutQuery::OnClickDBgridFinanceOut(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // CDialogRecord DialogRecord;
- char strID[50];
- char strSum[50];
- char strClass[50];
- char strDate[50];
- char strOperator[50];
- char strRemark[200];
- CSysDataStruct::CClassInfo ClassInfo;
- for(int i = 0; i < m_dbgridFinanceOut.GetItemCount(); i++)
- {
- if(m_dbgridFinanceOut.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED)
- {
- m_dbgridFinanceOut.GetItemText(i, 0, strID, 50);
- m_dbgridFinanceOut.GetItemText(i, 1, strSum, 50);
- m_dbgridFinanceOut.GetItemText(i, 2, strClass, 50);
- m_dbgridFinanceOut.GetItemText(i, 4, strDate, 50);
- m_dbgridFinanceOut.GetItemText(i, 5, strOperator, 50);
- m_dbgridFinanceOut.GetItemText(i, 3, strRemark, 200);
- gDBOperator.getMoneyOutClassInfo(ClassInfo);
- CDialogRecord DialogRecord;
- DialogRecord.setRecordInfo(strID, strSum, strOperator, strClass, strDate, strRemark, ClassInfo);
- DialogRecord.DoModal();
- }
- }
- *pResult = 0;
- }
- //-----------------------------------------------------------------------------
- //响应单击dbGrid事件
- void CDialogFinanceOutQuery::OnColumnclickDBgridFinanceOut(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_dbgridFinanceOut.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.ReOrderFinanceOut(strStart, strEnd, m_dbgridFinanceOut, m_strTotalIn,CString(strTitle), CString("asc"));
- }
- pRadio = (CButton*)GetDlgItem(IDC_ORDERBYDESC);
- if(pRadio->GetCheck())
- {
- gDBOperator.ReOrderFinanceOut(strStart, strEnd, m_dbgridFinanceOut, m_strTotalIn,CString(strTitle), CString("desc"));
- }
- UpdateData(FALSE);
- *pResult = 0;
- }