?? configdoc.cpp
字號:
// ConfigDoc.cpp : implementation file
//
#include "stdafx.h"
#include "pitc.h"
#include "ConfigDoc.h"
#include "MainFrm.h"
#include "configViewCess.h"
#include "configViewArea.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//extern CString pathname;
/////////////////////////////////////////////////////////////////////////////
// CConfigDoc
IMPLEMENT_DYNCREATE(CConfigDoc, CDocument)
CConfigDoc::CConfigDoc()
{
}
BOOL CConfigDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
////
static int count=1;
char message[100];
wsprintf (message,"%s%d","未命名的配置文件",count);
SetTitle (message);
count++;
//////////////////////////
m_arrArea.RemoveAll();
m_arrStart.RemoveAll();
m_arrFrom.RemoveAll();
m_arrTo.RemoveAll();
m_arrCess.RemoveAll();
m_arrSub.RemoveAll();
//pathname="";
UpdateAllViews(NULL);
return TRUE;
}
CConfigDoc::~CConfigDoc()
{
}
BEGIN_MESSAGE_MAP(CConfigDoc, CDocument)
//{{AFX_MSG_MAP(CConfigDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CConfigDoc diagnostics
#ifdef _DEBUG
void CConfigDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CConfigDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CConfigDoc serialization
void CConfigDoc::Serialize(CArchive& ar)
{
////
int i,count_c,count_a;
if (ar.IsStoring())
{
// TODO: add storing code here
////
count_c=m_arrFrom.GetSize();
ar<<count_c;
for(i=0;i<count_c;i++)
{
ar<<m_arrFrom.GetAt(i);
if (i<count_c-1)
ar<<m_arrTo.GetAt(i);
ar<<m_arrCess.GetAt(i);
ar<<m_arrSub.GetAt(i);
}
////
count_a=m_arrArea.GetSize();
ar<<count_a;
for( i=0;i<count_a;i++)
{
ar<<m_arrArea.GetAt(i);
ar<<m_arrStart.GetAt(i);
}
}
else
{
// TODO: add loading code here
m_arrFrom.RemoveAll();
m_arrTo.RemoveAll();
m_arrCess.RemoveAll();
m_arrSub.RemoveAll();
double d;
CString str;
ar>>count_c;
for(i=0;i<count_c;i++)
{
ar>>d;
m_arrFrom.Add(d);
if (i<count_c-1)
{
ar>>d;
m_arrTo.Add(d);
}
ar>>d;
m_arrCess.Add(d);
ar>>d;
m_arrSub.Add(d);
}
////
m_arrArea.RemoveAll();
m_arrStart.RemoveAll();
ar>>count_a;
for( i=0;i<count_a;i++)
{
ar>>str;
m_arrArea.Add(str);
ar>>d;
m_arrStart.Add(d);
}
///
}
}
/////////////////////////////////////////////////////////////////////////////
// CConfigDoc commands
BOOL CConfigDoc::Exam()
{
CConfigViewCess *pViewCess;
CConfigViewArea *pViewArea;
CView *pView;
POSITION pos=GetFirstViewPosition();
while(pos)
{
pView=GetNextView(pos);
if(pView->IsKindOf(RUNTIME_CLASS(CConfigViewCess)))
pViewCess=(CConfigViewCess *)pView;
else if(pView->IsKindOf(RUNTIME_CLASS(CConfigViewArea)))
pViewArea=(CConfigViewArea *)pView;
}
ASSERT(pViewArea!=NULL);
ASSERT(pViewCess!=NULL);
if( pViewCess->ExamCess() && pViewArea->ExamArea() )
{
return TRUE;
}
else
{
return FALSE;
}
}
double CConfigDoc::ComputSub(int num)
{
/*
速算扣除數由系統根據稅率表計算得到,方法如下:
設 N,表示級別數,N=1,2,3…
Vmin[N],表示第N級別的超過值
Vmax[N],表示第N級別的超過值
R[N],表示第N級別的稅率
S[N],表示第N級別的速算扣除數
那么
i=1
S[N]=Vmin[N] * R[N] - Σ( ( Vmax[i]-Vmin[i] ) * R[i] )
i<N
*/
//ASSERT(num>=2);
double sub;
if(num==1)
{
sub=0.00;
return sub;
}
double temp=0.00;
for(int i=0;i<num-1;i++)
{
temp=temp + ( (m_arrTo.GetAt(i)) - (m_arrFrom.GetAt(i)) ) * (m_arrCess.GetAt(i));
}
sub=(m_arrFrom.GetAt(num-1)) * (m_arrCess.GetAt(num-1)) - temp;
return sub;
}
BOOL CConfigDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: Add your specialized code here and/or call the base class
if(!this->Exam())
return FALSE;
return CDocument::OnSaveDocument(lpszPathName);
}
BOOL CConfigDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))
return FALSE;
// TODO: Add your specialized creation code here
//pathname=lpszPathName;
SetPathName(lpszPathName,FALSE);
UpdateAllViews(NULL);
return TRUE;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -