📄 addmoney.cpp
字号:
// AddMoney.cpp : implementation file
//
#include "stdafx.h"
#include "stocksystem.h"
#include "AddMoney.h"
#include "AccountTreeView.h"
#include "PersonFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAddMoney dialog
CAddMoney::CAddMoney(CWnd* pParent /*=NULL*/)
: CDialog(CAddMoney::IDD, pParent)
{
//{{AFX_DATA_INIT(CAddMoney)
m_add_money = 0.0;
m_now_money = 0.0;
//}}AFX_DATA_INIT
}
void CAddMoney::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAddMoney)
DDX_Control(pDX, IDC_DATETIMEPICKER, m_time);
DDX_Text(pDX, IDC_ADD_MONEY, m_add_money);
DDX_Text(pDX, IDC_NOW_MONEY, m_now_money);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAddMoney, CDialog)
//{{AFX_MSG_MAP(CAddMoney)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAddMoney message handlers
void CAddMoney::OnOK()
{
// TODO: Add extra validation here
UpdateData();
CString currentuser;
double money;
CStockSystemApp *pApp = (CStockSystemApp *)AfxGetApp();
CPersonFrame *pframe = (CPersonFrame *)GetParent();
CAccountTreeView *mytree =(CAccountTreeView *)(pframe->m_splitterwnd.GetPane(0,0));
mytree->GetCurrentUser(currentuser);
money = m_now_money + m_add_money;
if (pApp->m_pConnection.AmendAccountMoney(currentuser, money))
{
MessageBox("资金追加成功","提示");
//改变当前的结构体中账户的金额
int len = pApp->UserInfoVect.size();
for (int i=0; i<len; i++)
{
if (pApp->UserInfoVect[i].username == currentuser)
{
pApp->UserInfoVect[i].balance = money;
}
}
m_add_money = 0;
UpdateData(FALSE);
CDialog::OnOK();
}
else
{
MessageBox("资金追加失败","提示");
m_add_money = 0;
UpdateData(FALSE);
return;
}
}
void CAddMoney::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL CAddMoney::OnInitDialog()
{
CDialog::OnInitDialog();
CString title;
CString currentuser;
//获取当前账户名称
CPersonFrame *pframe = (CPersonFrame *)GetParent();
CAccountTreeView *mytree =(CAccountTreeView *)(pframe->m_splitterwnd.GetPane(0,0));
mytree->GetCurrentUser(currentuser);
title.Format("追加资金 - [%s]", currentuser);
SetWindowText(title);
//时间显示为当前日期
m_time.EnableWindow(FALSE);
//显示出账户的余额
CStockSystemApp *pApp = (CStockSystemApp *)AfxGetApp();
int len = pApp->UserInfoVect.size();
for (int i=0; i<len; i++)
{
if (pApp->UserInfoVect[i].username == currentuser)
{
m_now_money = pApp->UserInfoVect[i].balance;
}
}
UpdateData(FALSE);
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -