⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savedialog.cpp

📁 这是一个用VC++编写的银行定期储蓄管理系统
💻 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
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -