📄 cessdlg.cpp
字号:
// CessDlg.cpp : implementation file
//
#include "stdafx.h"
#include "pitc.h"
#include "CessDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString cessFlag;
//extern int curCess;
extern BOOL modified;
/////////////////////////////////////////////////////////////////////////////
// CCessDlg dialog
CCessDlg::CCessDlg(CWnd* pParent /*=NULL*/)
: CDialog(CCessDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CCessDlg)
m_dCess = 0.0;
m_dFrom = 0.0;
m_dTo = 0.0;
//}}AFX_DATA_INIT
}
void CCessDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCessDlg)
DDX_Text(pDX, IDC_EDIT_CESS, m_dCess);
DDX_Text(pDX, IDC_EDIT_FROM, m_dFrom);
DDX_Text(pDX, IDC_EDIT_TO, m_dTo);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CCessDlg, CDialog)
//{{AFX_MSG_MAP(CCessDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCessDlg message handlers
void CCessDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if(m_dFrom<0)
{
AfxMessageBox("超过值应>=0!");
GetDlgItem(IDC_EDIT_FROM)->SetFocus();
return;
}
if(m_dTo<0)
{
AfxMessageBox("至值应>=0!");
GetDlgItem(IDC_EDIT_TO)->SetFocus();
return;
}
if(m_dTo<=m_dFrom)
{
AfxMessageBox("超过值应<至值!");
GetDlgItem(IDC_EDIT_TO)->SetFocus();
return;
}
if(m_dCess<0)
{
AfxMessageBox("税率值应>=0!");
GetDlgItem(IDC_EDIT_CESS)->SetFocus();
return;
}
////
CMainFrame *pMain;
pMain=(CMainFrame *)(AfxGetApp()->m_pMainWnd);
CListCtrlCess *pListCtrl;
pListCtrl=(CListCtrlCess *)(&(pMain->m_pConfigViewCess->m_wndListCtrlCess));
/////
m_dFrom=((CPITCApp*)AfxGetApp())->Sswr(m_dFrom,2);//保留2位小数
m_dTo=((CPITCApp*)AfxGetApp())->Sswr(m_dTo,2);
m_dCess=((CPITCApp*)AfxGetApp())->Sswr(m_dCess,2);//税率保留几位小数?
/////
if(cessFlag=="ADD")
{
//POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
//int m=pListCtrl->GetNextSelectedItem(pos);//第一个被选中的
int count=pListCtrl->GetItemCount();
CString str;
str.Format("%d",count);
int nitem=pListCtrl->InsertItem(count,str);
str.Format("%.2f",m_dFrom);
pListCtrl->SetItemText(nitem,1,str);
str.Format("%.2f",m_dTo);
pListCtrl->SetItemText(nitem,2,str);
str.Format("%.2f",m_dCess);
pListCtrl->SetItemText(nitem,3,str);
pListCtrl->UpdateNum();//更新级别序号
pListCtrl->SetItemState(-1, 0, LVNI_SELECTED);//取消所有的item选中状态,执行后,item_cur可能会改变
pListCtrl->SetFocus();
pListCtrl->SetItemState(nitem,LVNI_SELECTED,LVNI_SELECTED);
}
if(cessFlag=="INSERT")
{
POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
int m=pListCtrl->GetNextSelectedItem(pos);//第一个被选中的
if(m<0)
m=0;
CString str;
str.Format("%d",m+1);
int nitem=pListCtrl->InsertItem(m,str);
str.Format("%.2f",m_dFrom);
pListCtrl->SetItemText(nitem,1,str);
str.Format("%.2f",m_dTo);
pListCtrl->SetItemText(nitem,2,str);
str.Format("%.2f",m_dCess);
pListCtrl->SetItemText(nitem,3,str);
pListCtrl->UpdateNum();//更新级别序号
pListCtrl->SetItemState(-1, 0, LVNI_SELECTED);//取消所有的item选中状态,执行后,item_cur可能会改变
pListCtrl->SetFocus();
pListCtrl->SetItemState(nitem,LVNI_SELECTED,LVNI_SELECTED);
}
if(cessFlag=="EDIT")
{
POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
int m=pListCtrl->GetNextSelectedItem(pos);//第一个被选中的
int count=pListCtrl->GetItemCount();
int num=atoi(pListCtrl->GetItemText(m,0));
CString str;
str.Format("%.2f",m_dFrom);
pListCtrl->SetItemText(m,1,str);
//if(num==count)//如果是编辑最后一行
//pListCtrl->SetItemText(m,2,"∞");
//else
{
str.Format("%.2f",m_dTo);
pListCtrl->SetItemText(m,2,str);
}
str.Format("%.2f",m_dCess);
pListCtrl->SetItemText(m,3,str);
pListCtrl->SetItemState(-1, 0, LVNI_SELECTED);//取消所有的item选中状态,执行后,item_cur可能会改变
pListCtrl->SetFocus();
pListCtrl->SetItemState(m,LVNI_SELECTED,LVNI_SELECTED);
}
modified=TRUE;
//////////////
CDialog::OnOK();
}
BOOL CCessDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(cessFlag=="ADD")
{
SetWindowText("添加税率");
}
else if(cessFlag=="INSERT")
{
SetWindowText("插入税率");
}
else if(cessFlag=="EDIT")
{
CMainFrame *pMain;
pMain=(CMainFrame *)(AfxGetApp()->m_pMainWnd);
CListCtrl *pListCtrl;
pListCtrl=&(pMain->m_pConfigViewCess->m_wndListCtrlCess);
int count=pListCtrl->GetSelectedCount();
if(0==count)
{
AfxMessageBox("请在税率表中选则一行数据!");
return FALSE;
}
POSITION pos = pListCtrl->GetFirstSelectedItemPosition();
int m=pListCtrl->GetNextSelectedItem(pos);//第一个被选中的
m_dFrom=atof(pListCtrl->GetItemText(m,1));
m_dTo=atof(pListCtrl->GetItemText(m,2));
m_dCess=atof(pListCtrl->GetItemText(m,3));
UpdateData(FALSE);//更新显示
SetWindowText("修改税率");
}
this->GetParent()->SetFocus();
this->SetFocus();
GetDlgItem(IDC_EDIT_FROM)->SetFocus();
///////////
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -