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

📄 dbtestview.cpp

📁 处理各种电话投诉的危机情况
💻 CPP
📖 第 1 页 / 共 5 页
字号:
				CS[i] = WS_HANGUP;
			}
			break;
	}
}

  //程序开始时的初始化工作(在此初始化语音卡)
void CDBtestView::OnInitialUpdate()
{
	 //建立气泡工具提示
	m_BalloonToolWnd.Create(this);
	m_BalloonToolWnd.m_bStuck = true;
    //为需要建立的控件加入气泡工具提示
	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_RECORD_ID),"自动建立记录ID号");
	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_RECORD_NUM),"记录号");
	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_RECORD_TYPE),"记录类型", RGB(0,0,255));
	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_RECORD_FILENAME),"记录文件名");	
	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_RECORD_MEMO),"记录备注信息");
	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_BUTTONOK),"确定记录操作");
	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_BUTTONCANCEL),"取消记录操作");
//	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_STATIC),"各通道状态提示信息");
//	m_BalloonToolWnd.AddTool(GetDlgItem(IDC_EDIT_CHANNEL_STATUS),"各通道内外线指示信息");

	m_pSet = &GetDocument()->m_dBtestSet;
	CRecordView::OnInitialUpdate();
	
	//在此初始化语音卡
	TW_ChannelNumber = TW_Installed();
	if (TW_ChannelNumber == 0) 
	{
		char s[256];
		sprintf(s, "TW语音卡设备没有安装,错误类型是%u", TW_GetReturnCode());
		MessageBox(s, "设备错误",MB_ICONSTOP);
	    exit(0);
	}
	GetDlgItem(IDC_EDIT_CHANNEL_STATUS)->SetWindowText(Status);

	TW_Initialize();
    TW_CompressRatio (RATE_64K);

	memset(Status, '-', 64);
	Status[TW_ChannelNumber] = 0;
	UpdateData(FALSE); 
	for (WORD i = 0; i < TW_ChannelNumber; ++i)
	{
		//inputchar[i]=HANGUP;
		CS[i] = WS_HANGUP;
	}

	TW_SetLength (0x2000);   
	SetTimer (ID_TIMER, 100, NULL); //启动计时器

	bRingTime=TRUE;  //设置振铃初始值
	iRingTimeNum=1; 
	   
	bPhoneNum=false; //设置号码改变初始值

   
}

/////////////////////////////////////////////////////////////////////////////
// CDBtestView printing

BOOL CDBtestView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	
	return DoPreparePrinting(pInfo);
}

void CDBtestView::OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo)
{
  CDBtestDoc *pDoc=GetDocument();
  ASSERT_VALID(pDoc);

  pDC->SetMapMode(MM_LOENGLISH);   //计算所须纸张页数
  int iPageHeight=pDC->GetDeviceCaps(VERTRES);
  int iLogPixelsY=pDC->GetDeviceCaps (LOGPIXELSY);
  int iRectHeight=(int)(iContextHeight*iLogPixelsY);
  int iNumPages=(iTitleHeight*iLogPixelsY)+iRowTotal*iRectHeight/iPageHeight+1;
  pInfo->SetMaxPage (iNumPages);
}

void CDBtestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CDBtestView diagnostics

#ifdef _DEBUG
void CDBtestView::AssertValid() const
{
	CRecordView::AssertValid();
}

void CDBtestView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}

CDBtestDoc* CDBtestView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDBtestDoc)));
	return (CDBtestDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDBtestView database support
CRecordset* CDBtestView::OnGetRecordset()   //得到记录集指针
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CDBtestView message handlers

void CDBtestView::OnRecordAdd() //添加一个记录
{
  if(m_pSet->CanAppend()==0)
	  MessageBox("不能向数据库中添加记录!","数据库打开错误",MB_OK|MB_ICONERROR);
  else
  {
	  //set the option button displaying
	  m_oOk.ShowWindow(SW_SHOW);
	  m_oCancel.ShowWindow(SW_SHOW);
	  //create a blank record for the user to edit 
	  m_oSampleID.SetWindowText("");
	   m_oSampleID.SetReadOnly(TRUE);
	  m_oNum.SetWindowText("");
	   m_oNum.SetReadOnly(FALSE);
	  m_oType.SetWindowText("");
	   m_oType.SetReadOnly(FALSE);
	  m_oFilename.SetWindowText("");
	   m_oFilename.SetReadOnly(FALSE);
	  m_oMemo.SetWindowText("");
	   m_oMemo.SetReadOnly(FALSE);

  }

}

void CDBtestView::OnRecordDelete() //从物理上删除一个记录
{
   char cValue[7],cFilename[21];
   
    strcpy(cFilename,m_pSet->m_FileName);
    m_pSet->Delete();
    CFile::Remove(cFilename);
   
	m_pSet->MoveNext();

	if(m_pSet->IsEOF())
		m_pSet->MoveLast();
 
   if(m_pSet->IsBOF())
		m_pSet->SetFieldNull(NULL);

   //restore the display data
	
  else
  {
   itoa(m_pSet->m_sampleID,cValue,10);
   m_oSampleID.SetWindowText(cValue);
    m_oSampleID.SetReadOnly(TRUE);

   itoa(m_pSet->m_RecordNum,cValue,10);
   m_oNum.SetWindowText(cValue);
    m_oNum.SetReadOnly(TRUE);

   if(m_pSet->m_type=='0')
	 strcpy(cType,"留言");
   else if(m_pSet->m_type!='1'&&m_pSet->m_type!='2'&&m_pSet->m_type!='3')
	 strcpy(cType,"空类型");
   else
	 strcpy(cType,"投诉");
   m_oType.SetWindowText(cType);
    m_oType.SetReadOnly(TRUE);

   m_oFilename.SetWindowText(m_pSet->m_FileName);
    m_oFilename.SetReadOnly(TRUE);

   m_oMemo.SetWindowText(m_pSet->m_memo);
    m_oMemo.SetReadOnly(TRUE);
  }
    
	//UpdateData(FALSE);
	 
}

void CDBtestView::OnSortId() //按记录ID排序
{
	m_pSet->Close();
	m_pSet->m_strSort="RecordNum";
	m_pSet->Open();
	UpdateData(FALSE);
	
}

void CDBtestView::OnSortType() //按记录类型排序
{
    m_pSet->Close();
	m_pSet->m_strSort="type";
	m_pSet->Open();
	UpdateData(FALSE);
 
}

void CDBtestView::OnSortFilename()  //按文件名排序
{
	m_pSet->Close();
	m_pSet->m_strSort="FileName";
	m_pSet->Open();
	UpdateData(FALSE);	
}

void CDBtestView::OnRecordPlay()  //播放语音记录
{
 if(m_pSet->m_FileName!="")
 {
 TW_StartPlayFile (3, m_pSet->m_FileName, 0 , LONG_MAX) ;
 while(TW_PlayFileRest(3)>0);
 }
 
}

void CDBtestView::OnRecordFirst()  //移到第一个记录并显示
{
 m_pSet->MoveFirst();
 
  itoa(m_pSet->m_sampleID,cTemp1,10);  //convert integer into character(decimal).
  m_oSampleID.SetWindowText(cTemp1);

 itoa(m_pSet->m_RecordNum,cTemp2,10);
  m_oNum.SetWindowText(cTemp2);

 GetDlgItem(IDC_RECORD_FILENAME)->SetWindowText(m_pSet->m_FileName);

 if(m_pSet->m_type=='0')
	 strcpy(cType,"留言");
 else if(m_pSet->m_type!='1'&&m_pSet->m_type!='2'&&m_pSet->m_type!='3')
	 strcpy(cType,"空类型");
 else
	 strcpy(cType,"投诉");
 GetDlgItem(IDC_RECORD_TYPE)->SetWindowText(cType);

 GetDlgItem(IDC_RECORD_MEMO)->SetWindowText(m_pSet->m_memo);
 //UpdateData(FALSE);

   m_oSampleID.SetReadOnly(TRUE);
   m_oNum.SetReadOnly(TRUE);
   m_oType.SetReadOnly(TRUE);
   m_oFilename.SetReadOnly(TRUE);
   m_oMemo.SetReadOnly(TRUE);

}

void CDBtestView::OnRecordLast()  //移到最后一个记录并显示
{
 	m_pSet->MoveLast(); 

  itoa(m_pSet->m_sampleID,cTemp1,10);
  m_oSampleID.SetWindowText(cTemp1);

  itoa(m_pSet->m_RecordNum,cTemp2,10);
  m_oNum.SetWindowText(cTemp2);

 GetDlgItem(IDC_RECORD_FILENAME)->SetWindowText(m_pSet->m_FileName);

  if(m_pSet->m_type=='0')
	 strcpy(cType,"留言");
 else if(m_pSet->m_type!='1'&&m_pSet->m_type!='2'&&m_pSet->m_type!='3')
	 strcpy(cType,"空类型");
 else
	 strcpy(cType,"投诉");
 GetDlgItem(IDC_RECORD_TYPE)->SetWindowText(cType);

 GetDlgItem(IDC_RECORD_MEMO)->SetWindowText(m_pSet->m_memo);
 //UpdateData(FALSE);
  m_oSampleID.SetReadOnly(TRUE);
  m_oNum.SetReadOnly(TRUE);
   m_oType.SetReadOnly(TRUE);
   m_oFilename.SetReadOnly(TRUE);
   m_oMemo.SetReadOnly(TRUE);
	
}

void CDBtestView::OnRecordNext() 
{
  m_pSet->MoveNext();      //后移一个记录并显示
  if(m_pSet->IsEOF())
   m_pSet->MoveLast();

  itoa(m_pSet->m_sampleID,cTemp1,10);
 m_oSampleID.SetWindowText(cTemp1);

  itoa(m_pSet->m_RecordNum,cTemp2,10);
 m_oNum.SetWindowText(cTemp2);

 GetDlgItem(IDC_RECORD_FILENAME)->SetWindowText(m_pSet->m_FileName);

  if(m_pSet->m_type=='0')
	 strcpy(cType,"留言");
 else if(m_pSet->m_type!='1'&&m_pSet->m_type!='2'&&m_pSet->m_type!='3')
	 strcpy(cType,"空类型");
 else
	 strcpy(cType,"投诉");
 GetDlgItem(IDC_RECORD_TYPE)->SetWindowText(cType);

 GetDlgItem(IDC_RECORD_MEMO)->SetWindowText(m_pSet->m_memo);
 //UpdateData(FALSE);

   m_oSampleID.SetReadOnly(TRUE);
   m_oNum.SetReadOnly(TRUE);
   m_oType.SetReadOnly(TRUE);
   m_oFilename.SetReadOnly(TRUE);
   m_oMemo.SetReadOnly(TRUE);

}

void CDBtestView::OnRecordPrev()     //前移一个记录并显示
{
	m_pSet->MovePrev();
	if(m_pSet->IsBOF())	
 	 m_pSet->MoveFirst();
  itoa(m_pSet->m_sampleID,cTemp1,10);
 m_oSampleID.SetWindowText(cTemp1);

  itoa(m_pSet->m_RecordNum,cTemp2,10);
 m_oNum.SetWindowText(cTemp2);

 GetDlgItem(IDC_RECORD_FILENAME)->SetWindowText(m_pSet->m_FileName);

 if(m_pSet->m_type=='0')
	 strcpy(cType,"留言");
 else if(m_pSet->m_type!='1'&&m_pSet->m_type!='2'&&m_pSet->m_type!='3')
	 strcpy(cType,"空类型");
 else
	 strcpy(cType,"投诉");
 GetDlgItem(IDC_RECORD_TYPE)->SetWindowText(cType);

 GetDlgItem(IDC_RECORD_MEMO)->SetWindowText(m_pSet->m_memo);
 
  m_oSampleID.SetReadOnly(TRUE);
   m_oNum.SetReadOnly(TRUE);
   m_oType.SetReadOnly(TRUE);
   m_oFilename.SetReadOnly(TRUE);
   m_oMemo.SetReadOnly(TRUE);

  
}
 
  //简单报表生成部分
void CDBtestView::OnPrint(CDC* pDC, CPrintInfo* pInfo) 
{
  int iRowCount=1;
  LPSTR lpstrRow="EMPTY1"; // TEXT FORM OF ROW COUNT
  LPSTR lpstrID="sampleID";
  CString cLine;
  CPen oPen;
  CBrush oBrush;
  CFont oTextFont;
  CFont oHeadFont;
  CFont oColFont;
  LOGFONT lfFont;
  CSize oFontSize;
  COLORREF oClrRef;
  int iRowPos=120;
  int iTextHeight=0;
  CRect oDrawRect;      // drawing area for printer
  int iRecNumPos;
  int iSampleIDPos;
  int iTypePos;
  int iFilenamePos;
  int iMemoPos;

   oDrawRect=pInfo->m_rectDraw;
   
   //create a pen and brush object
   oClrRef=0x00000000;
   oPen.CreatePen(PS_SOLID,2,oClrRef);
   pDC->SelectObject(&oPen);

   oClrRef=0x00c0c0c0;
   oBrush.CreateSolidBrush(oClrRef);
   pDC->SelectObject(&oBrush);
  
   //create a heading font and select into our device context
   oHeadFont.CreatePointFont(240,"宋体",pDC);
   pDC->SelectObject(&oHeadFont);

   oFontSize=pDC->GetOutputTextExtent("投诉抢修报表");
   pDC->Ellipse(500,iRowPos-(oFontSize.cy/2)-10,oDrawRect.Width()-500,iRowPos+(oFontSize.cy/2)+10);
   pDC->SetBkMode(TRANSPARENT);
   pDC->TextOut((oDrawRect.Width()-oFontSize.cx)/2,iRowPos-(oFontSize.cy/2)-10,"投诉抢修报表");
   pDC->SetBkMode(OPAQUE);
   
   // CREATE THE APPROPRIATE SPACE
   oHeadFont.GetLogFont(&lfFont);
   iRowPos=abs(lfFont.lfHeight+500);
  
   //create a text font
   oTextFont.CreatePointFont(120,"宋体",pDC);
   oTextFont.GetLogFont(&lfFont);
   iTextHeight=abs(lfFont.lfHeight)+10;
   
   //create a font for displaying column headings.
   lfFont.lfWeight=700; //make it bold,normal is 400.
   oColFont.CreateFontIndirect(&lfFont);
   pDC->SelectObject(&oColFont);
   
   //set the first column to 1/2 inch
   iRecNumPos=int(oDrawRect.Width()/17);
   iSampleIDPos=iRecNumPos+50+pDC->GetOutputTextExtent("####").cx;
   iTypePos=iSampleIDPos+50+pDC->GetOutputTextExtent("######").cx;
   iFilenamePos=iTypePos+50+pDC->GetOutputTextExtent("TYPE EMPTY").cx;
   iMemoPos=iFilenamePos+50+pDC->GetOutputTextExtent("YearMonthDayChannelnum").cx;
   
   pDC->TextOut(iRecNumPos,iRowPos,"#");
   pDC->TextOut(iSampleIDPos,iRowPos,"记录ID");
   pDC->TextOut(iTypePos,iRowPos,"类  型");
   pDC->TextOut(iFilenamePos,iRowPos,"文件名称");
   pDC->TextOut(iMemoPos,iRowPos,"备  注");

   //create a space between the column heading and the text
   iRowPos+=iTextHeight;
   pDC->MoveTo(iRecNumPos,iRowPos);
   pDC->LineTo(oDrawRect.Width()-iRecNumPos,iRowPos);
   iRowPos+=30;
   
   iTitleHeight=iRowPos;
   //select our text font into the device context
    pDC->SelectObject(&oTextFont);
	iTextHeight=20+pDC->GetOutputTextExtent("Pp").cy;

	iContextHeight=iTextHeight;

	//print the records in a loop
	if(!m_pSet->IsBOF())
        m_pSet->MoveFirst();
	while(iRowCount<=m_pSet->GetRecordCount())
	{
      itoa(iRowCount,lpstrRow,10);
	  
	  pDC->TextOut(iRecNumPos,iRowPos,lpstrRow);
	  itoa(m_pSet->m_sampleID,lpstrID,10);
	  pDC->TextOut(iSampleIDPos,iRowPos,lpstrID);
	  
	  if(m_pSet->m_type=='0')
		  pDC->TextOut(iTypePos,iRowPos,"留言");
	  else if(m_pSet->m_type=='1'||m_pSet->m_type=='2'||m_pSet->m_type=='3')
		  pDC->TextOut(iTypePos,iRowPos,"投诉");
	  else
		  pDC->TextOut(iTypePos,iRowPos,"空类型");

	  pDC->TextOut(iFilenamePos,iRowPos,m_pSet->m_FileName);
	  pDC->TextOut(iMemoPos,iRowPos,m_pSet-

⌨️ 快捷键说明

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