DialogFinanceOutAdd.cpp
上传用户:xiaoke98
上传日期:2014-06-29
资源大小:5718k
文件大小:4k
源码类别:
家庭/个人应用
开发平台:
Visual C++
- // DialogFinanceOutAdd.cpp : implementation file
- //
- #include "stdafx.h"
- #include "HomeFinanceManager.h"
- #include "DialogFinanceOutAdd.h"
- #include "DBOperator.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CDialogFinanceOutAdd dialog
- CDialogFinanceOutAdd::CDialogFinanceOutAdd(CWnd* pParent /*=NULL*/)
- : CDialog(CDialogFinanceOutAdd::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDialogFinanceOutAdd)
- m_dateOutRecord = 0;
- m_strRemark = _T("");
- m_strOutSum = _T("");
- m_strOutClass = _T("");
- m_strNewClass = _T("");
- //}}AFX_DATA_INIT
- }
- void CDialogFinanceOutAdd::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDialogFinanceOutAdd)
- DDX_Control(pDX, IDC_ADDRECORD, m_btnAddRecord);
- DDX_Control(pDX, IDC_ADDCLASS, m_bthAddClass);
- DDX_Control(pDX, IDC_OUTCLASSLIST, m_outClassList);
- DDX_DateTimeCtrl(pDX, IDC_OUTDATE, m_dateOutRecord);
- DDX_Text(pDX, IDC_OUTREMARK, m_strRemark);
- DDX_Text(pDX, IDC_OUTSUM, m_strOutSum);
- DDX_CBString(pDX, IDC_OUTCLASS, m_strOutClass);
- DDX_Text(pDX, IDC_NEWCLASS, m_strNewClass);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CDialogFinanceOutAdd, CDialog)
- //{{AFX_MSG_MAP(CDialogFinanceOutAdd)
- ON_BN_CLICKED(IDC_ADDRECORD, OnAddrecord)
- ON_BN_CLICKED(IDC_ADDCLASS, OnAddclass)
- //}}AFX_MSG_MAP
- ON_WM_ERASEBKGND()
- ON_WM_CTLCOLOR()
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CDialogFinanceOutAdd message handlers
- void CDialogFinanceOutAdd::OnOK( )
- {
- }
- //-----------------------------------------------------------------------------
- BOOL CDialogFinanceOutAdd::OnInitDialog( )
- {
- CDialog::OnInitDialog();
- m_dateOutRecord = CTime::GetCurrentTime();
- CSysDataStruct::CClassInfo TempClassInfo;
- gDBOperator.getMoneyOutClassInfo(TempClassInfo);
- CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_OUTCLASS);
- pComboBox->Clear();
- for(int i = 0; i < TempClassInfo.m_iClassNum; i++)
- {
- pComboBox->InsertString(-1, TempClassInfo.m_Classes[i]);
- }
- UpdateData(FALSE);
- gDBOperator.getOutClassInfo(&m_outClassList);
- return TRUE;
- }
- //-----------------------------------------------------------------------------
- BOOL CDialogFinanceOutAdd::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 CDialogFinanceOutAdd::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 CDialogFinanceOutAdd::OnAddrecord()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- CString strTime;
- strTime.Format("%d-%d-%d",
- m_dateOutRecord.GetYear(),
- m_dateOutRecord.GetMonth(),
- m_dateOutRecord.GetDay());
- int iClassID;
- iClassID = gDBOperator.getOutClassID(m_strOutClass);
- CString strClass;
- strClass.Format("%d", iClassID);
- if(iClassID < 0)
- {
- AfxMessageBox("类别出错,请重新输入");
- return;
- }
- else
- {
- gDBOperator.addFinanceOut(m_strOutSum, strClass, strTime, m_strRemark);
- }
- }
- //-----------------------------------------------------------------------------
- void CDialogFinanceOutAdd::OnAddclass()
- {
- // TODO: Add your control notification handler code here
- this->UpdateData();
- gDBOperator.addOutClass(m_strNewClass);
- CSysDataStruct::CClassInfo TempClassInfo;
- gDBOperator.getMoneyOutClassInfo(TempClassInfo);
- CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_OUTCLASS);
- pComboBox->Clear();
- for(int i = 0; i < TempClassInfo.m_iClassNum; i++)
- {
- pComboBox->InsertString(-1, TempClassInfo.m_Classes[i]);
- }
- UpdateData(FALSE);
- gDBOperator.getOutClassInfo(&m_outClassList);
- }