📄 financemaindlg.cpp
字号:
Length=strAllInvest.GetLength ();
strAllInvest.Delete (Length-4,4);
FinanceInfo+=L"至目前为止,您总共有投资总额达:";
FinanceInfo+=strAllInvest;
FinanceInfo+=L"元\n";
}
//最后可以显示了
SetDlgItemText(IDC_FINANCE_INFO_STATIC,FinanceInfo);
EndWaitCursor();
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void CFinanceMainDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
//先添加现金
CString FinanceInfo;
double dCashAmount=0;
CString StrCashAmount=L"";
int Length;
if(m_pCashSet.IsOpen ())
m_pCashSet.Close ();
m_pCashSet.Open (AFX_DB_USE_DEFAULT_TYPE,L"Select * From Cash Order by cDate");//按结算日期排序
if(m_pCashSet.GetRecordCount ()!=0)//还没有现金的信息,则不用理,否则进入
{
m_pCashSet.MoveLast ();//现金是用最后的状态的,故最后一个
dCashAmount=m_pCashSet.m_cAmount ;
StrCashAmount.Format (L"%f",dCashAmount);
Length=StrCashAmount.GetLength ();
StrCashAmount.Delete (Length-4,4);
}
m_pCashSet.Close ();
SetDlgItemText(IDC_CASHNOW_STATIC,StrCashAmount);
//再添加借贷信息
CString StrBorrowInfo=L"";
CString StartDate;
CString EndDate;
CString StrAmount;
CString StrMoneyLeft;
CTime tTime=CTime::GetCurrentTime();
CString Date=DateToString(tTime);
if(m_pBorrowSet.IsOpen ())
m_pBorrowSet.Close ();
m_pBorrowSet.Open (AFX_DB_USE_DEFAULT_TYPE,L"Select * From Borrow Order by bDate");
if(m_pBorrowSet.GetRecordCount ()==0)//还没有借贷的信息,则显示一些名言
{
m_pBorrowSet.Close ();
StrBorrowInfo=L"节俭持家,脑筋理财。";
SetDlgItemText(IDC_BORROW_REMIND_STATIC,StrBorrowInfo);
}
else//否则,监测借贷信息
{
m_pBorrowSet.MoveFirst ();
m_pBorrowSet.m_strFilter .Empty ();
while(!m_pBorrowSet.IsEOF ())
{
StartDate=DateToString(m_pBorrowSet.m_bStartDate );
EndDate=DateToString(m_pBorrowSet.m_bEndDate );
if(StartDate<=Date&&EndDate>=Date)//如果借贷期间跨越了当天,则显示
{
StrAmount.Format(L"%f",m_pBorrowSet.m_bAmount);
Length=StrAmount.GetLength ();
StrAmount.Delete (Length-4,4);
StrMoneyLeft.Format (L"%f",m_pBorrowSet.m_bMoneyLeft );
Length=StrMoneyLeft.GetLength ();
StrMoneyLeft.Delete (Length-4,4);
//还要判断是借入,借出,还欠,还回等操作
if((CString)m_pBorrowSet.m_bAction==L"借入")
{
//借入,则必须提醒
StrBorrowInfo+=L"你于"+FormatDate(m_pBorrowSet.m_bDate) +L"从"
+m_pBorrowSet.m_bOtherName +L"处借入"+StrAmount+L"元,有效期从"
+FormatDate(m_pBorrowSet.m_bStartDate) +L"到"+FormatDate(m_pBorrowSet.m_bEndDate) +L"\n";
}else
if((CString)m_pBorrowSet.m_bAction==L"借出")
{
//借出,则必须提醒
StrBorrowInfo+=m_pBorrowSet.m_bOtherName +L"于"
+FormatDate(m_pBorrowSet.m_bDate) +L"从你手中借出"+StrAmount+L"元,有效期从"
+FormatDate(m_pBorrowSet.m_bStartDate) +L"到"+FormatDate(m_pBorrowSet.m_bEndDate) +L"\n";
}else
if((CString)m_pBorrowSet.m_bAction==L"还出")
{ //还出,只有在有余额的时候要提醒
if(m_pBorrowSet.m_bMoneyLeft !=0)
StrBorrowInfo+=L"你于"+FormatDate(m_pBorrowSet.m_bDate) +L"还出"
+StrAmount +L"元给"+m_pBorrowSet.m_bOtherName
+L"仍欠"+StrMoneyLeft +L"元\n";
}else
{ //还入,只有在还有余额的时候提醒
if(m_pBorrowSet.m_bMoneyLeft !=0)
StrBorrowInfo+=m_pBorrowSet.m_bOtherName +L"于"+FormatDate(m_pBorrowSet.m_bDate)
+L"还入"+StrAmount +L"元,仍欠"+StrMoneyLeft +L"元\n";
}
}//if
m_pBorrowSet.MoveNext ();
}//while
}//else
m_pBorrowSet.Close ();
SetDlgItemText(IDC_BORROW_REMIND_STATIC,StrBorrowInfo);
//借贷信息添加完毕
//下面是财务报表的信息添加
//先收入部分
double nAllIncome=0;
CString strAllIncome;
if(m_pIncomeSet.IsOpen ())
m_pIncomeSet.Close ();
m_pIncomeSet.Open (AFX_DB_USE_DEFAULT_TYPE,L"Select * From Income");
if(m_pIncomeSet.GetRecordCount ()==0)
{
m_pIncomeSet.Close();
}
else
{
m_pIncomeSet.MoveFirst ();
while(!m_pIncomeSet.IsEOF ())
{
nAllIncome+=m_pIncomeSet.m_iAmount ;
m_pIncomeSet.MoveNext ();
}
m_pIncomeSet.Close ();
strAllIncome.Format (L"%f",nAllIncome);
Length=strAllIncome.GetLength ();
strAllIncome.Delete (Length-4,4);
FinanceInfo+=L"至目前为止,您有总收入:";
FinanceInfo+=strAllIncome;
FinanceInfo+=L"元\n";
}
//再支出部分
double nAllOutcome=0;
CString strAllOutcome;
if(m_pOutcomeSet.IsOpen ())
m_pOutcomeSet.Close ();
m_pOutcomeSet.Open (AFX_DB_USE_DEFAULT_TYPE,L"Select * From Outcome");
if(m_pOutcomeSet.GetRecordCount ()==0)
{
m_pOutcomeSet.Close();
}
else
{
m_pOutcomeSet.MoveFirst ();
while(!m_pOutcomeSet.IsEOF ())
{
nAllOutcome+=m_pOutcomeSet.m_oAmount ;
m_pOutcomeSet.MoveNext ();
}
m_pOutcomeSet.Close ();
strAllOutcome.Format (L"%f",nAllOutcome);
Length=strAllOutcome.GetLength ();
strAllOutcome.Delete (Length-4,4);
FinanceInfo+=L"至目前为止,您有总支出:";
FinanceInfo+=strAllOutcome;
FinanceInfo+=L"元\n";
}
//再列出银行卡里钱的总额
CString sCardId=L"";
double nAllBank=0;
CString strAllBank;
if(m_pBankSet.IsOpen ())
m_pBankSet.Close ();
m_pBankSet.Open (AFX_DB_USE_DEFAULT_TYPE,L"Select * From Bank Order by bODate DESC,bCardId");
if(m_pBankSet.GetRecordCount ()==0)
{
m_pBankSet.Close();
}
else
{
m_pBankSet.MoveFirst ();
while(!m_pBankSet.IsEOF ())
{
if(sCardId==(CString)m_pBankSet.m_bCardId )
{
m_pBankSet.MoveNext ();//若相等,则说明还是那个,则跳过
continue;
}
sCardId=m_pBankSet.m_bCardId ;//转换
nAllBank+=m_pBankSet.m_bLeft ;
m_pBankSet.MoveNext ();
}
m_pBankSet.Close ();
strAllBank.Format (L"%f",nAllBank);
Length=strAllBank.GetLength ();
strAllBank.Delete (Length-4,4);
FinanceInfo+=L"至目前为止,您银行卡上共有金额:";
FinanceInfo+=strAllBank;
FinanceInfo+=L"元\n";
}
//再列出所有物品财产的总额
double nAllTangible=0;
CString strAllTangible;
if(m_pTangibleSet.IsOpen ())
m_pTangibleSet.Close ();
m_pTangibleSet.Open (AFX_DB_USE_DEFAULT_TYPE,L"Select * From Tangible");
if(m_pTangibleSet.GetRecordCount ()==0)
{
m_pTangibleSet.Close();
}
else
{
m_pTangibleSet.MoveFirst ();
while(!m_pTangibleSet.IsEOF ())
{
nAllTangible+=m_pTangibleSet.m_tSum ;
m_pTangibleSet.MoveNext ();
}
m_pTangibleSet.Close ();
strAllTangible.Format (L"%f",nAllTangible);
Length=strAllTangible.GetLength ();
strAllTangible.Delete (Length-4,4);
FinanceInfo+=L"至目前为止,您有物品资产总值:";
FinanceInfo+=strAllTangible;
FinanceInfo+=L"元\n";
}
//下面再列出投资总额
double nAllInvest=0;
CString strAllInvest;
if(m_pInvestSet.IsOpen ())
m_pInvestSet.Close ();
m_pInvestSet.Open (AFX_DB_USE_DEFAULT_TYPE,L"Select * From Invest");
if(m_pInvestSet.GetRecordCount ()==0)
{
m_pInvestSet.Close();
}
else
{
m_pInvestSet.MoveFirst ();
while(!m_pInvestSet.IsEOF ())
{
nAllInvest+=m_pInvestSet.m_iSum ;
m_pInvestSet.MoveNext ();
}
m_pInvestSet.Close ();
strAllInvest.Format (L"%f",nAllInvest);
Length=strAllInvest.GetLength ();
strAllInvest.Delete (Length-4,4);
FinanceInfo+=L"至目前为止,您总共有投资总额达:";
FinanceInfo+=strAllInvest;
FinanceInfo+=L"元\n";
}
//最后可以显示了
SetDlgItemText(IDC_FINANCE_INFO_STATIC,FinanceInfo);
CDialog::OnTimer(nIDEvent);
}
void CFinanceMainDlg::OnClose()
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
KillTimer(FINANCE_TIMER);
CDialog::OnClose();
}
void CFinanceMainDlg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: 在此处添加消息处理程序代码
}
void CFinanceMainDlg::OnCancel()
{
// TODO: 在此添加专用代码和/或调用基类
DestroyWindow ();
}
void CFinanceMainDlg::PostNcDestroy()
{
// TODO: 在此添加专用代码和/或调用基类
CDialog::PostNcDestroy();
AfxGetMainWnd()->SendMessage(WM_USER_FINANCEMAINDLG_DESTROYED,0,0);
delete this;
}
HBRUSH CFinanceMainDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: 在此更改 DC 的任何属性
if(m_bColor)//如果用系统的,则直接返回
return hbr;
pDC->SetTextColor (m_RGB_CtrlColor);
pDC->SetBkMode(BKMODE_LAST);pDC->SetBkColor (m_RGB_BkColor);
return (HBRUSH)m_brush.GetSafeHandle ();
// TODO: 如果默认的不是所需画笔,则返回另一个画笔
// return hbr;
}
void CFinanceMainDlg::OnFinanceMainIncomeWizard()
{
// TODO: 在此添加命令处理程序代码
CIncomeWizardDlg dlg;
dlg.DoModal ();
}
void CFinanceMainDlg::OnFinanceMainOutcomeWizard()
{
// TODO: 在此添加命令处理程序代码
COutcomeWizardDlg1 dlg;
dlg.DoModal ();
}
void CFinanceMainDlg::OnFinancemainToFinance()
{
// TODO: 在此添加命令处理程序代码
CFinanceDlg dlg;
dlg.DoModal ();
}
void CFinanceMainDlg::OnFinanceMainClose()
{
// TODO: 在此添加命令处理程序代码
CDialog::OnClose ();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -