📄 financing_master_hand.cpp
字号:
// Financing_Master_Hand.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "Financing_Master_Hand.h"
#include "MainFrm.h"
#include "Financing_Master_HandDoc.h"
#include "Financing_Master_HandView.h"
#include "LoginDlg.h" //包含对话框头文件
#include "AccountManagement.h" //包含帐号管理视图头文件
#include "Register_InOutcome_AccountDlg.h" //包含现金帐号注册对话框
#include "time.h" //包含时间头文件
#include <wchar.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//#define USERFILE _T("3004218118")
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandApp
BEGIN_MESSAGE_MAP(CFinancing_Master_HandApp, CWinApp)
//{{AFX_MSG_MAP(CFinancing_Master_HandApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
ON_COMMAND(ID_WINDOW_ACCOUNT, OnWindowAccount)
ON_COMMAND(ID_WINDOW_INOUTCOME, OnWindowInoutcome)
//}}AFX_MSG_MAP
// Standard file based document commands
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandApp construction
CFinancing_Master_HandApp::CFinancing_Master_HandApp()
: CWinApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
m_pFirstView = NULL;
m_pAnotherView = NULL;
m_sName = "";
m_sPasswd = "";
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CFinancing_Master_HandApp object
CFinancing_Master_HandApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandApp initialization
BOOL CFinancing_Master_HandApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
// Change the registry key under which our settings are stored.
// You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
LoginDlg login;
int nResult = login.DoModal();
if(nResult == IDOK) //ok时验证帐号
{
m_sName = _T("admin");
m_sPasswd = USERFILE;
if(m_sName != login.m_sName || m_sPasswd != login.m_sPasswd)
{
AfxMessageBox(_T("The account or password is not right"));
return FALSE;
}
}
else if(nResult == IDCANCEL)
return FALSE;
else //
{}
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CFinancing_Master_HandDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CFinancing_Master_HandView));
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
///////////////////////新建视图并和文档联系//////////////////////////
CView* m_pActiveView = ((CFrameWnd*)m_pMainWnd)->GetActiveView(); //
m_pFirstView = m_pActiveView; //
m_pAnotherView = new CAccountManagement(); //
//文档和视图关联 //
CDocument* m_pDoc = ((CFrameWnd*)m_pMainWnd)->GetActiveDocument(); //
CCreateContext context; //
context.m_pCurrentDoc = m_pDoc; //
//创建视图 //
UINT m_IDFORANOTHERVIEW = AFX_IDW_PANE_FIRST + 1; //
CRect rect; //
m_pAnotherView->Create(NULL,NULL,WS_CHILD,rect,m_pMainWnd,m_IDFORANOTHERVIEW,&context);
/////////////////////////////////////////////////////////////////////
m_pAnotherView->OnInitialUpdate();
// AfxMessageBox(_T("app initaccountmanagement"));
( (CFinancing_Master_HandView*)m_pFirstView )->SerializeInfo();
( (CAccountManagement*)m_pAnotherView )->SerializeInfo();
OnWindowAccount(); //初始化显示帐号窗口
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// 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)
virtual BOOL OnInitDialog(); // Added for WCE apps
//}}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()
// App command to run the dialog
void CFinancing_Master_HandApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CFinancing_Master_HandApp commands
// Added for WCE apps
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CenterWindow();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFinancing_Master_HandApp::OnWindowAccount()
{
// TODO: Add your command handler code here
UINT temp = ::GetWindowLong(m_pAnotherView->m_hWnd, GWL_ID);
::SetWindowLong(m_pAnotherView->m_hWnd, GWL_ID, ::GetWindowLong(m_pFirstView->m_hWnd, GWL_ID));
::SetWindowLong(m_pFirstView->m_hWnd, GWL_ID, temp);
m_pFirstView->ShowWindow(SW_HIDE);
m_pAnotherView->ShowWindow(SW_SHOW);
((CFrameWnd*)m_pMainWnd)->SetActiveView(m_pAnotherView);
((CFrameWnd*) m_pMainWnd)->RecalcLayout();
m_pAnotherView->Invalidate();
///////////////////////////////////////////////////////////////
//m_pAnotherView->OnInitialUpdate();
}
void CFinancing_Master_HandApp::OnWindowInoutcome()
{
// TODO: Add your command handler code here
if(!((CAccountManagement*)m_pAnotherView)->m_bAccountFlag[2]) //是否有帐号
{
CRegister_InOutcome_AccountDlg dlg;
dlg.m_sAccountName = m_sName;
if(dlg.DoModal() == IDOK) //注册成功
{
// CFinancing_Master_HandApp *TheApp=(CFinancing_Master_HandApp*)AfxGetApp();
// CAccountManagement * pAnotherView;
// pAnotherView =(CAccountManagement *) TheApp->m_pAnotherView;
if(dlg.m_nAccountType != 2) //用户选择的不是现金管理帐号
{
AfxMessageBox(_T("You should choose In/Ouncome account type"));
return;
}
CAccounts temp;
temp.m_account.m_sAccount = dlg.m_sAccountName;
temp.m_account.m_sName = m_sName;
temp.m_account.m_sRemark = dlg.m_AccountRemark;
temp.m_account.m_fRemainMoney=0; //有待修改
CTime time = CTime::GetCurrentTime();
temp.m_account.m_sDate.Format(_T("%04d-%02d-%02d"),time.GetYear(),
time.GetMonth(),time.GetDay());; //时间
temp.m_nNum = 2;
((CAccountManagement*)m_pAnotherView)->addItem( ((CAccountManagement*)m_pAnotherView)->m_nAccountNum,temp);
((CAccountManagement*)m_pAnotherView)->m_nAccountNum++;
CFile file;
CString fileName;
fileName =( (CFinancing_Master_HandApp*)AfxGetApp() )->m_sName+_T("2");
if(!file.Open(fileName,CFile::modeCreate|CFile::modeRead))
AfxMessageBox(_T("Create file:")+fileName+_T("failed"));
}
}
//////////////////////////////////////////////////////////////////////////////
UINT temp = ::GetWindowLong(m_pAnotherView->m_hWnd, GWL_ID);
::SetWindowLong(m_pAnotherView->m_hWnd, GWL_ID, ::GetWindowLong(m_pFirstView->m_hWnd, GWL_ID));
::SetWindowLong(m_pFirstView->m_hWnd, GWL_ID, temp);
m_pAnotherView->ShowWindow(SW_HIDE);
m_pFirstView->ShowWindow(SW_SHOW);
((CFrameWnd*)m_pMainWnd)->SetActiveView(m_pFirstView);
((CFrameWnd*) m_pMainWnd)->RecalcLayout();
m_pFirstView->Invalidate();
}
int CFinancing_Master_HandApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
return CWinApp::ExitInstance();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -