?? savedialog.cpp
字號:
// SaveDialog.cpp : implementation file
//
#include "stdafx.h"
#include "銀行系統.h"
#include "SaveDialog.h"
#include "math.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// SaveDialog dialog
SaveDialog::SaveDialog(CWnd* pParent /*=NULL*/)
: CDialog(SaveDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(SaveDialog)
m_name = _T("");
m_address = _T("");
m_base = 0.0;
m_waiter = _T("");
m_type = -1;
m_password = 0;
m_indate = _T("");
//}}AFX_DATA_INIT
time_t temp = time(NULL);
m_indate = ctime(&temp);
}
void SaveDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SaveDialog)
DDX_Text(pDX, IDC_EDIT3, m_name);
DDX_Text(pDX, IDC_EDIT4, m_address);
DDX_Text(pDX, IDC_EDIT8, m_base);
DDX_CBString(pDX, IDC_COMBO1, m_waiter);
DDX_Radio(pDX, IDC_RADIO1, m_type);
DDX_Text(pDX, IDC_EDIT2, m_password);
DDV_MinMaxLong(pDX, m_password, 1000000, 9999999);
DDX_Text(pDX, IDC_EDIT6, m_indate);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(SaveDialog, CDialog)
//{{AFX_MSG_MAP(SaveDialog)
/* ON_EN_CHANGE(IDC_EDIT7, OnChangeEdit10)*/
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SaveDialog message handlers
void SaveDialog::OnChangeEdit10()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
}
void SaveDialog::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
//判斷數據是否合格。
if(m_address == _T(""))
{
MessageBox("地址錯誤","數據不合格");
return;
}
if(m_base<=0||m_base>9999999)
{
MessageBox("儲金錯誤","數據不合格");
return;
}
if(m_name == _T(""))
{
MessageBox("姓名錯誤","數據不合格");
return;
}
if(m_password<1000000||m_password>9999999)
{
MessageBox("密碼不合要求","數據不合格");
return;
}
if(m_type == -1)
{
MessageBox("請選擇儲種","數據不合格");
return;
}
if(m_waiter == _T(""))
{
MessageBox("請選擇營業員","數據不合格");
return;
}
int i = MyDoc->manage.DoSave(m_name,m_password,m_address,m_type,m_base, time(NULL),m_waiter);
if(i == 1||i ==2)
{
MessageBox("建立用戶失敗!!!","錯誤",MB_OK);
return;
}
//將賬號轉變為字符串
static long m_account = 1000;
char *account = new char[6];
account = ltoa(++m_account,account,10);
//將本金轉變為字符串
double base = m_base;
long z = (long)floor(base);
long s = (long)((base-z)*100);
char *cz = new char[8];
cz = ltoa(z,cz,10);
CString zz(cz);
char *cs = new char[3];
cs = ltoa(s,cs,10);
CString ss(cs);
//
int ntype = 0;
switch(m_type)
{
case 0:ntype = 1;break;
case 1:ntype = 3;break;
case 2:ntype = 5;break;
}
char *type = new char[2];
type = ltoa(ntype,type,10);
//給用于textout函數輸出的字符串賦值
MyView->saveinfo[0] = CString("帳號:") + CString(account);
MyView->saveinfo[1] = CString("姓名:")+ CString(m_name);
MyView->saveinfo[2] = CString("地址:")+ CString(m_address);
MyView->saveinfo[3] = CString("儲種:") + CString(type) + CString("年期");
MyView->saveinfo[4] = CString("本金:") + cz + CString('.') + cs + CString("元");
time_t a = time(NULL);
MyView->saveinfo[5] = CString("收儲日期:") + CString(ctime(&a));
MyView->issave = TRUE;
MyView->Invalidate();
}
void SaveDialog::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
BOOL SaveDialog::OnInitDialog()
{
CDialog::OnInitDialog();
return TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -