// Client2Dlg.cpp : implementatio n file // #include "stdafx.h" #include "uphonebox.h" #include "Client2Dlg.h" #include "UPhoneBoxDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // Client2Dlg dialog Client2Dlg::Client2Dlg(CWnd* pParent /*=NULL*/) : CDialog(Client2Dlg::IDD, pParent) { //{{AFX_DATA_INIT(Client2Dlg) m_phone = _T(""); m_name = _T(""); m_sex = _T(""); m_addr = _T(""); m_qq = _T(""); m_bz = _T(""); //}}AFX_DATA_INIT m_linepos = 0; m_bCanClose = 0; m_nSecond = 0; } void Client2Dlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(Client2Dlg) DDX_Text(pDX, IDC_EDIT1, m_phone); DDX_Text(pDX, IDC_EDIT2, m_name); DDX_Text(pDX, IDC_EDIT3, m_sex); DDX_Text(pDX, IDC_EDIT4, m_addr); DDX_Text(pDX, IDC_EDIT5, m_qq); DDX_Text(pDX, IDC_EDIT6, m_bz); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(Client2Dlg, CDialog) //{{AFX_MSG_MAP(Client2Dlg) ON_WM_LBUTTONDOWN() ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON1, OnButton1) //}}AFX_MSG_MAP ON_MESSAGE(WM_USER + 111, OnCloseWin) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // Client2Dlg message handlers BOOL Client2Dlg::OnInitDialog() { CDialog::OnInitDialog(); SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); g_hwnd[m_linepos] = this->m_hWnd; // TODO: Add extra initialization here ::SetForegroundWindow(m_hWnd); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } extern int g_nYearpos; extern BOOL g_bReturned2; extern CUPhoneBoxDlg *g_pMainWnd; LRESULT Client2Dlg::OnCloseWin(WPARAM wParam, LPARAM lParam) { // TODO: Add your message handler code here and/or call default if (wParam) { if (::PathFileExists(g_recordpath[m_linepos])) { CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"); CString sql, sql2; sql.Format("insert into [client2phonerecord]([phone],[datetime])values(\ '%s','%s')", m_phone, datetime); if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89))) { CString content = g_cominfoarray.ElementAt(0).ElementAt(92); if (content != "" && CheckExist(m_phone) == 0) { CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S"); int count = GetLengthEx(content) / 70; if (GetLengthEx(content) % 70) count++; CString scount; scount.Format("%d", count); CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\ ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')"; sql += sql2; } } g_sendhead.bsql = 1; g_nYearpos = -1; g_pMainWnd->ProcessChatMessageRequest2(sql); int i; for ( i = 0; i < 20; i++) { if (g_bReturned2)break; ::Sleep(500); } if (i >= 20) { nNeedConn2 = 1; // CDialog::OnCancel (); DestroyWindow(); return 1; } datetime.Replace(":", ""); ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户", NULL); ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone, NULL); CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\意向客户\\" + m_phone + "\\" + datetime + ".mp3"; if (::PathFileExists(g_recordpath[m_linepos])) { ::CopyFile(g_recordpath[m_linepos], m_savepath, 0); ::DeleteFile(g_recordpath[m_linepos]); } SetTimer(1, 1000, NULL); GetDlgItem(IDC_BUTTON2)->EnableWindow(1); m_bCanClose = 1; return 1; } } else { CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"); CString sql, sql2; sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\ '%s','%s','%s','%s')", m_phone, datetime, m_name, "意向客户来电"); if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89))) { CString content = g_cominfoarray.ElementAt(0).ElementAt(92); if (content != "" && CheckExist(m_phone) == 0) { CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S"); int count = GetLengthEx(content) / 70; if (GetLengthEx(content) % 70) count++; CString scount; scount.Format("%d", count); CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\ ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')"; sql += sql2; } } g_sendhead.bsql = 1; g_nYearpos = -1; g_pMainWnd->ProcessChatMessageRequest2(sql); int i; for ( i = 0; i < 20; i++) { if (g_bReturned2)break; ::Sleep(500); } if (i >= 20) { nNeedConn2 = 1; // CDialog::OnCancel (); DestroyWindow(); return 1; } } // CDialog::OnCancel (); DestroyWindow(); } void Client2Dlg::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y)); CDialog::OnLButtonDown(nFlags, point); } void Client2Dlg::OnOK() { // TODO: Add extra hevalidationre } void Client2Dlg::OnCancel() { // TODO: Add extra cleanup here } void Client2Dlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default m_nSecond++; CString str; str.Format("关闭(%d)", 300 - m_nSecond); GetDlgItem(IDC_BUTTON2)->SetWindowText(str); if (m_nSecond >= 300) { KillTimer(1); DestroyWindow(); } } void Client2Dlg::OnButton1() { // TODO: Add your control notification handler code here UpdateData(); CString sql; sql.Format("update [client2] set [bz]='%s' where [phone]='%s'", m_bz, m_phone); g_sendhead.bsql = 1; g_nYearpos = -1; g_pMainWnd->ProcessChatMessageRequest2(sql); int i; for ( i = 0; i < 20; i++) { if (g_bReturned2)break; ::Sleep(500); } if (i >= 20) { nNeedConn2 = 1; AfxMessageBox("保存失败!", MB_ICONINFORMATION); return; } AfxMessageBox("保存成功!", MB_ICONINFORMATION); if (m_bCanClose)CDialog::OnOK(); }