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

📄 accept.cpp

📁 根据客户提供的轮胎规格,单价,完成天数计算价格,并形成记录,可根据记录自行选择轮胎种类计算某几种轮胎再一定时间内完成需要价格.共有记录添加,记录修改,计算价格三个部分
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	m_chk5=0;
	UpdateData(FALSE);
}

void accept::OnCancel2() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	UpdateData(FALSE);
	fstream datafile,bufffile;
	if(!m_chk1&&!m_chk2&&!m_chk3&&!m_chk4&&!m_chk5)
		return;
	if(m_chk1)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);
			
		changed(page*5+1,datafile);
	if(!m_mtype1.IsEmpty()&&!m_meach1.IsEmpty()&&!m_mtime1.IsEmpty()&&!m_mtime2.IsEmpty()&&!m_mprice1.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile.close();
	appendd(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk2)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			changed(page*5+2,datafile);
	if(!m_mtype2.IsEmpty()&&!m_meach2.IsEmpty()&&!m_mtime3.IsEmpty()&&!m_mtime4.IsEmpty()&&!m_mprice2.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile.close();
	appendd(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk3)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			changed(page*5+3,datafile);
	if(!m_mtype3.IsEmpty()&&!m_meach3.IsEmpty()&&!m_mtime5.IsEmpty()&&!m_mtime6.IsEmpty()&&!m_mprice3.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile.close();
	appendd(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk4)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			changed(page*5+4,datafile);
	if(!m_mtype4.IsEmpty()&&!m_meach4.IsEmpty()&&!m_mtime7.IsEmpty()&&!m_mtime8.IsEmpty()&&!m_mprice4.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile.close();
	appendd(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk5)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			changed(page*5+5,datafile);
	if(!m_mtype5.IsEmpty()&&!m_meach5.IsEmpty()&&!m_mtime9.IsEmpty()&&!m_mtime10.IsEmpty()&&!m_mprice5.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile.close();
	appendd(datafile);
		datafile.close();
		copyfile();
	}
	}
	m_chk1=0;
	m_chk2=0;
	m_chk3=0;
	m_chk4=0;
	m_chk5=0;
		UpdateData(FALSE);
		OnOk3();
}

void accept::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);
	UpdateData(FALSE);
	fstream datafile,bufffile;
	if(!m_chk1&&!m_chk2&&!m_chk3&&!m_chk4&&!m_chk5)
		return;
	if(m_chk1)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);
			
		change(page*5+1,datafile);
	if(!m_mtype1.IsEmpty()&&!m_meach1.IsEmpty()&&!m_mtime1.IsEmpty()&&!m_mtime2.IsEmpty()&&!m_mprice1.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile<<m_mtype1<<"\n";
	bufffile<<m_meach1<<"\n";
	bufffile<<m_mtime1<<"\n";
	bufffile<<m_mtime2<<"\n";
	bufffile<<m_mprice1<<"\n";
	bufffile<<"noteend\n";
	bufffile.close();
	append(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk2)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			change(page*5+2,datafile);
	if(!m_mtype2.IsEmpty()&&!m_meach2.IsEmpty()&&!m_mtime3.IsEmpty()&&!m_mtime4.IsEmpty()&&!m_mprice2.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile<<m_mtype2<<"\n";
	bufffile<<m_meach2<<"\n";
	bufffile<<m_mtime3<<"\n";
	bufffile<<m_mtime4<<"\n";
	bufffile<<m_mprice2<<"\n";
	bufffile<<"noteend\n";
	bufffile.close();
	append(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk3)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			change(page*5+3,datafile);
	if(!m_mtype3.IsEmpty()&&!m_meach3.IsEmpty()&&!m_mtime5.IsEmpty()&&!m_mtime6.IsEmpty()&&!m_mprice3.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile<<m_mtype3<<"\n";
	bufffile<<m_meach3<<"\n";
	bufffile<<m_mtime5<<"\n";
	bufffile<<m_mtime6<<"\n";
	bufffile<<m_mprice3<<"\n";
	bufffile<<"noteend\n";
	bufffile.close();
	append(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk4)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			change(page*5+4,datafile);
	if(!m_mtype4.IsEmpty()&&!m_meach4.IsEmpty()&&!m_mtime7.IsEmpty()&&!m_mtime8.IsEmpty()&&!m_mprice4.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile<<m_mtype4<<"\n";
	bufffile<<m_meach4<<"\n";
	bufffile<<m_mtime7<<"\n";
	bufffile<<m_mtime8<<"\n";
	bufffile<<m_mprice4<<"\n";
	bufffile<<"noteend\n";
	bufffile.close();
	append(datafile);
		datafile.close();
		copyfile();
	}
	}
	if(m_chk5)
	{
			datafile.open("d:\\Program Files\\type\\type.typ",ios::in|ios::out);

			change(page*5+5,datafile);
	if(!m_mtype5.IsEmpty()&&!m_meach5.IsEmpty()&&!m_mtime9.IsEmpty()&&!m_mtime10.IsEmpty()&&!m_mprice5.IsEmpty()){
		bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	bufffile<<m_mtype5<<"\n";
	bufffile<<m_meach5<<"\n";
	bufffile<<m_mtime9<<"\n";
	bufffile<<m_mtime10<<"\n";
	bufffile<<m_mprice5<<"\n";
	bufffile<<"noteend\n";
	bufffile.close();
	append(datafile);
		datafile.close();
		copyfile();
	}
	}
	m_chk1=0;
	m_chk2=0;
	m_chk3=0;
	m_chk4=0;
	m_chk5=0;
		UpdateData(FALSE);
//	CDialog::OnOK();
}

BOOL accept::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
		page=0;
	GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);
	GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void accept::change(int j,fstream &datafile)
{
	int i=0;
	CString buff;
	fstream bufffile;
	bufffile.open("d:\\Program Files\\type\\buff.typ",ios::out);
	while(i<j)
	{
		if(datafile.eof())
			return;
		buff=readnote(datafile);
		bufffile<<buff<<"\n";
		if(buff=="notebegin")
		i++;
	}
	bufffile.close();
}

void accept::append(fstream &datafile)
{
	fstream bufffile;
	CString buff;
	bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	buff=readnote(datafile);
 
	while(!datafile.eof())
	{
		bufffile<<readnote(datafile)<<"\n";
	}
	bufffile.close();


}

void accept::copyfile()
{
	fstream bufffile,datafile;
	bufffile.open("d:\\Program Files\\type\\buff.typ",ios::in);
	datafile.open("d:\\Program Files\\type\\type.typ",ios::out);
	while(!bufffile.eof())
	{
		datafile<<readnote(bufffile)<<"\n";
	}
	bufffile.close();
	datafile.close();
}

void accept::changed(int j, fstream &datafile)
{
	int i=0;
	CString buff;
	fstream bufffile;
	bufffile.open("d:\\Program Files\\type\\buff.typ",ios::out);
	while(i<j)
	{
		if(datafile.eof())
			return;
		buff=readnote(datafile);
		if(buff=="notebegin")
		i++;
		if(i<j)
			bufffile<<buff<<"\n";
	}
	bufffile.close();
}

void accept::appendd(fstream &datafile)
{
	fstream bufffile;
	CString buff;
	bufffile.open("d:\\Program Files\\type\\buff.typ",ios::app);
	//buff=readnote(datafile);
 
	while(!datafile.eof())
	{
		bufffile<<readnote(datafile)<<"\n";
	}
	bufffile.close();


}

int accept::compare(CString a, CString b)
{
		int montha,monthb,datea,dateb,buff,last;
	int n,i;
	int yeara=atoi(dateyear(a,1));
	int yearb=atoi(dateyear(b,1));
	datea=atoi(dateyear(a,3));
	dateb=atoi(dateyear(b,3));
	montha=atoi(dateyear(a,2));
	monthb=atoi(dateyear(b,2));
		n=yearb-yeara;
		for(i=0;i<n;i++)
		{
			yeara+=i;
			if(!(yeara%400==0)&&!(yeara%4==0))
				buff+=365;
				else
				buff+=366;
		}
		for(i=1;i<monthb+1;i++)
		{
				if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
				buff+=31;
				if(i==4||i==6||i==9||i==11)
				buff+=30;
				if(i==2)
				{
					if(!(yearb%400==0)&&!(yearb%4==0))
					buff+=29;
					else
					buff+=28;
				}

		}
		buff+=dateb;
		for(i=1;i<montha+1;i++)
		{
				if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
				last+=31;
				if(i==4||i==6||i==9||i==11)
				last+=30;
				if(i==2)
				{
					if(!(yeara%400==0)&&!(yeara%4==0))
					last+=29;
					else
					last+=28;
				}

		}
		last+=datea;
	return buff-last+1;
}

CString accept::dateyear(CString date, int n)
{
	CString buff;
	CString retu;
	int m=date.Find('.');
	if(n==1){
		retu=date.Left(m);
	}
	if(n==2){
		n=date.Find(".",m+1);
		retu=date.Left(n);
		retu=retu.Right(n-m-1);
	}
	if(n==3){
		n=date.Find(".",m+1);
		m=date.GetLength();
		retu=date.Right(m-n-1);
	}
	return retu;
}



void accept::OnChangeEdit2() 
{
	UpdateData(TRUE);
	if(m_meach1.IsEmpty())
		return;
	if(m_mtime1.IsEmpty())
		return;
	if(m_mtime2.IsEmpty())
		return;
	int i=compare(m_mtime1,m_mtime2);
	float n=atof(m_meach1)*i;
	m_mprice1.Format("%.2f",n/100);
	UpdateData(FALSE);	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

void accept::OnChangeEdit5() 
{
UpdateData(TRUE);
	if(m_meach2.IsEmpty())
		return;
	if(m_mtime3.IsEmpty())
		return;
	if(m_mtime4.IsEmpty())
		return;
	int i=compare(m_mtime3,m_mtime4);
	float n=atof(m_meach2)*i;
	m_mprice2.Format("%.2f",n/100);
	UpdateData(FALSE);	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

void accept::OnChangeEdit8() 
{
	UpdateData(TRUE);
	if(m_meach3.IsEmpty())
		return;
	if(m_mtime5.IsEmpty())
		return;
	if(m_mtime6.IsEmpty())
		return;
	int i=compare(m_mtime5,m_mtime6);
	float n=atof(m_meach3)*i;
	m_mprice3.Format("%.2f",n/100);
	UpdateData(FALSE);	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

void accept::OnChangeEdit11() 
{
UpdateData(TRUE);
	if(m_meach4.IsEmpty())
		return;
	if(m_mtime7.IsEmpty())
		return;
	if(m_mtime8.IsEmpty())
		return;
	int i=compare(m_mtime7,m_mtime8);
	float n=atof(m_meach4)*i;
	m_mprice4.Format("%.2f",n/100);
	UpdateData(FALSE);	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

void accept::OnChangeEdit14() 
{
UpdateData(TRUE);
	if(m_meach5.IsEmpty())
		return;
	if(m_mtime9.IsEmpty())
		return;
	if(m_mtime10.IsEmpty())
		return;
	int i=compare(m_mtime9,m_mtime10);
	float n=atof(m_meach5)*i;
	m_mprice5.Format("%.2f",n/100);
	UpdateData(FALSE);	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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