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

家庭/个人应用

开发平台:

Visual C++

  1. // DialogFinanceOutAdd.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "HomeFinanceManager.h"
  5. #include "DialogFinanceOutAdd.h"
  6. #include "DBOperator.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CDialogFinanceOutAdd dialog
  14. CDialogFinanceOutAdd::CDialogFinanceOutAdd(CWnd* pParent /*=NULL*/)
  15. : CDialog(CDialogFinanceOutAdd::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CDialogFinanceOutAdd)
  18. m_dateOutRecord = 0;
  19. m_strRemark = _T("");
  20. m_strOutSum = _T("");
  21. m_strOutClass = _T("");
  22. m_strNewClass = _T("");
  23. //}}AFX_DATA_INIT
  24. }
  25. void CDialogFinanceOutAdd::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CDialog::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(CDialogFinanceOutAdd)
  29. DDX_Control(pDX, IDC_ADDRECORD, m_btnAddRecord);
  30. DDX_Control(pDX, IDC_ADDCLASS, m_bthAddClass);
  31. DDX_Control(pDX, IDC_OUTCLASSLIST, m_outClassList);
  32. DDX_DateTimeCtrl(pDX, IDC_OUTDATE, m_dateOutRecord);
  33. DDX_Text(pDX, IDC_OUTREMARK, m_strRemark);
  34. DDX_Text(pDX, IDC_OUTSUM, m_strOutSum);
  35. DDX_CBString(pDX, IDC_OUTCLASS, m_strOutClass);
  36. DDX_Text(pDX, IDC_NEWCLASS, m_strNewClass);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CDialogFinanceOutAdd, CDialog)
  40. //{{AFX_MSG_MAP(CDialogFinanceOutAdd)
  41. ON_BN_CLICKED(IDC_ADDRECORD, OnAddrecord)
  42. ON_BN_CLICKED(IDC_ADDCLASS, OnAddclass)
  43. //}}AFX_MSG_MAP
  44. ON_WM_ERASEBKGND() 
  45. ON_WM_CTLCOLOR()
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDialogFinanceOutAdd message handlers
  49. void CDialogFinanceOutAdd::OnOK( )
  50. {
  51. }
  52. //-----------------------------------------------------------------------------
  53. BOOL CDialogFinanceOutAdd::OnInitDialog( )
  54. {
  55. CDialog::OnInitDialog();
  56. m_dateOutRecord = CTime::GetCurrentTime();
  57. CSysDataStruct::CClassInfo TempClassInfo;
  58. gDBOperator.getMoneyOutClassInfo(TempClassInfo);
  59. CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_OUTCLASS);
  60. pComboBox->Clear();
  61. for(int i = 0; i < TempClassInfo.m_iClassNum; i++)
  62. {
  63. pComboBox->InsertString(-1, TempClassInfo.m_Classes[i]);
  64. }
  65. UpdateData(FALSE);
  66. gDBOperator.getOutClassInfo(&m_outClassList);
  67. return TRUE;
  68. }
  69. //-----------------------------------------------------------------------------
  70. BOOL CDialogFinanceOutAdd::OnEraseBkgnd( CDC* pDC )
  71. {
  72. RECT rcClient;
  73. this->GetClientRect(&rcClient);
  74. HBRUSH hOldBrush;
  75. HBRUSH hBrush = ::CreateSolidBrush(RGB(208, 231, 240));
  76. hOldBrush = (HBRUSH)pDC->SelectObject(hBrush);
  77. pDC->Rectangle(&rcClient);
  78. pDC->SelectObject(hOldBrush);
  79. ::DeleteObject(hBrush);
  80. return TRUE;
  81. }
  82. //-----------------------------------------------------------------------------
  83. HBRUSH CDialogFinanceOutAdd::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  84. {
  85. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  86. //改变控件的颜色
  87. if(nCtlColor == CTLCOLOR_STATIC)
  88. {
  89. pDC->SetBkMode(TRANSPARENT);
  90. pDC->SetTextColor(RGB(0,0,0));
  91. LOGBRUSH  logBrush;
  92. logBrush.lbStyle = BS_HOLLOW;
  93. hbr = CreateBrushIndirect(&logBrush);
  94. }
  95. if(nCtlColor == CTLCOLOR_EDIT)
  96. {
  97. pDC->SetTextColor(RGB(255,0,0));//字体色
  98. //pDC->SetBkColor(RGB(170, 243, 162));
  99. }
  100. return hbr;
  101. }
  102. //-----------------------------------------------------------------------------
  103. void CDialogFinanceOutAdd::OnAddrecord() 
  104. {
  105. // TODO: Add your control notification handler code here
  106. UpdateData(TRUE);
  107. CString strTime;
  108. strTime.Format("%d-%d-%d", 
  109. m_dateOutRecord.GetYear(),
  110. m_dateOutRecord.GetMonth(),
  111. m_dateOutRecord.GetDay());
  112. int iClassID;
  113. iClassID = gDBOperator.getOutClassID(m_strOutClass);
  114. CString strClass;
  115. strClass.Format("%d", iClassID);
  116. if(iClassID < 0)
  117. {
  118. AfxMessageBox("类别出错,请重新输入");
  119. return;
  120. }
  121. else
  122. {
  123. gDBOperator.addFinanceOut(m_strOutSum, strClass, strTime, m_strRemark);
  124. }
  125. }
  126. //-----------------------------------------------------------------------------
  127. void CDialogFinanceOutAdd::OnAddclass() 
  128. {
  129. // TODO: Add your control notification handler code here
  130. this->UpdateData();
  131. gDBOperator.addOutClass(m_strNewClass);
  132. CSysDataStruct::CClassInfo TempClassInfo;
  133. gDBOperator.getMoneyOutClassInfo(TempClassInfo);
  134. CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_OUTCLASS);
  135. pComboBox->Clear();
  136. for(int i = 0; i < TempClassInfo.m_iClassNum; i++)
  137. {
  138. pComboBox->InsertString(-1, TempClassInfo.m_Classes[i]);
  139. }
  140. UpdateData(FALSE);
  141. gDBOperator.getOutClassInfo(&m_outClassList);
  142. }