📄 commucationview.cpp
字号:
PhoneDate[Pos]+=temp;
}
void CCommucationView::OnView()
{
// TODO: Add your command handler code here
m_IsView=1;
}
void CCommucationView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// Do not call CFormView::OnPaint() for painting messages
}
HBRUSH CCommucationView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
pDC->SetTextColor(RGB(255,255,0));
HBRUSH m_blue = CBrush(RGB(0,0,255));
// TODO: Change any attributes of the DC here
if ( nCtlColor==CTLCOLOR_STATIC)
{
pDC->SetBkColor(RGB(0,0,255));
return m_blue;
}
if ( nCtlColor==CTLCOLOR_DLG)
{
pDC->SetBkColor(RGB(0,0,255));
return m_blue;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CCommucationView::ProcessData(int Pos)
{
CStdioFile file;
CString str,filename;
filename="Phone.txt";
if(file.Open(filename,CFile::modeRead|CFile::typeText)==0)
{
AfxMessageBox("failure");
}
file.Seek(402,CFile::begin);
file.ReadString(str);
str.TrimLeft();
file.Close();
duty=str;
CString temp;
CDaoTableDef m_OpenTable(&m_pDB);
COleVariant tempFieldValue;
temp="record";
try
{
m_OpenTable.Open(temp);
}
catch(CDaoException* e)
{
DisplayDaoException(e);
e->Delete();
}
CDaoRecordset rs(&m_pDB);
try
{
rs.Open(&m_OpenTable,dbOpenDynaset,dbAppendOnly|dbInconsistent);
}
catch(CDaoException* e)
{
DisplayDaoException(e);
e->Delete();
}
rs.AddNew();
tempFieldValue=COleVariant(SerialNo[Pos],VT_BSTRT);
rs.SetFieldValue("流水号",tempFieldValue);
tempFieldValue=COleVariant(PhoneDate[Pos],VT_BSTRT);
rs.SetFieldValue("日期",tempFieldValue);
temp.Format("%d",Pos+1);
if(temp.GetLength()<2)
{
temp="0"+temp;
}
tempFieldValue=COleVariant(temp,VT_BSTRT);
rs.SetFieldValue("话亭",tempFieldValue);
temp=PhoneNo[Pos];
for(int i=PhoneNo[Pos].GetLength();i<16;i++)
{
temp+="_";
}
tempFieldValue=COleVariant(PhoneNo[Pos],VT_BSTRT);
rs.SetFieldValue("被叫号",tempFieldValue);
tempFieldValue=COleVariant(BeginChat[Pos],VT_BSTRT);
rs.SetFieldValue("起始时间",tempFieldValue);
temp.Format("%d",timetotal[Pos]);
tempFieldValue=COleVariant(temp,VT_BSTRT);
rs.SetFieldValue("通话时间",tempFieldValue);
tempFieldValue=COleVariant(backup[Pos]);
rs.SetFieldValue("总价",tempFieldValue);
tempFieldValue=COleVariant(duty,VT_BSTRT);
rs.SetFieldValue("工号",tempFieldValue);
CString tmpid,username;
filename="C:\\WINDOWS\\SYSTEM\\user.txt";
if(file.Open(filename,CFile::modeReadWrite|CFile::typeText)==0)
{
AfxMessageBox("failure");
}
file.ReadString(str);
while (tmpid!="end")
{
file.ReadString(str);
tmpid=str.Left(3);
if(tmpid==duty)
{
username=str.Mid(13,8);
username.TrimRight("-");
break;
}
}
file.Close();
tempFieldValue=COleVariant(username,VT_BSTRT);
rs.SetFieldValue("姓名",tempFieldValue);
temp.Format("%d",iLevel[Pos]);
tempFieldValue=COleVariant(temp,VT_BSTRT);
rs.SetFieldValue("统计级",tempFieldValue);
tempFieldValue=COleVariant(PhonePrice[Pos],VT_BSTRT);
rs.SetFieldValue("话价",tempFieldValue);
temp.Format("%5.2f",AddFee[Pos]);
tempFieldValue=COleVariant(temp,VT_BSTRT);
rs.SetFieldValue("附加费",tempFieldValue);
tempFieldValue=COleVariant("1",VT_BSTRT);
rs.SetFieldValue("flag",tempFieldValue);
try
{
rs.Update();
}
catch(CDaoException* e)
{
DisplayDaoException(e);
e->Delete();
}
if(rs.IsOpen())
rs.Close();
if(m_OpenTable.IsOpen())
m_OpenTable.Close();
}
//查找号码对应的费率级
CString CCommucationView::GetLevel(CString PhoneCode)
{
BOOL found;
int current;
int resultCompare;
CString tempCode,compareCode;
int start,end;
CString Result,tempResult;
for(int i=11;i>=1;i--)
{
start=1;
end =CodeAmount;
found=false;
tempCode=PhoneCode.Left(i);
while((!found)&&(start<=end))
{
current=(start+end)/2;
compareCode=code[current].Left(11);
compareCode.TrimRight('-');
resultCompare=tempCode.Compare(compareCode);
if(resultCompare==0)
{
Result=code[current].Mid(11,2);
found=true;
}
else if(resultCompare>0)
{
start=current+1;
}
else
{
end=current-1;
}
}
if(found)
{
break;
}
else
{
if(i==11)
tempResult=code[current].Mid(11,2);
}
}
if(!found)
Result=tempResult;
return(Result);
}
//根据电话号码查出对应的费率
COST CCommucationView::GetFeeInfo(CString PhoneNo)
{
// TODO: Add your control notification handler code here
CString CodeLevel;//号码费率级
COST t_Fee;
int current;
int resultCompare;
int start,end;
BOOL found;
CStdioFile file;
CString filename,str,tempstr;
//查费率级
CodeLevel=GetLevel(PhoneNo);
// SetDlgItemText(IDC_TELE_5,CodeLevel);
//取费率级的在费率表中的位置
start=1;
end =FeeAmount;
found=false;
while((!found)&&(start<=end))
{
current=(start+end)/2;
resultCompare=CodeLevel.Compare(Fee[current]);
if(resultCompare==0)
{
found=true;
}
else if(resultCompare>0)
{
start=current+1;
}
else
{
end=current-1;
}
}
//取出查找到的费率级的数据并赋给结构t_Fee
filename="fee.txt";
if(file.Open(filename,CFile::modeRead|CFile::typeText)==0)
{
AfxMessageBox("failure");
}
file.Seek(52*(current-1),CFile::begin);
file.ReadString(str);
file.Close();
tempstr=str.Mid(2,4);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.unitprice1);
tempstr=str.Mid(6,3);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.unittime1);
tempstr=str.Mid(9,1);
sscanf(tempstr,"%d",&t_Fee.time1);
tempstr=str.Mid(10,4);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.surcharge1);
if(t_Fee.time1!=0)
{
tempstr=str.Mid(14,4);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.unitprice2);
tempstr=str.Mid(18,3);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.unittime2);
tempstr=str.Mid(21,1);
sscanf(tempstr,"%d",&t_Fee.time2);
tempstr=str.Mid(22,4);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.surcharge2);
if(t_Fee.time2!=0)
{
tempstr=str.Mid(26,4);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.unitprice3);
tempstr=str.Mid(30,3);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.unittime3);
tempstr=str.Mid(33,1);
sscanf(tempstr,"%d",&t_Fee.time3);
tempstr=str.Mid(34,4);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.surcharge3);
}
}
tempstr=str.Mid(38,4);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.billcharge);
tempstr=str.Mid(42,3);
tempstr.TrimRight('-');
sscanf(tempstr,"%d",&t_Fee.percharge);
tempstr=str.Mid(45,1);
sscanf(tempstr,"%d",&t_Fee.countlevel);
tempstr=str.Mid(46,2);
sscanf(tempstr,"%x",&t_Fee.location);
tempstr=str.Mid(48,1);
sscanf(tempstr,"%d",&t_Fee.IsPrint);
tempstr=str.Mid(49,1);
sscanf(tempstr,"%d",&t_Fee.ip);
return(t_Fee);
}
//查询折扣率
int CCommucationView::GetDiscount(CTime StartTime, int Location,int IsIp)
{
int CurYear=StartTime.GetYear();
int CurMonth=StartTime.GetMonth();
int CurDay=StartTime.GetDay();
int CurHour=StartTime.GetHour();
int DatePos,SearchPos;
CStdioFile file;
CString filename;
char a[2];
filename="10Y-Tab.txt";
if(file.Open(filename,CFile::modeRead|CFile::typeText)==0)
{
AfxMessageBox("failure");
}
DatePos=((CurYear%10*12+CurMonth-1)*34+CurDay);
file.Seek(DatePos,CFile::begin);
file.Read(a,1);
//
YearPos=a[0];
//
file.Close();
SearchPos=Location&a[0];
filename="Day-Tab.txt";
if(file.Open(filename,CFile::modeRead|CFile::typeText)==0)
{
AfxMessageBox("failure");
}
file.Seek(CurHour,CFile::begin);
file.Read(a,1);
//
DayPos=a[0];
//
SearchPos=SearchPos&a[0];
//
AndTotal=SearchPos;
//
// CString bb;
// bb.Format("%d",SearchPos);
// SetDlgItemText(IDC_TELE_5,bb);
if(IsIp)
{
file.Seek(SearchPos*2+164,CFile::begin);
}
else
{
file.Seek(SearchPos*2+34,CFile::begin);
}
file.Read(a,2);
// SetDlgItemText(IDC_TELE_5,a);
file.Close();
a[0]-=48;
a[1]-=48;
//
RateNum=a[0]*10+a[1];
//
// int x=a[0];
// CString y;
// y.Format("%d",x);
if((a[0]==0)&&(a[1]==0))
return(100);
else
return(a[0]*10+a[1]);
}
//处理发出的各条命令
void CCommucationView::SignalProcess(int SignalCode)
{
if(info.Mid(43*SignalCode,2)=="00")
{
SendStr[SendLen]='A';
SendStr[SendLen+1]='T';
SendStr[SendLen+2]='O';
SendStr[SendLen+3]=48+SignalCode;
SendStr[SendLen+4]='\r';
SendLen+=5;
}
else if(info.Mid(43*SignalCode,2)=="01")
{
SendStr[SendLen]='A';
SendStr[SendLen+1]='T';
SendStr[SendLen+2]='C';
SendStr[SendLen+3]=48+SignalCode;
SendStr[SendLen+4]='\r';
SendLen+=5;
}
else if(info.Mid(43*SignalCode,2)=="43")
{
CSelectDialog m_Dlg;
if(m_Dlg.DoModal()==IDOK)
{
if(m_Dlg.m_Select==0)
{
SendStr[SendLen]='A';
SendStr[SendLen+1]='T';
SendStr[SendLen+2]='Q';
SendStr[SendLen+3]=48+SignalCode;
SendStr[SendLen+4]='\r';
SendLen+=5;
m_Force[SignalCode]=TRUE;
}
else
{
SendStr[SendLen]='A';
SendStr[SendLen+1]='T';
SendStr[SendLen+2]='C';
SendStr[SendLen+3]=48+SignalCode;
SendStr[SendLen+4]='\r';
SendLen+=5;
}
}
}
else if(info.Mid(43*SignalCode,2)=="63")
{
CWarnDialog m_Dlg;
if(m_Dlg.DoModal()==IDOK)
{
SendStr[SendLen]='A';
SendStr[SendLen+1]='T';
SendStr[SendLen+2]='C';
SendStr[SendLen+3]=48+SignalCode;
SendStr[SendLen+4]='\r';
SendLen+=5;
}
}
}
void CCommucationView::ProcessTotal(int Pos)
{
int StartTime;
StartTime=1;
while(StartTime<=timetotal[Pos])
{
if((m_Data[Pos].time1==0)||((StartTime-1)<time1[Pos]))
{
int pos=GetDiscount(BeginTime[Pos]+timetotal[Pos],m_Data[Pos].location,m_Data[Pos].ip);
if(m_Data[Pos].surcharge1!=0)
{
intValue=m_Data[Pos].unitprice1*pos/100+m_Data[Pos].surcharge1;
backup[Pos]+=(float)intValue/100;
}
else
{
intValue=m_Data[Pos].unitprice1*pos/100;
backup[Pos]+=(float)intValue/100;
}
accumulator[Pos]+=1;
accumulate[Pos]+=1;
StartTime+=m_Data[Pos].unittime1;
}
else if((m_Data[Pos].time2==0)||((StartTime-1)<time2[Pos]))
{
int pos=GetDiscount(BeginTime[Pos]+timetotal[Pos],m_Data[Pos].location,m_Data[Pos].ip);
if(m_Data[Pos].surcharge2!=0)
{
intValue=m_Data[Pos].unitprice2*pos/100+m_Data[Pos].surcharge2;
backup[Pos]+=(float)intValue/100;
}
else
{
intValue=m_Data[Pos].unitprice2*pos/100;
backup[Pos]+=(float)intValue/100;
}
accumulator[Pos]+=1;
accumulate[Pos]+=1;
StartTime+=m_Data[Pos].unittime2;
}
else
{
int pos=GetDiscount(BeginTime[Pos]+timetotal[Pos],m_Data[Pos].location,m_Data[Pos].ip);
if(m_Data[Pos].surcharge3!=0)
{
intValue=m_Data[Pos].unitprice3*pos/100+m_Data[Pos].surcharge3;
backup[Pos]+=(float)intValue/100;
}
else
{
intValue=m_Data[Pos].unitprice3*pos/100;
backup[Pos]+=(float)intValue/100;
}
accumulator[Pos]+=1;
accumulate[Pos]+=1;
StartTime+=m_Data[Pos].unittime3;
}
}
}
void CCommucationView::OnViewInfo()
{
// TODO: Add your command handler code here
CSear
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -