// outsourcingDlg.cpp : impleme ntation file // #include "stdafx.h" #include "uphonebox.h" #include "outsourcingDlg.h" #include #include "UPhoneBoxDlg.h" #include "ShowHeader.h" #include "./helper/ffsco.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CArrayyearposarray[10]; extern CStringArray idarray[10]; #pragma comment(lib, "Shlwapi.lib") ///////////////////////////////////////////////////////////////////////////// // outsourcingDlg dialog IDC_EDITstatus1 outsourcingDlg::outsourcingDlg(CWnd* pParent /*=NULL*/) : CDialog(outsourcingDlg::IDD, pParent) { //{{AFX_DATA_INIT(outsourcingDlg) m_name1 = _T(""); m_name2 = _T(""); m_id = _T(""); m_money1 = _T(""); m_money2 = _T(""); m_money3 = _T(""); m_tx = _T(""); m_status1 = _T(""); m_status2 = _T(""); m_status3 = _T(""); m_status4 = _T(""); m_status5 = _T(""); m_status6 = _T(""); m_status7 = _T(""); m_waiter = _T(""); m_date1 = _T(""); m_date2 = _T(""); m_date3 = _T(""); m_date4 = _T(""); m_date5 = _T(""); //}}AFX_DATA_INIT m_pos = 0; m_linepos = 0; m_pImg = NULL; m_headerpos = 0; m_headerhwnd = NULL; } void outsourcingDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(outsourcingDlg) DDX_Control(pDX, IDC_LIST1, m_List1); DDX_Text(pDX, IDC_EDITname1, m_name1); DDX_Text(pDX, IDC_EDITname2, m_name2); DDX_Text(pDX, IDC_EDITid2, m_id); DDX_Text(pDX, IDC_EDITmoney1, m_money1); DDX_Text(pDX, IDC_EDITmoney2, m_money2); DDX_Text(pDX, IDC_EDITmoney3, m_money3); DDX_Text(pDX, IDC_EDITid3, m_tx); DDX_Text(pDX, IDC_EDITstatus1, m_status1); DDX_Text(pDX, IDC_EDITstatus2, m_status2); DDX_Text(pDX, IDC_EDITstatus3, m_status3); DDX_Text(pDX, IDC_EDITstatus4, m_status4); DDX_Text(pDX, IDC_EDITstatus5, m_status5); DDX_Text(pDX, IDC_EDITstatus6, m_status6); DDX_Text(pDX, IDC_EDITstatus7, m_status7); DDX_Text(pDX, IDC_EDITwaiter, m_waiter); DDX_Text(pDX, IDC_EDITdate1, m_date1); DDX_Text(pDX, IDC_EDITdate2, m_date2); DDX_Text(pDX, IDC_EDITdate3, m_date3); DDX_Text(pDX, IDC_EDITdate4, m_date4); DDX_Text(pDX, IDC_EDITdate5, m_date5); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(outsourcingDlg, CDialog) //{{AFX_MSG_MAP(outsourcingDlg) ON_BN_CLICKED(IDC_BUTTON1, OnButton1) ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_BN_CLICKED(IDC_STATIC2, OnStatic2) ON_WM_PAINT() ON_WM_DESTROY() ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_WM_TIMER() ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_MESSAGE(WM_USER + 111, OnCloseWin) //}}AFX_MSG_MAP ON_WM_CLOSE() END_MESSAGE_MAP() // ///////////////////////////////////////////////////////////////////////////// // outsourcingDlg message handlers BOOL outsourcingDlg::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 if (idarray[m_linepos].GetSize() > 1) { GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_SHOW); GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_SHOW); GetDlgItem(IDC_STATIC1)->ShowWindow(SW_SHOW); } if (idarray[m_linepos].GetSize() > 1) { GetDlgItem(IDC_BUTTON1)->EnableWindow(1); GetDlgItem(IDC_BUTTON2)->EnableWindow(1); } CString str; str.Format("找到%d个客户", idarray[m_linepos].GetSize()); SetDlgItemText(IDC_STATIC1, str); m_List1.InitStyle(); m_List1.InsertColumn(0, _T("商品名称"), LVCFMT_LEFT, 120); m_List1.InsertColumn(1, _T("数量"), LVCFMT_LEFT, 50); m_List1.InsertColumn(2, _T("加急"), LVCFMT_LEFT, 50); m_List1.InsertColumn(3, _T("取件日期"), LVCFMT_LEFT, 80); m_List1.InsertColumn(4, _T("发出"), LVCFMT_LEFT, 80); m_List1.InsertColumn(5, _T("发出日期"), LVCFMT_LEFT, 120); m_List1.InsertColumn(6, _T("返工"), LVCFMT_LEFT, 50); m_List1.InsertColumn(7, _T("返工日期"), LVCFMT_LEFT, 120); m_List1.InsertColumn(8, _T("完成"), LVCFMT_LEFT, 60); m_List1.InsertColumn(9, _T("完成日期"), LVCFMT_LEFT, 120); m_List1.InsertColumn(10, _T("取走"), LVCFMT_LEFT, 50); m_List1.InsertColumn(11, _T("取走日期"), LVCFMT_LEFT, 120); ShowClient(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } CString outsourcingDlg::GetLB(CString name) { return ""; } void ConvertToPrice(CString &str) { if (str.Find('.') == -1)return; str.TrimRight('0'); str.TrimRight('.'); } void LoadImageFromBuf(Image **img, BYTE *pData, DWORD leng) { try { if (pData == NULL)return; if (*img)delete *img; *img = NULL; // Allocate global memory on which to create stream HGLOBAL m_hMem = GlobalAlloc(GMEM_MOVEABLE, leng); if (m_hMem == NULL)return; BYTE* pmem = (BYTE*)GlobalLock(m_hMem); memcpy(pmem, pData, leng); IStream* pstm; CreateStreamOnHGlobal(m_hMem, TRUE, &pstm); // load from stream *img = Gdiplus::Image::FromStream(pstm); // free/release stuff GlobalUnlock(m_hMem); pstm->Release(); } catch (...) { } } void LoadImageFromBuf(Image **img, CString path) { try { CFile fp; if (fp.Open(path, CFile::modeRead)) { DWORD leng = fp.GetLength(); BYTE *pData = new BYTE[leng]; fp.Read(pData, leng); fp.Close(); LoadImageFromBuf(img, pData, leng); delete[]pData; } } catch (...) { } } extern CString g_headerpath; extern int g_nYearpos; extern BOOL g_bReturned2; extern CUPhoneBoxDlg *g_pMainWnd; extern void DataToArray(CArray*List1array, CArray*List2array, CArray*List3array); void outsourcingDlg::ShowClient() { m_id = idarray[m_linepos].ElementAt(m_pos); CString filter = "id='" + m_id + "' and kind<>'5' and name<>'入册';id='" + m_id + "';id='" + m_id + "'"; g_nYearpos = yearposarray[m_linepos].ElementAt(m_pos); /* g_sendhead.code[0]=56; g_sendhead.code[1]=11; g_sendhead.code[2]=181; g_sendhead.tabcount=3; g_sendhead.bsql=0; g_pMainWnd->ProcessChatMessageRequest2(filter); for(int i=0; i<20; i++) { if(g_bReturned2)break; ::Sleep (500); } if(i>=20) { nNeedConn2=1; return; }*/ CArrayList1array; CArrayList2array; CArraym_sparray; // DataToArray(&m_sparray,&List1array,&List2array); GetListData(56, &m_sparray, m_id, g_nYearpos + 1, 0); GetListData(11, &List1array, m_id, g_nYearpos + 1, 1); GetListData(181, &List2array, m_id, g_nYearpos + 1, 0); m_List1.DeleteAllItems(); int listpos[3] = { 0 }; CComboBoxListCtrl *pList[1] = { &m_List1 }; int pos = 0; int i; for ( i = 0; i < m_sparray.GetSize(); i++) { pList[pos]->InsertItem(listpos[pos], m_sparray.ElementAt(i).ElementAt(0)); pList[pos]->SetItemText(listpos[pos], 1, m_sparray.ElementAt(i).ElementAt(1)); pList[pos]->SetItemText(listpos[pos], 2, m_sparray.ElementAt(i).ElementAt(18)); pList[pos]->SetItemText(listpos[pos], 3, m_sparray.ElementAt(i).ElementAt(19)); pList[pos]->SetItemText(listpos[pos], 4, m_sparray.ElementAt(i).ElementAt(2)); pList[pos]->SetItemText(listpos[pos], 5, m_sparray.ElementAt(i).ElementAt(9) + "/" + m_sparray.ElementAt(i).ElementAt(10)); pList[pos]->SetItemText(listpos[pos], 6, m_sparray.ElementAt(i).ElementAt(3)); pList[pos]->SetItemText(listpos[pos], 7, m_sparray.ElementAt(i).ElementAt(11) + "/" + m_sparray.ElementAt(i).ElementAt(12)); pList[pos]->SetItemText(listpos[pos], 8, m_sparray.ElementAt(i).ElementAt(4)); pList[pos]->SetItemText(listpos[pos], 9, m_sparray.ElementAt(i).ElementAt(13) + "/" + m_sparray.ElementAt(i).ElementAt(14)); pList[pos]->SetItemText(listpos[pos], 10, m_sparray.ElementAt(i).ElementAt(5)); pList[pos]->SetItemText(listpos[pos], 11, m_sparray.ElementAt(i).ElementAt(15) + "/" + m_sparray.ElementAt(i).ElementAt(16)); listpos[pos]++; } if (List1array.GetSize()) { CString m_taoxijiage = List1array.ElementAt(0).ElementAt(8); CString m_payed4 = List1array.ElementAt(0).ElementAt(19); CString m_payed5 = List1array.ElementAt(0).ElementAt(20); m_money1 = List1array.ElementAt(0).ElementAt(1); m_money2.Format("%f", atof(m_payed5) + atof(m_money1)); m_money1.Format("%f", atof(m_taoxijiage) + atof(m_payed4)); m_money3.Format("%f", atof(m_money1) - atof(m_money2)); ConvertToPrice(m_money1); ConvertToPrice(m_money2); ConvertToPrice(m_money3); m_name1 = List1array.ElementAt(0).ElementAt(4); m_name2 = List1array.ElementAt(0).ElementAt(5); m_tx = List1array.ElementAt(0).ElementAt(7); m_waiter = List1array.ElementAt(0).ElementAt(14); m_status1 = List2array.ElementAt(0).ElementAt(5 + 3); m_status2 = List2array.ElementAt(0).ElementAt(6 + 3); m_status3 = List2array.ElementAt(0).ElementAt(7 + 3); m_status4 = List2array.ElementAt(0).ElementAt(8 + 3); m_status5 = List2array.ElementAt(0).ElementAt(9 + 3); m_status6 = List2array.ElementAt(0).ElementAt(10 + 3); m_status7 = List2array.ElementAt(0).ElementAt(11 + 3); m_date1 = List2array.ElementAt(0).ElementAt(12 + 3); m_date2 = List2array.ElementAt(0).ElementAt(13 + 3); m_date3 = List2array.ElementAt(0).ElementAt(14 + 3); m_date4 = List2array.ElementAt(0).ElementAt(15 + 3); m_date5 = List2array.ElementAt(0).ElementAt(16 + 3); UpdateData(false); } ::SetForegroundWindow(m_hWnd); CString path = g_headerpath + m_id + "\\"; CString str; m_headerarray.RemoveAll(); for (i = 0; i < 100; i++) { str.Format("%s%03d.jpg", path, i); if (::PathFileExists(str)) { m_headerarray.Add(str); } } if (m_headerarray.GetSize() == 0) { str = "客人头像\\"; CString defaultpath = g_headerpath.Left(g_headerpath.GetLength() - str.GetLength()); defaultpath += m_id + "\\"; using namespace helper_coffs; ffsco o; o.dirs(1); o.find(LPCSTR(defaultpath), LPCSTR("*.jpg")); ffsco::typeT coo; ffsco::typeT::iterator it; coo = o.co_file(); for (it = coo.begin();coo.end() != it;it++) { str = (*it).c_str(); if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue; m_headerarray.Add(str); if (m_headerarray.GetSize() > 10)break; } } if (m_headerarray.GetSize() <= 1) { GetDlgItem(IDC_BUTTON4)->EnableWindow(0); GetDlgItem(IDC_BUTTON5)->EnableWindow(0); } if (m_headerarray.GetSize()) { m_headerpos = -1; OnButton5(); } } void outsourcingDlg::OnButton1() { // TODO: Add your control notification handler code here m_pos--; if (m_pos < 0) m_pos = idarray[m_linepos].GetSize() - 1; ShowClient(); } void outsourcingDlg::OnButton2() { // TODO: Add your control notification handler code here m_pos++; if (m_pos >= idarray[m_linepos].GetSize()) m_pos = 0; ShowClient(); } CString g_id; CString g_name1; CString g_name2; void outsourcingDlg::OnButton3() { // TODO: Add your control notification handler code here g_id = m_id; g_name1 = m_name1; g_name2 = m_name2; // g_pMainWnd->ClientBooking(m_id, m_name1, m_name2); g_pMainWnd->SetTimer(4, 200, NULL); } BOOL outsourcingDlg::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class if (pMsg->message == WM_LBUTTONDBLCLK) { return 1; } return CDialog::PreTranslateMessage(pMsg); } LRESULT outsourcingDlg::OnCloseWin(WPARAM wParam, LPARAM lParam) { // TODO: Add your message handler code here and/or call default #if _DEBUG TRACE("订单顾客来电对话框关闭\n"); #endif if (m_headerhwnd) { ::SendMessage(m_headerhwnd, WM_CLOSE, 0, 0); m_headerhwnd = NULL; } if (wParam) { if (::PathFileExists(g_recordpath[m_linepos])) { CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S"); CString sql; sql.Format("insert into [phonerecord]([id],[datetime],[phoneno])values(\ '%s','%s','%s')", m_id, datetime, m_phone); 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(); return 1; } datetime.Replace(":", ""); ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\客户电话", NULL); ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\客户电话\\" + m_id, NULL); CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\客户电话\\" + m_id + "\\" + datetime + ".mp3"; if (::PathFileExists(g_recordpath[m_linepos])) { ::CopyFile(g_recordpath[m_linepos], m_savepath, 0); } } } else { CString name; if (!m_name1.IsEmpty()) name = m_name1 + ","; name += m_name2; name.TrimRight(","); 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, 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(); return 1; } } ::DeleteFile(g_recordpath[m_linepos]); DestroyWindow(); // CDialog::OnCancel (); } void outsourcingDlg::OnOK() { // TODO: Add extra validation here } void outsourcingDlg::OnCancel() { // TODO: Add extra cleanup here } void RectFitDes(int width, int height, CRect &rc) { try { if (width == 0 || height == 0)return; float fscale = (float)width / (float)height; float rcscale = ((float)rc.Width()) / ((float)rc.Height()); int rcwid = rc.Width(); int rchei = rc.Height(); int dt = 0; if (rcscale < fscale) { dt = (rchei - rcwid / fscale) / 2; rc.top += dt; rc.bottom -= dt; } else { dt = (rcwid - rchei*fscale) / 2; rc.left += dt; rc.right -= dt; } } catch (...) { } } void outsourcingDlg::OnPaint() { CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here if (m_pImg) { CRect rc; GetDlgItem(IDC_STATIC2)->GetWindowRect(rc); ScreenToClient(rc); RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc); Graphics dcgraph(dc.GetSafeHdc()); Rect destinationRect(rc.left, rc.top, rc.Width(), rc.Height()); dcgraph.DrawImage(m_pImg, destinationRect, 0, 0, m_pImg->GetWidth(), m_pImg->GetHeight(), UnitPixel); } // Do not call CDialog::OnPaint() for painting messages } void outsourcingDlg::OnStatic2() { // TODO: Add your control notification handler code here if (m_pImg) { ShowHeader dlg; dlg.m_pheaderhwnd = &m_headerhwnd; dlg.m_pImg = m_pImg; dlg.DoModal(); } } void outsourcingDlg::OnDestroy() { CDialog::OnDestroy(); // TODO: Add your message handler code here if (m_pImg)delete m_pImg; m_pImg = NULL; } void outsourcingDlg::OnButton4() { // TODO: Add your control notification handler code here m_headerpos--; if (m_headerpos == -1) m_headerpos = m_headerarray.GetSize() - 1; CString path = m_headerarray.ElementAt(m_headerpos); if (m_pImg)delete m_pImg; m_pImg = NULL; ::LoadImageFromBuf(&m_pImg, path); CRect rc; GetDlgItem(IDC_STATIC2)->GetWindowRect(rc); ScreenToClient(rc); InvalidateRect(rc); } void outsourcingDlg::OnButton5() { // TODO: Add your control notification handler code here m_headerpos++; if (m_headerarray.GetSize() <= m_headerpos) m_headerpos = 0; CString path = m_headerarray.ElementAt(m_headerpos); if (m_pImg)delete m_pImg; m_pImg = NULL; ::LoadImageFromBuf(&m_pImg, path); CRect rc; GetDlgItem(IDC_STATIC2)->GetWindowRect(rc); ScreenToClient(rc); InvalidateRect(rc); } void outsourcingDlg::OnClose() { // TODO: 在此添加消息处理程序代码和/或调用默认值 CDialog::OnClose(); }