DialogFinanceOutQuery.cpp
上传用户:xiaoke98
上传日期:2014-06-29
资源大小:5718k
文件大小:7k
源码类别:

家庭/个人应用

开发平台:

Visual C++

  1. // DialogFinanceOutQuery.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "HomeFinanceManager.h"
  5. #include "DialogFinanceOutQuery.h"
  6. #include "DBOperator.h"
  7. #include "DialogRecord.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CDialogFinanceOutQuery dialog
  15. CDialogFinanceOutQuery::CDialogFinanceOutQuery(CWnd* pParent /*=NULL*/)
  16. : CDialog(CDialogFinanceOutQuery::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CDialogFinanceOutQuery)
  19. m_strTotalIn = _T("");
  20. m_dateEnd = 0;
  21. m_dateStart = 0;
  22. //}}AFX_DATA_INIT
  23. }
  24. void CDialogFinanceOutQuery::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CDialogFinanceOutQuery)
  28. DDX_Control(pDX, IDC_BTN_QUERY, m_btnQuery);
  29. DDX_Text(pDX, IDC_TOTALIN, m_strTotalIn);
  30. DDX_DateTimeCtrl(pDX, IDC_DATE_END, m_dateEnd);
  31. DDX_DateTimeCtrl(pDX, IDC_DATE_START, m_dateStart);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CDialogFinanceOutQuery, CDialog)
  35. //{{AFX_MSG_MAP(CDialogFinanceOutQuery)
  36. ON_BN_CLICKED(IDC_BTN_QUERY, OnBtnQuery)
  37. ON_WM_SHOWWINDOW()
  38. ON_NOTIFY(NM_DBLCLK, IDC_LISTCTRL_FIANCEDATE, OnClickDBgridFinanceOut)
  39. ON_NOTIFY(LVN_COLUMNCLICK, IDC_LISTCTRL_FIANCEDATE, OnColumnclickDBgridFinanceOut)
  40. //}}AFX_MSG_MAP
  41. ON_WM_ERASEBKGND() 
  42. ON_WM_CTLCOLOR()
  43. END_MESSAGE_MAP()
  44. /////////////////////////////////////////////////////////////////////////////
  45. // CDialogFinanceOutQuery message handlers
  46. void CDialogFinanceOutQuery::OnOK( )
  47. {
  48. }
  49. //-----------------------------------------------------------------------------
  50. void CDialogFinanceOutQuery::OnShowWindow(BOOL bShow, UINT nStatus) 
  51. {
  52. CDialog::OnShowWindow(bShow, nStatus);
  53. // TODO: Add your message handler code here
  54. OnBtnQuery();
  55. }
  56. //-----------------------------------------------------------------------------
  57. BOOL CDialogFinanceOutQuery::OnInitDialog( )
  58. {
  59. CDialog::OnInitDialog();
  60. //显示收入dbgrid
  61. RECT rcClient;
  62. this->GetClientRect(&rcClient);
  63. rcClient.top += 200;
  64. rcClient.bottom += 90;
  65. m_dbgridFinanceOut.Create(LVS_REPORT, rcClient, this, IDC_LISTCTRL_FIANCEDATE);
  66. m_dbgridFinanceOut.ShowWindow(SW_SHOW);
  67. m_dateStart = CTime::GetCurrentTime();
  68. m_dateEnd = CTime::GetCurrentTime();
  69. UpdateData(FALSE);
  70. CButton* pRadio = (CButton*)GetDlgItem(IDC_ORDERBYASC);
  71. pRadio->SetCheck(TRUE);
  72. return TRUE;
  73. }
  74. //-----------------------------------------------------------------------------
  75. BOOL CDialogFinanceOutQuery::OnEraseBkgnd( CDC* pDC )
  76. {
  77. RECT rcClient;
  78. this->GetClientRect(&rcClient);
  79. HBRUSH hOldBrush;
  80. HBRUSH hBrush = ::CreateSolidBrush(RGB(208, 231, 240));
  81. hOldBrush = (HBRUSH)pDC->SelectObject(hBrush);
  82. pDC->Rectangle(&rcClient);
  83. pDC->SelectObject(hOldBrush);
  84. ::DeleteObject(hBrush);
  85. return TRUE;
  86. }
  87. //-----------------------------------------------------------------------------
  88. HBRUSH CDialogFinanceOutQuery::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  89. {
  90. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  91. //改变控件的颜色
  92. if(nCtlColor == CTLCOLOR_STATIC)
  93. {
  94. pDC->SetBkMode(TRANSPARENT);
  95. pDC->SetTextColor(RGB(0,0,0));
  96. LOGBRUSH  logBrush;
  97. logBrush.lbStyle = BS_HOLLOW;
  98. hbr = CreateBrushIndirect(&logBrush);
  99. }
  100. if(nCtlColor == CTLCOLOR_EDIT)
  101. {
  102. pDC->SetTextColor(RGB(255,0,0));//字体色
  103. //pDC->SetBkColor(RGB(170, 243, 162));
  104. }
  105. return hbr;
  106. }
  107. //-----------------------------------------------------------------------------
  108. void CDialogFinanceOutQuery::OnBtnQuery() 
  109. {
  110. // TODO: Add your control notification handler code here
  111. CString strStart;
  112. CString strEnd;
  113. UpdateData(TRUE);
  114. strStart.Format("%d-%d-%d", m_dateStart.GetYear(),
  115. m_dateStart.GetMonth(),
  116. m_dateStart.GetDay());
  117. strEnd.Format("%d-%d-%d",   m_dateEnd.GetYear(),
  118. m_dateEnd.GetMonth(),
  119. m_dateEnd.GetDay());
  120. //CButton* pBtnDateRadio = (CButton*)GetDlgItem(IDC_ORDERBYDATE);
  121. //if(pBtnDateRadio->GetCheck())
  122. {
  123. gDBOperator.selectFinanceOut(strStart, strEnd, m_dbgridFinanceOut, m_strTotalIn, enDate);
  124. }
  125. UpdateData(FALSE);
  126. }
  127. //-----------------------------------------------------------------------------
  128. //响应单击dbGrid事件
  129. void CDialogFinanceOutQuery::OnClickDBgridFinanceOut(NMHDR* pNMHDR, LRESULT* pResult)
  130. {
  131. // CDialogRecord DialogRecord;
  132. char strID[50];
  133. char strSum[50];
  134. char strClass[50];
  135. char strDate[50];
  136. char strOperator[50];
  137. char strRemark[200];
  138. CSysDataStruct::CClassInfo ClassInfo;
  139. for(int i = 0; i < m_dbgridFinanceOut.GetItemCount(); i++)
  140. {
  141. if(m_dbgridFinanceOut.GetItemState(i, LVIS_SELECTED) == LVIS_SELECTED)
  142. {
  143. m_dbgridFinanceOut.GetItemText(i, 0, strID, 50);
  144. m_dbgridFinanceOut.GetItemText(i, 1, strSum, 50);
  145. m_dbgridFinanceOut.GetItemText(i, 2, strClass, 50);
  146. m_dbgridFinanceOut.GetItemText(i, 4, strDate, 50);
  147. m_dbgridFinanceOut.GetItemText(i, 5, strOperator, 50);
  148. m_dbgridFinanceOut.GetItemText(i, 3, strRemark, 200);
  149. gDBOperator.getMoneyOutClassInfo(ClassInfo);
  150. CDialogRecord  DialogRecord;
  151. DialogRecord.setRecordInfo(strID, strSum, strOperator, strClass, strDate, strRemark, ClassInfo);
  152. DialogRecord.DoModal();
  153. }
  154. }
  155. *pResult = 0;
  156. }
  157. //-----------------------------------------------------------------------------
  158. //响应单击dbGrid事件
  159. void CDialogFinanceOutQuery::OnColumnclickDBgridFinanceOut(NMHDR* pNMHDR, LRESULT* pResult)
  160. {
  161. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  162. // TODO: Add your control notification handler code here
  163. int iColumIndex = pNMListView->iSubItem;
  164. LVCOLUMN column;
  165. column.mask = LVCF_TEXT;
  166. char strTitle[256];
  167. column.pszText = strTitle;
  168. column.cchTextMax=256;
  169. int iResutl = m_dbgridFinanceOut.GetColumn(iColumIndex, &column);
  170. CString strStart;
  171. CString strEnd;
  172. UpdateData(TRUE);
  173. strStart.Format("%d-%d-%d", m_dateStart.GetYear(),
  174. m_dateStart.GetMonth(),
  175. m_dateStart.GetDay());
  176. strEnd.Format("%d-%d-%d",   m_dateEnd.GetYear(),
  177. m_dateEnd.GetMonth(),
  178. m_dateEnd.GetDay());
  179. CButton* pRadio = (CButton*)GetDlgItem(IDC_ORDERBYASC);
  180. if(pRadio->GetCheck())
  181. {
  182. gDBOperator.ReOrderFinanceOut(strStart, strEnd, m_dbgridFinanceOut, m_strTotalIn,CString(strTitle), CString("asc"));
  183. }
  184. pRadio = (CButton*)GetDlgItem(IDC_ORDERBYDESC);
  185. if(pRadio->GetCheck())
  186. {
  187. gDBOperator.ReOrderFinanceOut(strStart, strEnd, m_dbgridFinanceOut, m_strTotalIn,CString(strTitle), CString("desc"));
  188. }
  189. UpdateData(FALSE);
  190. *pResult = 0;
  191. }