📄 banksystemdlg.cpp
字号:
// BankSystemDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BankSystem.h"
#include "BankSystemDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBankSystemDlg dialog
CBankSystemDlg::CBankSystemDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBankSystemDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBankSystemDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CBankSystemDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBankSystemDlg)
DDX_Control(pDX, IDC_STATIC_BANK, m_childDlg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBankSystemDlg, CDialog)
//{{AFX_MSG_MAP(CBankSystemDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_1_CREATE, OnCreate)
ON_COMMAND(ID_1_GUASHI, OnGuashi)
ON_COMMAND(ID_1_JIEGUA, OnJiegua)
ON_COMMAND(ID_1_CHANGEPW, OnChangepw)
ON_COMMAND(ID_2_DEPOSIT, OnDeposit)
ON_COMMAND(ID_2_SEARCH, OnSearch)
ON_COMMAND(ID_2_TRANSFER, OnTransfer)
ON_COMMAND(ID_2_WITHDRAW, OnWithdraw)
ON_COMMAND(ID_3_ADMIN, OnAdmin)
ON_COMMAND(ID_3_SUPERSEARCH, OnSupersearch)
ON_COMMAND(ID_1_DEL, OnDel)
ON_COMMAND(ID_4_INFO, OnShowInfo)
ON_COMMAND(ID_3_RENEW, OnRenew)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBankSystemDlg message handlers
BOOL CBankSystemDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
SetWindowSkin( m_hWnd , "Dialog" );
SetDialogSkin("Dialog");
// TODO: Add extra initialization here
m_bGuashi=m_bJiegua=false;
m_iPower=0;
m_iTransaction=0;
HRESULT hr = m_pConnection.CreateInstance(__uuidof(Connection));
if(SUCCEEDED(hr))
{
m_pConnection->Open("Provider=SQLOLEDB;server=(local);uid=sa;pwd=111111;database=BankData","","",adModeUnknown);
}
childDlg=new CDialog();
LoginDlg=new CLogin();
childDlg=LoginDlg;
childDlg->Create(IDD_LOG,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CBankSystemDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CBankSystemDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CBankSystemDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CBankSystemDlg::OnCreate()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
CreateDlg=new CCreate();
childDlg=CreateDlg;
childDlg->Create(IDD_DIALOG1,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
void CBankSystemDlg::OnGuashi()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
GuaJieDlg=new CGuaJie();
childDlg=GuaJieDlg;
childDlg->Create(IDD_DIALOG2,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
m_bGuashi=true;
m_bJiegua=false;
}
void CBankSystemDlg::OnJiegua()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
GuaJieDlg=new CGuaJie();
childDlg=GuaJieDlg;
childDlg->Create(IDD_DIALOG2,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
m_bGuashi=false;
m_bJiegua=true;
}
void CBankSystemDlg::OnChangepw()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
ChangeDlg=new CChangePw();
childDlg=ChangeDlg;
childDlg->Create(IDD_DIALOG3,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
void CBankSystemDlg::OnDeposit()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
DepositOrWithdrawDlg=new CDepositOrWithdraw();
childDlg=DepositOrWithdrawDlg;
childDlg->Create(IDD_DIALOG4,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
m_iTransaction=1; //存钱
}
void CBankSystemDlg::OnSearch()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
SearchDlg=new CSearch();
childDlg=SearchDlg;
childDlg->Create(IDD_DIALOG6,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
void CBankSystemDlg::OnTransfer()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
TransferDlg=new CTransfer();
childDlg=TransferDlg;
childDlg->Create(IDD_DIALOG5,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
void CBankSystemDlg::OnWithdraw()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg=new CDialog();
DepositOrWithdrawDlg=new CDepositOrWithdraw();
childDlg=DepositOrWithdrawDlg;
childDlg->Create(IDD_DIALOG4,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
// childDlg->GetDlgItem(IDC_RADIO1)->ShowWindow(SW_HIDE);
// childDlg->GetDlgItem(IDC_RADIO2)->ShowWindow(SW_HIDE);
m_iTransaction=2; //取钱
}
float CBankSystemDlg::Check(CString strAcount)
{
CString strSQL,m_strInterest;
CTime m_cTime=CTime::GetCurrentTime();
CTime m_cLastTime,m_cDueTime,m_cNowTime;
CTimeSpan timespan;
float m_iInterest,money;
_RecordsetPtr m_pRec;
CString acount,m_strLastTime,m_strSort,m_strStatus,m_strDueTime;
_variant_t vartime,varInterest,varMoney;
strSQL="SELECT * FROM VIEW1 where 账号=";
strSQL+=strAcount;
m_pRec.CreateInstance(__uuidof(Recordset));
m_pRec->Open(_variant_t(strSQL),m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(m_pRec->adoEOF)
{
AfxMessageBox("不存在此账号");
return -1;
}
m_strStatus=(LPCSTR)_bstr_t(m_pRec->GetCollect("状态"));
if(m_strStatus=="挂失")
{
AfxMessageBox("此账号已经挂失!");
return -1;
}
acount=(LPCSTR)_bstr_t(m_pRec->GetCollect("账号"));
m_strLastTime=(LPCSTR)_bstr_t(m_pRec->GetCollect("最后结算时间"));
m_strSort=(LPCSTR)_bstr_t(m_pRec->GetCollect("定活"));
CStringToCTime(m_strLastTime,m_cLastTime);
timespan=m_cTime-m_cLastTime;
int day=timespan.GetDays();
if(m_strSort=="定期") //定期结算
{
m_strDueTime=(LPCSTR)_bstr_t(m_pRec->GetCollect("到期时间"));
CStringToCTime(m_strDueTime,m_cDueTime);
m_cNowTime=CTime::GetCurrentTime();
CTimeSpan timespan;
timespan=m_cNowTime-m_cDueTime;
if(timespan.GetDays()<0)
{
// m_pRec->PutCollect("定活",_variant_t("活期"));
varInterest=m_pRec->GetCollect("定期");
m_iInterest=varInterest.dblVal;
varMoney=m_pRec->GetCollect("金额");
float money=varMoney.dblVal;
for(int i=0;i<day;i++)
money*=(m_iInterest+1);
varMoney.bVal=VT_I8;
varMoney.dblVal=money;
m_strLastTime=m_cTime.Format("%y-%m-%d");
vartime=m_strLastTime;
m_pRec->PutCollect("金额",varMoney);
m_pRec->PutCollect("最后结算时间",vartime);
m_pRec->Update();
m_pRec->Close();
}
else //到期后支取,到期后利息按活期算
{
m_strLastTime=(LPCSTR)_bstr_t(m_pRec->GetCollect("最后结算时间"));
CStringToCTime(m_strLastTime,m_cLastTime);
timespan=m_cDueTime-m_cLastTime;
varInterest=m_pRec->GetCollect("固定利息");
varMoney=m_pRec->GetCollect("金额");
money=varMoney.dblVal;
m_iInterest=varInterest.dblVal;
for(int i=0;i<timespan.GetDays();i++)
money*=(m_iInterest+1);
m_cTime = CTime::GetCurrentTime();
vartime = m_cTime.Format("%y-%m-%d");
timespan = m_cTime-m_cDueTime;
varInterest= m_pRec->GetCollect("活期");
m_iInterest = varInterest.dblVal;
for(i=0;i<timespan.GetDays();i++)
money*=(m_iInterest+1);
varMoney.dblVal=money;
m_pRec->PutCollect("金额",varMoney);
m_pRec->PutCollect("定活",_variant_t("活期"));
m_pRec->PutCollect("最后结算时间",_variant_t(vartime));
m_pRec->Update();
m_pRec->Close();
}
}
else //活期结算
{
m_pRec.CreateInstance(__uuidof(Recordset));
m_pRec->Open(_variant_t(strSQL),m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
varMoney=m_pRec->GetCollect("金额");
varInterest= m_pRec->GetCollect("活期");
m_iInterest = varInterest.dblVal;
money=varMoney.dblVal;
for(int i=0;i<timespan.GetDays();i++)
money*=(m_iInterest+1);
varMoney.dblVal=money;
m_cTime = CTime::GetCurrentTime();
vartime = m_cTime.Format("%y-%m-%d");
m_pRec->PutCollect("金额",varMoney);
m_pRec->PutCollect("最后结算时间",_variant_t(vartime));
m_pRec->Update();
m_pRec->Close();
}
return money;
}
void CBankSystemDlg::CStringToCTime(CString str,CTime &time)
{
COleVariant vtime(str);
vtime.ChangeType(VT_DATE);
COleDateTime time4=vtime;
SYSTEMTIME systime;
VariantTimeToSystemTime(time4, &systime);
CTime temp(systime);
time=temp;
}
void CBankSystemDlg::OnAdmin()
{
// TODO: Add your command handler code here
if(m_iPower<2)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg = new CDialog();
TabDlg = new CTab();
childDlg = TabDlg;
childDlg->Create(IDD_TAB,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
void CBankSystemDlg::OnSupersearch()
{
// TODO: Add your command handler code here
if(m_iPower<2)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg = new CDialog();
ShowLogDlg = new CShowLog();
childDlg = ShowLogDlg;
childDlg->Create(IDD_SHOWLOG,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
void CBankSystemDlg::OnDel()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg = new CDialog();
zhuxiaoDlg = new CZhuxiao();
childDlg = zhuxiaoDlg;
childDlg->Create(IDD_ZHUZIAIO,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
void CBankSystemDlg::OnShowInfo()
{
// TODO: Add your command handler code here
if(m_iPower<1)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg = new CDialog();
infoDlg = new CInfo();
childDlg = infoDlg;
childDlg->Create(IDD_SHOWINFO,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
infoDlg->ShowInfo();
}
BOOL CBankSystemDlg::IsChars(CString str)
{
for(int i=0;i<str.GetLength();i++)
if(str[i]<'Z'||str[i]>'z')
return false;
return true;
}
BOOL CBankSystemDlg::IsDigits(CString str)
{
for(int i=0;i<str.GetLength();i++)
if((str[i]<'0'||str[i]>'9') && str[i]!='.')
return false;
return true;
}
void CBankSystemDlg::OnRenew()
{
// TODO: Add your command handler code here
if(m_iPower<2)
return;
if(childDlg!=NULL)
{
delete childDlg;
}
childDlg = new CDialog();
ReNewDlg = new CReNew();
childDlg = ReNewDlg;
childDlg->Create(IDD_RENEW,&m_childDlg);
childDlg->ShowWindow(SW_SHOWNORMAL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -