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

📄 commucationview.cpp

📁 一个可以控制单片机根据通话时间和所拨地区进行计费的软件!
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	str.Format("余额:%6.2f元",m_Money[4]);
	m_Dlg.m_sta5=str;
	str.Format("余额:%6.2f元",m_Money[5]);
	m_Dlg.m_sta6=str;
	str.Format("余额:%6.2f元",m_Money[6]);
	m_Dlg.m_sta7=str;
	str.Format("余额:%6.2f元",m_Money[7]);
	m_Dlg.m_sta8=str;
	str.Format("余额:%6.2f元",m_Money[8]);
	m_Dlg.m_sta9=str;
	str.Format("余额:%6.2f元",m_Money[9]);
	m_Dlg.m_sta10=str;
	str.Format("余额:%6.2f元",m_Money[10]);
	m_Dlg.m_sta11=str;
	str.Format("余额:%6.2f元",m_Money[11]);
	m_Dlg.m_sta12=str;
	str.Format("余额:%6.2f元",m_Money[12]);
	m_Dlg.m_sta13=str;
	str.Format("余额:%6.2f元",m_Money[13]);
	m_Dlg.m_sta14=str;
	str.Format("余额:%6.2f元",m_Money[14]);
	m_Dlg.m_sta15=str;
	str.Format("余额:%6.2f元",m_Money[15]);
	m_Dlg.m_sta16=str;
	file.Close();
	if(m_Dlg.DoModal()==IDOK)
	{
		if(file.Open(filename,CFile::modeReadWrite|CFile::typeText)==0)
		{
			AfxMessageBox("failure");
		}
		
		if(m_Dlg.m_Room1==TRUE)
		{
			m_Money[0]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[0]);
			file.Seek(258,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room2==TRUE)
		{
			m_Money[1]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[1]);
			file.Seek(267,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room3==TRUE)
		{
			m_Money[2]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[2]);
			file.Seek(276,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room4==TRUE)
		{
			m_Money[3]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[3]);
			file.Seek(285,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room5==TRUE)
		{
			m_Money[4]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[4]);
			file.Seek(294,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room6==TRUE)
		{
			m_Money[5]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[5]);
			file.Seek(303,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room7==TRUE)
		{
			m_Money[6]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[6]);
			file.Seek(312,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room8==TRUE)
		{
			m_Money[7]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[7]);
			file.Seek(321,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room9==TRUE)
		{
			m_Money[8]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[8]);
			file.Seek(330,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room10==TRUE)
		{
			m_Money[9]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[9]);
			file.Seek(339,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room11==TRUE)
		{
			m_Money[10]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[10]);
			file.Seek(348,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room12==TRUE)
		{
			m_Money[11]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[11]);
			file.Seek(357,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room13==TRUE)
		{
			m_Money[12]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[12]);
			file.Seek(366,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room14==TRUE)
		{
			m_Money[13]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[13]);
			file.Seek(375,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room15==TRUE)
		{
			m_Money[14]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[14]);
			file.Seek(384,CFile::begin);
			file.Write(str,7);
		}
		if(m_Dlg.m_Room16==TRUE)
		{
			m_Money[15]=m_Dlg.m_Money;
			str.Format("%7.2f",m_Money[15]);
			file.Seek(393,CFile::begin);
			file.Write(str,7);
		}
		file.Close();
	}
	
}

void CCommucationView::OnButton16() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(15);
	}
}

int CCommucationView::GetSpendTime(UINT m_Number)
{
	int time;
	int tempTime;
	sscanf(info.Mid(m_Number*43+27,2),"%x",&tempTime);
	time=tempTime*100;
	sscanf(info.Mid(m_Number*43+30,2),"%d",&tempTime);
	time+=tempTime;
	return(time);
}

void CCommucationView::OnButton5() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(4);
	}
}

void CCommucationView::OnButton6() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(5);
	}
}

void CCommucationView::OnButton7() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(6);
	}
}

void CCommucationView::OnButton8() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(7);
	}
}

