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

📄 ipcountdlg.cpp

📁 IP电话计费管理系统本地版
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		{
		case 1:
			
			m_BLogin.EnableWindow(FALSE);
			m_BModPswd.EnableWindow(FALSE);
			m_BMang.EnableWindow(FALSE);
			m_BStatics.EnableWindow(FALSE);
			m_BTitle.EnableWindow(FALSE);
			m_BRate.EnableWindow(FALSE);
			m_BSetUp.EnableWindow(FALSE);
			break;
		case 2:
			m_BTitle.EnableWindow(FALSE);
			m_BLogin.EnableWindow(FALSE);
			m_BRate.EnableWindow(FALSE);
			m_BMang.EnableWindow(FALSE);
			m_BStatics.EnableWindow(FALSE);
			m_BModPswd.EnableWindow(FALSE);
			m_BSetUp.EnableWindow(FALSE);
			break;
		default:
			break;
		}
	}
	
    set.Close();
}

void CIPCountDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
/*	for (int i=0; i<16; i++)
	{
		if (sdlg->m_SaleGrid.GetTextMatrix(i, 2).GetLength()<3)
		{
            sdlg->m_SaleGrid.SetTextMatrix(i, 2, "");
			sdlg->m_SaleGrid.SetTextMatrix(i, 1, "空闲");
		}
	}
*/
	CDialog::OnTimer(nIDEvent);
}



void CIPCountDlg::AddToDb(int nLineNum)
{
	CIPCountReCordSet m_pSet(&m_database);
	//获得文件的当前路径
	TCHAR pFileName[MAX_PATH];
	GetModuleFileName(NULL,pFileName,MAX_PATH);
	if(strchr(pFileName,'\\'))
		*strrchr(pFileName,'\\')='\0';
    strcat(pFileName,"\\IPCount.mdb");
    CString strChar="";
	try
	{
		CString  sDSN="ODBC;DRIVER=Microsoft Access Driver (*.mdb);DSN='';DBQ="+strChar+pFileName+strChar;
        if(!m_database.IsOpen())
		{
			if(!m_database.Open(NULL,FALSE,FALSE,sDSN,FALSE))//打开数据库是否成功
			{
				CDialog::EndDialog(0);
				GetParent()->PostMessage(WM_CLOSE);
			}
		}
        CString strSQL="select * from huafei";
		
		m_pSet.Open(CIPCountReCordSet::dynaset,strSQL);//打开数据表是否成功
	}
	
	catch(CDBException* pEx)//丢出异常处理
	{
		pEx->ReportError();
		m_pSet.Close();
		m_database.Close();
        pEx->Delete();
	} 
	
	if(m_pSet.CanAppend())//是否能过添加或修改
	{ 
		m_pSet.AddNew();
		m_pSet.m_Line=m_RecodeInfo[nLineNum].m_Line;//v12.03.08
		m_pSet.m_CalledNum=m_RecodeInfo[nLineNum].m_CalledNum;
		m_pSet.m_RDay=m_RecodeInfo[nLineNum].m_CDay;
		m_pSet.m_RTLen=m_RecodeInfo[nLineNum].m_RTLen;
		if(m_pSet.m_RTLen.IsEmpty())
            m_pSet.m_RTLen="00:00:01";//修改没读到时长时,写数据库为空
		m_pSet.m_Rate=m_RecodeInfo[nLineNum].m_Rate;
		m_pSet.m_RCount=m_RecodeInfo[nLineNum].m_RCount;
		m_pSet.m_StreamNum=strStreamNum[nLineNum];
		m_pSet.m_RAreaName=strAreaName[nLineNum];
		m_pSet.m_COper=sdlg->m_strCName;
		m_pSet.m_ORate=sdlg->strTotalORate[nLineNum];
		m_pSet.Update();
	}
	m_pSet.Close();
	//增加显示当班话费和当日话费
	
	if(nPrintAtOnce)	//添加立即打印代码
	{
		char szSaveInfo[30];
		memset(szSaveInfo,0,30);
		CFile pFile;
		//获得文件的当前路径
		TCHAR pFileName[MAX_PATH];
		GetModuleFileName(NULL,pFileName,MAX_PATH);
		if(strchr(pFileName,'\\'))
			*strrchr(pFileName,'\\')='\0';
		strcat(pFileName,"\\PrintSet.DAT");
		if (pFile.Open(pFileName, CFile::modeRead))
		{
			pFile.Read(szSaveInfo,30);
			pFile.Close();
		}
		
		int nRow=0;
		sdlg->m_HideGrid1.SetTextMatrix(nRow,0,szSaveInfo);
		sdlg->m_HideGrid1.SetTextMatrix(nRow,1,"");
		sdlg->m_HideGrid1.SetTextMatrix(nRow,2,strAreaName[nLineNum]);//区名
		if(nPrintMode==0)//单联打印
		{
			sdlg->m_HideGrid1.SetTextMatrix(nRow,4,szSaveInfo);
			sdlg->m_HideGrid1.SetTextMatrix(nRow,5,"");
			sdlg->m_HideGrid1.SetTextMatrix(nRow,6,strAreaName[nLineNum]);   
		}
		
		CString strDate="";
		CString strStartTime="";
		CString strTempTime=sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,3);
		int nFindSpace=-1;
		nFindSpace=strTempTime.Find(' ',0);
		if(nFindSpace!=-1)
		{
			strDate=strTempTime.Mid(0,nFindSpace);
			strStartTime=strTempTime.Mid(nFindSpace+1);
		}
		sdlg->m_HideGrid1.SetTextMatrix(nRow+1,0,strStreamNum[nLineNum]);//流水号
		sdlg->m_HideGrid1.SetTextMatrix(nRow+1,1,"");
		sdlg->m_HideGrid1.SetTextMatrix(nRow+1,2,strDate);//日期
		
		if(nPrintMode==0)
		{
			sdlg->m_HideGrid1.SetTextMatrix(nRow+1,4,strStreamNum[nLineNum]);
			sdlg->m_HideGrid1.SetTextMatrix(nRow+1,5,"");
			sdlg->m_HideGrid1.SetTextMatrix(nRow+1,6,strDate);
		}
		
		sdlg->m_HideGrid1.SetTextMatrix(nRow+2,0,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,2));//被叫号
		sdlg->m_HideGrid1.SetTextMatrix(nRow+2,1,"线号:");
		sdlg->m_HideGrid1.SetTextMatrix(nRow+2,2,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,0));
		if(nPrintMode==0)
		{
			sdlg->m_HideGrid1.SetTextMatrix(nRow+2,4,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,2));
			sdlg->m_HideGrid1.SetTextMatrix(nRow+2,5,"线号:");
			sdlg->m_HideGrid1.SetTextMatrix(nRow+2,6,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,0));
		}
		
		sdlg->m_HideGrid1.SetTextMatrix(nRow+3,0,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,6));//话费
		sdlg->m_HideGrid1.SetTextMatrix(nRow+3,1,"");
		sdlg->m_HideGrid1.SetTextMatrix(nRow+3,2,sdlg->strTotalORate[nLineNum]);//附加费
		if(nPrintMode==0)
		{
			sdlg->m_HideGrid1.SetTextMatrix(nRow+3,4,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,6));
			sdlg->m_HideGrid1.SetTextMatrix(nRow+3,5,"");
			sdlg->m_HideGrid1.SetTextMatrix(nRow+3,6,sdlg->strTotalORate[nLineNum]);
		}
		
		sdlg->m_HideGrid1.SetTextMatrix(nRow+4,0,strDate);
		sdlg->m_HideGrid1.SetTextMatrix(nRow+4,1,"");
		sdlg->m_HideGrid1.SetTextMatrix(nRow+4,2,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,4));//时长
		if(nPrintMode==0)
		{
			sdlg->m_HideGrid1.SetTextMatrix(nRow+4,4,strStartTime);
			sdlg->m_HideGrid1.SetTextMatrix(nRow+4,5,"");
			sdlg->m_HideGrid1.SetTextMatrix(nRow+4,6,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,4));
		}
		
		sdlg->m_HideGrid1.SetTextMatrix(nRow+5,0,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,5));//费率
		sdlg->m_HideGrid1.SetTextMatrix(nRow+5,1,"");
		sdlg->m_HideGrid1.SetTextMatrix(nRow+5,2,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,6));//总计
		if(nPrintMode==0)
		{
			sdlg->m_HideGrid1.SetTextMatrix(nRow+5,4,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,5));
			sdlg->m_HideGrid1.SetTextMatrix(nRow+5,5,"");
			sdlg->m_HideGrid1.SetTextMatrix(nRow+5,6,sdlg->m_SaleGrid.GetTextMatrix(nLineNum+1,6));
		}
		mdlg->ReadFromFile();//从文件读取打印设置信息
		PrintAtOnce();
		
	}
	
	AddToTemp(nLineNum);
	ShowCInfo();
}


//未计到小时


CString CIPCountDlg::ConvTimeToMin(CString strSecond,int nOperLine)
{
     int nSecond[16];
	 int nMin[16];	 
	 int nHour[16];
//	 for(int k=0;k<16;k++)
//	 {
		 nSecond[nOperLine]=0;
		 nMin[nOperLine]=0;
		 nHour[nOperLine]=0;
//	 }//03-31
	 
	 nSecond[nOperLine]=atoi(strSecond);
	 div_t Result,nResult;
	 Result=div(nSecond[nOperLine],60);//保持跳动60下
	 nMin[nOperLine]=Result.quot;
     nSecond[nOperLine]=Result.rem;

	 if(nMin[nOperLine]>60)
	 {
         nResult=div(nMin[nOperLine],60);
		 nHour[nOperLine]=nResult.quot;
		 nMin[nOperLine]=nResult.rem;
	 }

	 CString strMin[16];
	 CString strHour[16];
	 CString strTempSecond[16];
	 strHour[nOperLine].Format("%d",nHour[nOperLine]);
	 strMin[nOperLine].Format("%d",nMin[nOperLine]);
	 strTempSecond[nOperLine].Format("%d",nSecond[nOperLine]);
	 if(nSecond[nOperLine]<10)
		 strTempSecond[nOperLine]='0'+strTempSecond[nOperLine];
	 if(nMin[nOperLine]<10)
		 strMin[nOperLine]='0'+strMin[nOperLine];
	 if(nHour[nOperLine]<10)
		 strHour[nOperLine]='0'+strHour[nOperLine];
	 strHour[nOperLine]=strHour[nOperLine]+":"+strMin[nOperLine]+":"+strTempSecond[nOperLine];

     //如果起计时长为6秒,进入六秒计费函数
	 int nStartSecondLen=atof(sdlg->strStartTLen[nOperLine])*OneSecondOfMin;
	 
	 if(nStartSecondLen<7)
	 {
         div_t nRem;
         nRem = div(nSecond[nOperLine],nStartSecondLen);
		 if(nRem.rem == 0)
             sdlg->CountMoney(nOperLine);
	 }
	 else if (nStartSecondLen >= OneSecondOfMin)
	 {
		 if(nSecond[nOperLine]==1)
		 {
			 //时间分钟跳动一次
			 if((sdlg->nCountMoneyTimes[sdlg->nCountFlag]==1)&&(nMin[nOperLine]==0)&&(nHour[nOperLine]==0))
				 return strHour[nOperLine];
			 sdlg->CountMoney(nOperLine);
		 }
	 }

    return strHour[nOperLine];
}

void CIPCountDlg::DealReboot(int nCom)
{
    int n=0;
    //下面的代码实现初始化时启动deb cdr
	int nReturn = -1;
	if (nCom == nGwCom[0])
		nReturn = m_strRXData[0].Find(':',0);
	else
	    nReturn =m_strRXData[1].Find(':',0);

	if(nReturn!=-1)
	{
		if (nCom == nGwCom[0])
		    m_strRXData2=m_strRXData[0].Right(7);
		else
            m_strRXData2=m_strRXData[1].Right(7);

		m_strRXData2=m_strRXData2.Mid(1,5);

		
		if(strcmp(m_strRXData2,"Login")==0)
		{
			bReboot=TRUE;
            
			SendData("admin",nCom);
			SendData("admin",nCom);//记得改回密码
			SendData("con",nCom);
			SendData("admin",nCom);
			SendData("deb cdr",nCom);
            SendData("deb line",nCom);
            SendData("line",nCom);
            SendData("bil",nCom);
			SendData("exit",nCom);
			
			m_strRXData[0]="";
			return;
		}
        //SendData("0d",nCom);

		if (nCom == nGwCom[0])
		    m_strRXData1=m_strRXData[0].Mid(5,8);
		else
			 m_strRXData1 = m_strRXData[1].Mid(5,8);

		
        if(strcmp(m_strRXData1,"Passwo")==0)
		{
			SendData("0d",nCom);
			if (nCom == nGwCom[0])
                m_strRXData[0]="";
			else
				m_strRXData[1]="";
			return;
		}

	}
	if(bReboot)
	{
		bReboot=FALSE;
		// nBCount=1;//v12.03.04 去掉退回sinovoip>目录时发一线锁机全锁的bugs
		// nDCount=1;
		if(bOpenSale)//将所有状态恢复到锁机状态
		{
			int nMin;
            int nMax;
			if(nCom == nGwCom[1])
			{
				nMin=8;
				nMax=16;
			}
			else if (nCom == nGwCom[0])
			{
				nMin=0;
				nMax=8;
			}
            for(int j=nMin;j<nMax;j++)
			{
				bClosedLine[j]=TRUE;
				
				if(strcmp(sdlg->m_SaleGrid.GetTextMatrix(j+1,9),"关")!=0)
				{
					//如果线路不是空闲,则不锁机
					if(nFlagLine[j]==0)
					{
						nFlagLine[j]=7;
						sdlg->nCountClk[j]++;
						sdlg->m_SaleGrid.SetTextMatrix(j+1,9,"关");
						sdlg->m_SaleGrid.SetTextMatrix(j+1,1,"锁定");
						ShowLineColor(j,RGB(255,0,0));//显示红颜色			
					}
				}
				else
				{
					bTalking[j]=FALSE;
				}
				
			}
            SendCommand("bil", "line", nCom);
		}
		return;
	}
	
}



void CIPCountDlg::SendData(CString strSend,int nCom)
{
	CByteArray hexdata;
	String2Hex("0d",hexdata);

	if (nCom == nGwCom[0])//网关一
	{
		if(strcmp(strSend,"0d")==0)
		{
			m_ctrlComm.SetOutput(COleVariant(hexdata));
			return;
		}
		
		m_ctrlComm.SetOutput(COleVariant(strSend));//发送ASCII字符数据
		m_ctrlComm.SetOutput(COleVariant(hexdata));
		
	}

	if (nCom == nGwCom[1])//网关二
	{
		if(strcmp(strSend,"0d")==0)
		{
			m_ctrlComm2.SetOutput(COleVariant(hexdata));
			return;
		}
		
		m_ctrlComm2.SetOutput(COleVariant(strSend));//发送ASCII字符数据
		m_ctrlComm2.SetOutput(COleVariant(hexdata));
		
	}
}

int CIPCountDlg::String2Hex(CString str, CByteArray &senddata)
{
	int hexdata,lowhexdata;
	int hexdatalen=0;
	int len=str.GetLength();
	senddata.SetSize(len/2);
	for(int i=0;i<len;)
	{
		char lstr,hstr=str[i];
		if(hstr==' ')
		{
			i++;
			continue;
		}
		i++;
		if(i>=len)
			break;
		lstr=str[i];
		hexdata=ConvertHexChar(hstr);
		lowhexdata=ConvertHexChar(lstr);
		if((hexdata==16)||(lowhexdata==16))
			break;
		else 
			hexdata=hexdata*16+lowhexdata;
		i++;
		senddata[hexdatalen]=(char)hexdata;
		hexdatalen++;
	}
	senddata.SetSize(hexdatalen);
	return hexdatalen;
}

char CIPCountDlg::ConvertHexChar(char ch)
{
	if((ch>='0')&&(ch<='9'))
		return ch-0x30;
	else if((ch>='A')&&(ch<='F'))
		return ch-'A'+10;
	else if((ch>='a')&&(ch<='f'))
		return ch-'a'+10;
	else 
		return (-1);
}

//需仔细做下面的函数
void CIPCountDlg::ShutDownLine(int nSLine)
{
	CString sLine = "";
	if (nSLine < 8)
	{
        sLine.Format("Line %d", nSLine);
        SendCommand("cutoff", sLine, nGwCom[0]);
	}
	else if (nSLine < 16)
	{
        sLine.Format("Line %d", nSLine - 8);
        SendCommand("cutoff", sLine, nGwCom[1]);
	}
}

HBRUSH CIPCountDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	// TODO: Change any attributes of the DC here
	if(pWnd ->m_hWnd == GetDlgItem(IDC_EDIT_SHOW) ->m_hWnd)	
	{
		pDC ->SetTextColor(RGB(0,89,232));

⌨️ 快捷键说明

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