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

📄 feetimechangemodifydlg.cpp

📁 VC6.0环境下编写的一个交换机计费程序。
💻 CPP
字号:
// feeTimechangemodifyDlg.cpp : implementation file
//

#include "stdafx.h"
#include "fee.h"
#include "feeTimechangemodifyDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CfeeTimechangemodifyDlg dialog


CfeeTimechangemodifyDlg::CfeeTimechangemodifyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CfeeTimechangemodifyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CfeeTimechangemodifyDlg)
	m_bfeeincity = FALSE;
	m_bfeeincountry = FALSE;
	m_bfeeinlong = FALSE;
	m_bfeeoutcity = FALSE;
	m_bfeeoutcountry = FALSE;
	m_bfeeoutlong = FALSE;
	m_bfeespec = FALSE;
	m_strstartyear = _T("");
	m_strendday = _T("");
	m_strendhour = _T("");
	m_strendminute = _T("");
	m_strendmonth = _T("");
	m_strendsecond = _T("");
	m_strendyear = _T("");
	m_strstartday = _T("");
	m_strstarthour = _T("");
	m_strstartminute = _T("");
	m_strstartmonth = _T("");
	m_strstartsecond = _T("");
	m_uintfeedecper = 0;
	//}}AFX_DATA_INIT
}


void CfeeTimechangemodifyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CfeeTimechangemodifyDlg)
	DDX_Check(pDX, IDC_CHECK_FEETIMECHANGE_INCITY, m_bfeeincity);
	DDX_Check(pDX, IDC_CHECK_FEETIMECHANGE_INCOUNTRY, m_bfeeincountry);
	DDX_Check(pDX, IDC_CHECK_FEETIMECHANGE_INLONG, m_bfeeinlong);
	DDX_Check(pDX, IDC_CHECK_FEETIMECHANGE_OUTCITY, m_bfeeoutcity);
	DDX_Check(pDX, IDC_CHECK_FEETIMECHANGE_OUTCOUNTRY, m_bfeeoutcountry);
	DDX_Check(pDX, IDC_CHECK_FEETIMECHANGE_OUTLONG, m_bfeeoutlong);
	DDX_Check(pDX, IDC_CHECK_FEETIMECHANGE_SPEC, m_bfeespec);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHAGE_STARTYEAR, m_strstartyear);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_ENDDAY, m_strendday);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_ENDHOUR, m_strendhour);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_ENDMINUTE, m_strendminute);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_ENDMONTH, m_strendmonth);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_ENDSECOND, m_strendsecond);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_ENDYEAR, m_strendyear);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_STARTDAY, m_strstartday);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_STARTHOUR, m_strstarthour);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_STARTMINUTE, m_strstartminute);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_STARTMONTH, m_strstartmonth);
	DDX_CBString(pDX, IDC_COMBO_FEETIMECHANGE_STARTSECOND, m_strstartsecond);
	DDX_Text(pDX, IDC_EDIT1_FEETIMECHANGE_DECPERCENT, m_uintfeedecper);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CfeeTimechangemodifyDlg, CDialog)
	//{{AFX_MSG_MAP(CfeeTimechangemodifyDlg)
	ON_BN_CLICKED(ID_TIMECHAGE_MODIFY, OnTimechageModify)
	ON_BN_CLICKED(ID_FEETIMECHANGE_DELETE, OnFeetimechangeDelete)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CfeeTimechangemodifyDlg message handlers

void CfeeTimechangemodifyDlg::OnTimechageModify() 
{
	// TODO: Add your control notification handler code here
	CString strSql,strTemp,strTemp1;

	BOOL	oldbfeeincity;
	BOOL	oldbfeeincountry;
	BOOL	oldbfeeinlong;
	BOOL	oldbfeeoutcity;
	BOOL	oldbfeeoutcountry;
	BOOL	oldbfeeoutlong;
	BOOL	oldbfeespec;
	CString	oldstrstartyear;
	CString	oldstrendday;
	CString	oldstrendhour;
	CString	oldstrendminute;
	CString	oldstrendmonth;
	CString	oldstrendsecond;
	CString	oldstrendyear;
	CString	oldstrstartday;
	CString	oldstrstarthour;
	CString	oldstrstartminute;
	CString	oldstrstartmonth;
	CString	oldstrstartsecond;
	UINT	olduintfeedecper;
	
	oldbfeeincity=m_bfeeincity;
	oldbfeeincountry=m_bfeeincountry;
	oldbfeeinlong=m_bfeeinlong;
	oldbfeeoutcity=m_bfeeoutcity;
	oldbfeeoutcountry=m_bfeeoutcountry;
	oldbfeeoutlong=m_bfeeoutlong;
	oldbfeespec=m_bfeespec;
	oldstrendyear=m_strendyear;
	oldstrendmonth=m_strendmonth;
	oldstrendday=m_strendday;
	oldstrendhour=m_strendhour;
	oldstrendminute=m_strendminute;
	oldstrendsecond=m_strendsecond;
	oldstrstartyear=m_strstartyear;
	oldstrstartmonth=m_strstartmonth;
	oldstrstartday=m_strstartday;
	oldstrstarthour=m_strstarthour;
	oldstrstartminute=m_strstartminute;
	oldstrstartsecond=m_strstartsecond;
	olduintfeedecper=m_uintfeedecper;

	UpdateData(TRUE);

	long lyear,lmonth,lday;
	long flag;
	lyear=atol(m_strstartyear);
	lmonth=atol(m_strstartmonth);
	lday=atol(m_strstartday);

	if (lyear<2000)
		flag=1;
	if (lmonth<1||lmonth>12)
		flag=1;
	if (lday<1||lday>31)
		flag=1;
	if (lmonth==1||lmonth==3||lmonth==5||lmonth==7||lmonth==8||lmonth==10||lmonth==12)
	{
		if (lday>31)
		{
			flag=1;
		}
	}
	if (lmonth==4||lmonth==6||lmonth==9||lmonth==11)
	{
		if (lday>30)
		{
			flag=1;
		}
	}
	if(lmonth==2)
	{
		if ((lyear%4)==0)
		{
			if (lday>29)
			{
				flag=1;
			}
		}
		else
		{
			if (lday>28)
			{
				flag=1;
			}
		}
	}

	if (flag==1)
	{
		AfxMessageBox("timeset error");
		OnCancel();
		return;
	}

	flag=0;
	lyear=atol(m_strendyear);
	lmonth=atol(m_strendmonth);
	lday=atol(m_strendday);

	if (lyear<2000)
		flag=1;
	if (lmonth<1||lmonth>12)
		flag=1;
	if (lday<1||lday>31)
		flag=1;
	if (lmonth==1||lmonth==3||lmonth==5||lmonth==7||lmonth==8||lmonth==10||lmonth==12)
	{
		if (lday>31)
		{
			flag=1;
		}
	}
	if (lmonth==4||lmonth==6||lmonth==9||lmonth==11)
	{
		if (lday>30)
		{
			flag=1;
		}
	}
	if(lmonth==2)
	{
		if ((lyear%4)==0)
		{
			if (lday>29)
			{
				flag=1;
			}
		}
		else
		{
			if (lday>28)
			{
				flag=1;
			}
		}
	}

	if (flag==1)
	{
		AfxMessageBox("timeset error");
		OnCancel();
		return;
	}

	long lhour,lminute,lsecond;
	flag=0;
	lhour=atol(m_strstarthour);
	lminute=atol(m_strstartminute);
	lsecond=atol(m_strstartsecond);
	if (lhour>=24) 
	{
		flag=1;
	}
	if (lminute>=60)
	{
		flag=1;
	}
	if (lsecond>=60)
	{
		flag=1;
	}
	if (flag==1)
	{
		AfxMessageBox("timeset error");
		OnCancel();
		return;
	}
	flag=0;
	lhour=atol(m_strendhour);
	lminute=atol(m_strendminute);
	lsecond=atol(m_strendsecond);
	if (lhour>=24) 
	{
		flag=1;
	}
	if (lminute>=60)
	{
		flag=1;
	}
	if (lsecond>=60)
	{
		flag=1;
	}
	if (flag==1)
	{
		AfxMessageBox("timeset error");
		OnCancel();
		return;
	}


	strSql.Format("select * from feetimechange");
	strTemp.Format(" where feetimechangestartdate=#%d-%d-%d#",\
		atol(oldstrstartyear),atol(oldstrstartmonth),atol(oldstrstartday));
	strSql=strSql+strTemp;
	strTemp.Format(" and feetimechangeenddate=#%d-%d-%d#",\
		atol(oldstrendyear),atol(oldstrendmonth),atol(oldstrendday));
	strSql=strSql+strTemp;
	strTemp.Format(" and feedaychangestarttime=#%d:%d:%d#",\
		atol(oldstrstarthour),atol(oldstrstartminute),atol(oldstrstartsecond));
	strSql=strSql+strTemp;
	strTemp.Format(" and feedaychangeendtime=#%d:%d:%d#",\
		atol(oldstrendhour),atol(oldstrendminute),atol(oldstrendsecond));
	strSql=strSql+strTemp;
	strTemp.Format(" and feetimechangedecper=%d",olduintfeedecper);
	strSql=strSql+strTemp;


	long lkind;
	lkind=0;
	if (oldbfeeincountry==TRUE) lkind|=1;
	if (oldbfeeincity==TRUE) lkind|=2;
	if (oldbfeeoutcountry==TRUE) lkind|=4;
	if (oldbfeeoutcity==TRUE) lkind|=8;
	if (oldbfeeinlong==TRUE) lkind|=0x10;
	if (oldbfeeoutlong==TRUE) lkind|=0x20;
	if (oldbfeespec==TRUE) lkind|=0x40;

	strTemp.Format(" and feetimechangekind=%d",lkind);
	strSql=strSql+strTemp;
	flag=0;
	CFeeApp* pApp;
	HRESULT result;
	pApp=(CFeeApp *)AfxGetApp();
	result=pApp->m_pjifeiRecordset->Open(strSql.AllocSysString(),
		pApp->m_pjifeiConnection.GetInterfacePtr(),
		adOpenDynamic,adLockOptimistic,adCmdText);
	if (!SUCCEEDED(result))
	{
		AfxMessageBox("can't open feedirection table");
	}
	if(!pApp->m_pjifeiRecordset->adoEOF)
	{
		CString strstartdate,strstarttime,strenddate,strendtime;

		strstartdate=m_strstartyear+"-"+m_strstartmonth+"-"+m_strstartday;
		strenddate=m_strendyear+"-"+m_strendmonth+"-"+m_strendday;
		strstarttime=m_strstarthour+":"+m_strstartminute+":"+m_strstartsecond;
		strendtime=m_strendhour+":"+m_strendminute+":"+m_strendsecond;
		strTemp=strstartdate;
		if (strTemp!="")
			pApp->m_pjifeiRecordset->PutCollect("feetimechangestartdate",_variant_t(strTemp));
		strTemp=strstarttime;
		if (strTemp!="")
			pApp->m_pjifeiRecordset->PutCollect("feedaychangestarttime",_variant_t(strTemp));
		strTemp=strenddate;
		if (strTemp!="")
			pApp->m_pjifeiRecordset->PutCollect("feetimechangeenddate",_variant_t(strTemp));
		strTemp=strendtime;
		if (strTemp!="")
			pApp->m_pjifeiRecordset->PutCollect("feedaychangeendtime",_variant_t(strTemp));
		strTemp.Format("%d",m_uintfeedecper);
		pApp->m_pjifeiRecordset->PutCollect("feetimechangedecper",_variant_t(strTemp));
		
		long lkind;
		lkind=0;
		if (m_bfeeincountry==TRUE)
			lkind|=1;
		if (m_bfeeincity==TRUE)
			lkind|=2;
		if (m_bfeeoutcountry==TRUE)
			lkind|=4;
		if (m_bfeeoutcity==TRUE)
			lkind|=8;
		if (m_bfeeinlong==TRUE)
			lkind|=0x10;
		if (m_bfeeoutlong==TRUE)
			lkind|=0x20;
		if (m_bfeespec==TRUE)
			lkind|=0x40;
		strTemp.Format("%d",lkind);
		pApp->m_pjifeiRecordset->PutCollect("feetimechangekind",_variant_t(strTemp));
		pApp->m_pjifeiRecordset->Update();
		AfxMessageBox("Modified successfully");
	}
	else
	{
		AfxMessageBox("The record to modify does not exist");
	}
	pApp->m_pjifeiRecordset->Close();
	
	CDialog::OnOK();

	
}

void CfeeTimechangemodifyDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void CfeeTimechangemodifyDlg::OnFeetimechangeDelete() 
{
	// TODO: Add your control notification handler code here

	BOOL	oldbfeeincity;
	BOOL	oldbfeeincountry;
	BOOL	oldbfeeinlong;
	BOOL	oldbfeeoutcity;
	BOOL	oldbfeeoutcountry;
	BOOL	oldbfeeoutlong;
	BOOL	oldbfeespec;
	CString	oldstrstartyear;
	CString	oldstrendday;
	CString	oldstrendhour;
	CString	oldstrendminute;
	CString	oldstrendmonth;
	CString	oldstrendsecond;
	CString	oldstrendyear;
	CString	oldstrstartday;
	CString	oldstrstarthour;
	CString	oldstrstartminute;
	CString	oldstrstartmonth;
	CString	oldstrstartsecond;
	UINT	olduintfeedecper;
	

	oldbfeeincity=m_bfeeincity;
	oldbfeeincountry=m_bfeeincountry;
	oldbfeeinlong=m_bfeeinlong;
	oldbfeeoutcity=m_bfeeoutcity;
	oldbfeeoutcountry=m_bfeeoutcountry;
	oldbfeeoutlong=m_bfeeoutlong;
	oldbfeespec=m_bfeespec;
	oldstrendyear=m_strendyear;
	oldstrendmonth=m_strendmonth;
	oldstrendday=m_strendday;
	oldstrendhour=m_strendhour;
	oldstrendminute=m_strendminute;
	oldstrendsecond=m_strendsecond;
	oldstrstartyear=m_strstartyear;
	oldstrstartmonth=m_strstartmonth;
	oldstrstartday=m_strstartday;
	oldstrstarthour=m_strstarthour;
	oldstrstartminute=m_strstartminute;
	oldstrstartsecond=m_strstartsecond;
	olduintfeedecper=m_uintfeedecper;

	CString strSql,strTemp;
	strSql.Format("select * from feetimechange");
	strTemp.Format(" where feetimechangestartdate=#%d-%d-%d#",\
		atol(oldstrstartyear),atol(oldstrstartmonth),atol(oldstrstartday));
	strSql=strSql+strTemp;
	strTemp.Format(" and feetimechangeenddate=#%d-%d-%d#",\
		atol(oldstrendyear),atol(oldstrendmonth),atol(oldstrendday));
	strSql=strSql+strTemp;
	strTemp.Format(" and feedaychangestarttime=#%d:%d:%d#",\
		atol(oldstrstarthour),atol(oldstrstartminute),atol(oldstrstartsecond));
	strSql=strSql+strTemp;
	strTemp.Format(" and feedaychangeendtime=#%d:%d:%d#",\
		atol(oldstrendhour),atol(oldstrendminute),atol(oldstrendsecond));
	strSql=strSql+strTemp;
	strTemp.Format(" and feetimechangedecper=%d",olduintfeedecper);
	strSql=strSql+strTemp;

	long lkind;
	lkind=0;
	if (oldbfeeincountry==TRUE) lkind|=1;
	if (oldbfeeincity==TRUE) lkind|=2;
	if (oldbfeeoutcountry==TRUE) lkind|=4;
	if (oldbfeeoutcity==TRUE) lkind|=8;
	if (oldbfeeinlong==TRUE) lkind|=0x10;
	if (oldbfeeoutlong==TRUE) lkind|=0x20;
	if (oldbfeespec==TRUE) lkind|=0x40;

	strTemp.Format(" and feetimechangekind=%d",lkind);
	strSql=strSql+strTemp;
	unsigned char flag;
	flag=0;
	CFeeApp* pApp;
	HRESULT result;
	pApp=(CFeeApp *)AfxGetApp();
	result=pApp->m_pjifeiRecordset->Open(strSql.AllocSysString(),
		pApp->m_pjifeiConnection.GetInterfacePtr(),
		adOpenDynamic,adLockOptimistic,adCmdText);
	if (!SUCCEEDED(result))
	{
		AfxMessageBox("can't open feedirection table");
	}
	if(!pApp->m_pjifeiRecordset->adoEOF)
	{
		flag=1;
	}
	pApp->m_pjifeiRecordset->Close();
	if (flag==1)
	{
		strSql.Format("delete * from feetimechange");
		strTemp.Format(" where feetimechangestartdate=#%d-%d-%d#",\
			atol(oldstrstartyear),atol(oldstrstartmonth),atol(oldstrstartday));
		strSql=strSql+strTemp;
		strTemp.Format(" and feetimechangeenddate=#%d-%d-%d#",\
			atol(oldstrendyear),atol(oldstrendmonth),atol(oldstrendday));
		strSql=strSql+strTemp;
		strTemp.Format(" and feedaychangestarttime=#%d:%d:%d#",\
			atol(oldstrstarthour),atol(oldstrstartminute),atol(oldstrstartsecond));
		strSql=strSql+strTemp;
		strTemp.Format(" and feedaychangeendtime=#%d:%d:%d#",\
			atol(oldstrendhour),atol(oldstrendminute),atol(oldstrendsecond));
		strSql=strSql+strTemp;
		strTemp.Format(" and feetimechangedecper=%d",olduintfeedecper);
		strSql=strSql+strTemp;

		long lkind;
		lkind=0;
		if (oldbfeeincountry==TRUE) lkind|=1;
		if (oldbfeeincity==TRUE) lkind|=2;
		if (oldbfeeoutcountry==TRUE) lkind|=4;
		if (oldbfeeoutcity==TRUE) lkind|=8;
		if (oldbfeeinlong==TRUE) lkind|=0x10;
		if (oldbfeeoutlong==TRUE) lkind|=0x20;
		if (oldbfeespec==TRUE) lkind|=0x40;

		strTemp.Format(" and feetimechangekind=%d",lkind);
		strSql=strSql+strTemp;
		pApp=(CFeeApp *)AfxGetApp();
		result=pApp->m_pjifeiRecordset->Open(strSql.AllocSysString(),
			pApp->m_pjifeiConnection.GetInterfacePtr(),
			adOpenDynamic,adLockOptimistic,adCmdText);
		if (!SUCCEEDED(result))
		{
			AfxMessageBox("can't open feedirection table");
		}
	}
	CDialog::OnOK();
}

⌨️ 快捷键说明

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