void CCommucationView::OnButton9() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(8);
	}
}

void CCommucationView::OnButton10() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(9);
	}
}

void CCommucationView::OnButton11() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(10);
	}
}

void CCommucationView::OnButton12() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(11);
	}
}

void CCommucationView::OnButton13() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(12);
	}
}

void CCommucationView::OnButton14() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(13);
	}
}

void CCommucationView::OnButton15() 
{
	// TODO: Add your control notification handler code here
	if(info.GetLength()==690)
	{
		SignalProcess(14);
	}
}

void CCommucationView::OnReportPrint() 
{
	// TODO: Add your command handler code here
	m_Report=1;

	int i,j;
	CString str,temp,tmp,title[7];
	int number,adder;
	CReportDialog dlg;
    CStdioFile file;
    CString filename;
    filename="Phone.txt";
    if(file.Open(filename,CFile::modeRead|CFile::typeText)==0)
	{
    	AfxMessageBox("failure");
	}
	int count;
	float total;
	float addtion;
	//打印日期
	CTime system=CTime::GetCurrentTime();
	tmp=system.Format("%B %d,%Y    %H:%M:%S");
	//打印流水号

	int Serial1,Serial2;
	file.Seek(245,CFile::begin);
	file.ReadString(str);
	sscanf(str.Left(6),"%d",&Serial1);
	sscanf(str.Mid(7,4),"%d",&Serial2);
	Serial1=Serial1-Serial2+1;
	temp.Format("%d",Serial1);
	number=6-temp.GetLength();
	for(i=0;i<number;i++)
	{
	    temp="0"+temp;
	}
    str=tmp+"              流水号:  "+temp+"——"+str.Left(6);
    dlg.m_Report1=str;
	
	//打印行标题
	//   地区码                  次数        通话时间        附加费         总价
	title[0]="********国际    :     ";
	title[1]="********香港    :     ";
	title[2]="********澳门    :     ";
	title[3]="********台湾    :     ";
	title[4]="********长途    :     ";
	title[5]="********市内    :     ";
	title[6]="********小区    :     ";
	
	//
	CString final;
	count=0;
	total=0;
	for(i=0;i<7;i++)
	{
		file.Seek(35*i,CFile::begin);
		file.ReadString(str);
		sscanf(str.Left(4),"%d",&adder);
		count+=adder;
		sscanf(str.Mid(5,8),"%d",&adder);
		adder=adder/60;
		temp.Format("%d",adder);
		number=6-temp.GetLength();
		for(j=0;j<number;j++)
		{
			temp="0"+temp;
		}
		final=str.Left(4)+"              "+temp+"                 ";
		final=final+str.Mid(14,9)+"              "+str.Mid(24,9);
		title[i]=title[i]+final;
		sscanf(str.Mid(24,9),"%f",&addtion);
		total+=addtion;
	}
	dlg.m_Report3=title[0];
	dlg.m_Report4=title[1];
	dlg.m_Report5=title[2];
	dlg.m_Report6=title[3];
	dlg.m_Report7=title[4];
	dlg.m_Report8=title[5];
	dlg.m_Report9=title[6];

	temp.Format("%d",count);
	number=4-temp.GetLength();
	for(j=0;j<number;j++)
	{
		temp="0"+temp;
	}
	
	tmp.Format("%9.2f",total);
	tmp.TrimLeft();
	number=9-tmp.GetLength();
	for(j=0;j<number;j++)
	{
		tmp="0"+tmp;
	}
	str="********总计    :     "+temp+"					              "+tmp;
	dlg.m_Report10=str;

	file.Close();
	if(count!=0)
	{
		if(dlg.DoModal()==IDOK)
		{
			OnFilePrint();
		}
	}
	else
	{
		AfxMessageBox("目前还没有通话记录!");
	}
}

void CCommucationView::OnUpdateReportPrint(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
//	pCmdUI->Enable(!m_Report);
}

//记录通话信息,生成统计报表
void CCommucationView::ProcessFile(int Pos)
{
	CStdioFile file;
	CString str,temp;
	CString result;//修改后的行信息
	CString filename;
	int adder;
	int number;//需要加0的个数
	float addtion;//需增加的费用

	filename="Phone.txt";
	if(file.Open(filename,CFile::modeReadWrite|CFile::typeText)==0)
	{
		AfxMessageBox("failure");
	}
	//取出需要修改的统计级位置
	LevelPos=iLevel[Pos]-1;
	file.Seek(35*LevelPos,CFile::begin);
	file.ReadString(str);

	//将原先的通话次数加1
	sscanf(str.Left(4),"%d",&adder);
	adder+=1;
	temp.Format("%d",adder);
	//
	number=4-temp.GetLength();
	for(m=0;m<number;m++)
	{
		temp="0"+temp;
	}
	result=temp;

	//存取时间
	sscanf(str.Mid(5,8),"%d",&adder);
	adder+=timetotal[Pos];
	temp.Format("%d",adder);
	//
	number=8-temp.GetLength();
	for(m=0;m<number;m++)
	{
		temp="0"+temp;
	}
	result=result+" "+temp;

	//存取附加费
	sscanf(str.Mid(14,9),"%f",&addtion);
	addtion+=AddFee[Pos];
	temp.Format("%9.2f",addtion);
	temp.TrimLeft();
	//
	number=9-temp.GetLength();
	for(m=0;m<number;m++)
	{
		temp="0"+temp;
	}
	result=result+" "+temp;

	//存取总价
	sscanf(str.Mid(24,9),"%f",&addtion);
	addtion+=backup[Pos];
	temp.Format("%9.2f",addtion);
	temp.TrimLeft();
	//
	number=9-temp.GetLength();
	for(m=0;m<number;m++)
	{
		temp="0"+temp;
	}
	result=result+" "+temp;
	//将修改后的行写入文件
	file.Seek(35*LevelPos,CFile::begin);
	file.Write(result,33);
	//保存押金
    str.Format("%7.2f",m_Money[Pos]);
   	file.Seek(258+9*Pos,CFile::begin);
   	file.Write(str,7);

	//处理流水号
	file.Seek(245,CFile::begin);
	file.ReadString(str);
   	sscanf(str.Left(6),"%d",&adder);
   	adder+=1;
   	temp.Format("%d",adder);
	//
   	number=6-temp.GetLength();
   	for(int i=0;i<number;i++)
	{
    	temp="0"+temp;
	}
   	sscanf(str.Right(4),"%d",&adder);
   	adder+=1;
   	str.Format("%d",adder);
	//
	number=4-str.GetLength();
   	for(i=0;i<number;i++)
	{
    	str="0"+str;
	}
   	str=temp+":"+str;
	file.Seek(245,CFile::begin);
	file.Write(str,11);
	file.Close();
	//赋流水号
	SerialNo[Pos]=str;
	//赋单价
	if(m_Data[Pos].time1==0)
	{
    	str.Format("%5.2f",(float)m_Data[Pos].unitprice1/100);
    	temp.Format("%3d",m_Data[Pos].unittime1);
	}
    else if(m_Data[Pos].time2==0)
	{
	    str.Format("%5.2f",(float)m_Data[Pos].unitprice2/100);
	    temp.Format("%3d",m_Data[Pos].unittime2);
	}
    else
	{
	    str.Format("%5.2f",(float)m_Data[Pos].unitprice3/100);
	    temp.Format("%3d",m_Data[Pos].unittime3);
	}
	PhonePrice[Pos]=str+temp;
	//赋日期
	CTime t=CTime::GetCurrentTime();
	int tYear=t.GetYear();
	int tMonth=t.GetMonth();
	int tDay=t.GetDay();
	PhoneDate[Pos].Format("%d",tYear);
	PhoneDate[Pos]+="/";
	temp.Format("%2d",tMonth);
	PhoneDate[Pos]+=temp;
	PhoneDate[Pos]+="/";
	temp.Format("%2d",tDay);

⌨️ 快捷键说明

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