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

📄 interestcalc.cpp

📁 银行系统的网上用户操作模块.用户可以以网页的形式注册银行帐号,并进行转帐操作.
💻 CPP
字号:
// InterestCalc.cpp : 实现文件
//

#include "stdafx.h"
#include "BankService.h"
#include "InterestCalc.h"
#include ".\interestcalc.h"


// CInterestCalc 对话框

IMPLEMENT_DYNAMIC(CInterestCalc, CDialog)
CInterestCalc::CInterestCalc(CWnd* pParent /*=NULL*/)
	: CDialog(CInterestCalc::IDD, pParent)
{
}

CInterestCalc::~CInterestCalc()
{
}

void CInterestCalc::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_INTERETLIST, m_calclist);
}


BEGIN_MESSAGE_MAP(CInterestCalc, CDialog)
	ON_BN_CLICKED(IDC_InterestCalc, OnBnClickedInterestcalc)
END_MESSAGE_MAP()


// CInterestCalc 消息处理程序

void CInterestCalc::OnBnClickedInterestcalc()
{
	// TODO: 在此添加控件通知处理程序代码

	//更新输入变量
	UpdateData();
	
	//查询银行帐户数据表
	CString strQuery="SELECT * FROM bankbook";
	pRst.CreateInstance("ADODB.Recordset");
	pRst->Open(_bstr_t(strQuery),_variant_t((IDispatch*)pConn,true),adOpenStatic,adLockOptimistic,adCmdText);

	//查询帐户类型表
	CString strQuery2="SELECT * FROM fundtypebook";
	pRst2.CreateInstance("ADODB.Recordset");
	pRst2->Open(_bstr_t(strQuery2),_variant_t((IDispatch*)pConn,true),adOpenStatic,adLockOptimistic,adCmdText);

	
	//将计算后的帐户记录加到列表框
	while(!pRst->rsEOF)
	{
		while(!pRst2->rsEOF)
		{
			//找出帐户类型对应的存折类型的利息
			CString str1=(_bstr_t)pRst->GetCollect("fundtype");
			str1.Trim();
			CString str2=(_bstr_t)pRst2->GetCollect("type");
			str2.Trim();
			//对应吗?
			if( str1==str2 )
			{
				//读取本金
				CString original=(_bstr_t)pRst->GetCollect("amount");
				float before=atof(original);

				//计算利息天数
				CString   strCString=pRst->GetCollect("lastmodify");     
				COleVariant   vtime(strCString);   
				vtime.ChangeType(VT_DATE);   
				COleDateTime   time4=vtime;   
				SYSTEMTIME   systime;   
				VariantTimeToSystemTime(time4,   &systime);   
				CTime   t1(systime);     //CString=======>CTime
				CTime t2=CTime::GetCurrentTime();
				CTimeSpan time=t2-t1;   
				int n=time.GetDays();

				//读取利率
				CString intereststr=(_bstr_t)pRst2->GetCollect("interest");
				float interest=atof(intereststr);

				//计算本息
				float result=before+before*(1+interest)*n/365;
				CString AfterCalc;
				AfterCalc.Format("%f",result);

				//写进列表框
				CString addstr="帐号:"+(_bstr_t)pRst->GetCollect("accnum")+"  余额:"+(_bstr_t)pRst->GetCollect("amount")+"  类型:"+(_bstr_t)pRst->GetCollect("fundtype")+"  利率:"+(_bstr_t)pRst2->GetCollect("interest")+"  本+息="+AfterCalc;
				m_calclist.AddString(addstr);
			}
			pRst2->MoveNext();
		}
		pRst2->MoveFirst();
		pRst->MoveNext();
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -