AddOldClient.cpp 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. // AddOldClient.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "UPhoneBox.h"
  5. #include "AddOldClient.h"
  6. #include "UPhoneBoxDlg.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // AddOldClient dialog IDC_EDITdate
  14. AddOldClient::AddOldClient(CWnd* pParent /*=NULL*/)
  15. : CDialog(AddOldClient::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(AddOldClient)
  18. m_date = _T("");
  19. m_birthday1 = _T("");
  20. m_birthday2 = _T("");
  21. m_name1 = _T("");
  22. m_name2 = _T("");
  23. m_phone1 = _T("");
  24. m_phone2 = _T("");
  25. m_qq1 = _T("");
  26. m_qq2 = _T("");
  27. m_time3 = _T("");
  28. m_taoxijiage = _T("");
  29. m_taoxiname = _T("");
  30. m_bAdd = 1;
  31. m_check1 = FALSE;
  32. m_check2 = FALSE;
  33. m_check3 = FALSE;
  34. //}}AFX_DATA_INIT
  35. }
  36. void AddOldClient::DoDataExchange(CDataExchange* pDX)
  37. {
  38. CDialog::DoDataExchange(pDX);
  39. //{{AFX_DATA_MAP(AddOldClient)
  40. DDX_Control(pDX, IDC_COMBO1, m_combotaoxiname);
  41. DDX_Text(pDX, IDC_EDITdate, m_date);
  42. DDX_Text(pDX, IDC_EDITBirthday, m_birthday1);
  43. DDX_Text(pDX, IDC_EDITBirthday3, m_birthday2);
  44. DDX_Text(pDX, IDC_EDITname2, m_name1);
  45. DDX_Text(pDX, IDC_EDITname3, m_name2);
  46. DDX_Text(pDX, IDC_EDITphone3, m_phone1);
  47. DDX_Text(pDX, IDC_EDITphone4, m_phone2);
  48. DDX_Text(pDX, IDC_EDITqq2, m_qq1);
  49. DDX_Text(pDX, IDC_EDITqq3, m_qq2);
  50. DDX_Text(pDX, IDC_EDITtime3, m_time3);
  51. DDX_Text(pDX, IDC_EDITtaoxijiage, m_taoxijiage);
  52. DDX_CBString(pDX, IDC_COMBO1, m_taoxiname);
  53. DDX_Check(pDX, IDC_CHECK1, m_check1);
  54. DDX_Check(pDX, IDC_CHECK2, m_check2);
  55. DDX_Check(pDX, IDC_CHECK3, m_check3);
  56. //}}AFX_DATA_MAP
  57. }
  58. BEGIN_MESSAGE_MAP(AddOldClient, CDialog)
  59. //{{AFX_MSG_MAP(AddOldClient)
  60. //}}AFX_MSG_MAP
  61. ON_MESSAGE(WM_USER + 111, OnCloseWin)
  62. END_MESSAGE_MAP()
  63. /////////////////////////////////////////////////////////////////////////////
  64. // AddOldClient message handlers
  65. extern int g_nYearpos;
  66. extern BOOL g_bReturned2;
  67. extern CUPhoneBoxDlg *g_pMainWnd;
  68. extern void DataToArray(CArray<CStringArray, CStringArray>*List1array);
  69. BOOL AddOldClient::OnInitDialog()
  70. {
  71. CDialog::OnInitDialog();
  72. SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
  73. g_hwnd[m_linepos] = this->m_hWnd;
  74. // TODO: Add extra initialization here
  75. /* g_sendhead.bsql=0;
  76. g_sendhead.code[0]=138;
  77. g_sendhead.tabcount=1;
  78. CString filter;
  79. CString addareaphone="%"+m_phone;
  80. filter="phone like '"+addareaphone+"' or phone2 like '"+addareaphone+"'";
  81. g_pMainWnd->ProcessChatMessageRequest2(filter);
  82. for(int i=0; i<20; i++)
  83. {
  84. if(g_bReturned2)break;
  85. ::Sleep (500);
  86. }
  87. if(i>=20)
  88. {
  89. nNeedConn2=1; CDialog::OnCancel ();
  90. return 0;
  91. }
  92. DataToArray( &m_List1array);*/
  93. GetListData(138, &m_List1array, m_phone, 0, 0);
  94. if (m_List1array.GetSize())
  95. {
  96. m_name1 = m_List1array.ElementAt(0).ElementAt(1);
  97. m_name2 = m_List1array.ElementAt(0).ElementAt(2);
  98. m_phone1 = m_List1array.ElementAt(0).ElementAt(3);
  99. m_phone2 = m_List1array.ElementAt(0).ElementAt(4);
  100. m_qq1 = m_List1array.ElementAt(0).ElementAt(5);
  101. m_qq2 = m_List1array.ElementAt(0).ElementAt(6);
  102. m_birthday1 = m_List1array.ElementAt(0).ElementAt(7);
  103. m_birthday2 = m_List1array.ElementAt(0).ElementAt(8);
  104. m_time3 = m_List1array.ElementAt(0).ElementAt(9);
  105. m_taoxiname = m_List1array.ElementAt(0).ElementAt(10);
  106. m_taoxijiage = m_List1array.ElementAt(0).ElementAt(11);
  107. m_date = m_List1array.ElementAt(0).ElementAt(12);
  108. m_check1 = atoi(m_List1array.ElementAt(0).ElementAt(17));
  109. m_check2 = atoi(m_List1array.ElementAt(0).ElementAt(18));
  110. m_check3 = atoi(m_List1array.ElementAt(0).ElementAt(19));
  111. UpdateData(0);
  112. }
  113. this->CenterWindow(g_pMainWnd);
  114. return false; // return TRUE unless you set the focus to a control
  115. // EXCEPTION: OCX Property Pages should return FALSE
  116. }
  117. void AddOldClient::OnOK()
  118. {
  119. // TODO: Add extra validation here
  120. }
  121. void AddOldClient::OnCancel()
  122. {
  123. // TODO: Add extra cleanup here
  124. }
  125. LRESULT AddOldClient::OnCloseWin(WPARAM wParam, LPARAM lParam)
  126. {
  127. // TODO: Add your message handler code here and/or call default
  128. if (wParam)
  129. {
  130. if (::PathFileExists(g_recordpath[m_linepos]))
  131. {
  132. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  133. CString sql, sql2;
  134. sql.Format("insert into [client3phonerecord]([phone],[datetime])values(\
  135. '%s','%s')", m_phone, datetime);
  136. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  137. {
  138. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  139. if (content != "" && CheckExist(m_phone) == 0)
  140. {
  141. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  142. int count = GetLengthEx(content) / 70;
  143. if (GetLengthEx(content) % 70)
  144. count++;
  145. CString scount;
  146. scount.Format("%d", count);
  147. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  148. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  149. sql += sql2;
  150. }
  151. }
  152. g_sendhead.bsql = 1;
  153. g_nYearpos = -1;
  154. g_pMainWnd->ProcessChatMessageRequest2(sql);
  155. int i = 0;
  156. for ( i = 0; i < 20; i++)
  157. {
  158. if (g_bReturned2)break;
  159. ::Sleep(500);
  160. }
  161. if (i >= 20)
  162. {
  163. nNeedConn2 = 1;
  164. // CDialog::OnCancel ();
  165. DestroyWindow();
  166. return 1;
  167. }
  168. datetime.Replace(":", "");
  169. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\老客户", NULL);
  170. ::CreateDirectory("\\\\" + g_server2 + "\\电话录音(管理软件)$\\老客户\\" + m_phone, NULL);
  171. CString m_savepath = "\\\\" + g_server2 + "\\电话录音(管理软件)$\\老客户\\" + m_phone + "\\" + datetime + ".mp3";
  172. if (::PathFileExists(g_recordpath[m_linepos]))
  173. {
  174. ::CopyFile(g_recordpath[m_linepos], m_savepath, 0);
  175. ::DeleteFile(g_recordpath[m_linepos]);
  176. }
  177. }
  178. }
  179. else
  180. {
  181. CString datetime = CTime::GetCurrentTime().Format("%Y-%m-%d %H:%M:%S");
  182. CString sql, sql2;
  183. CString m_name;
  184. m_name = m_name1 + "," + m_name2;
  185. m_name.TrimRight(",");
  186. sql.Format("insert into [misscallrecord]([phone],[datetime],[name],[type])values(\
  187. '%s','%s','%s','%s')", m_phone, datetime, m_name, "老客户来电");
  188. if (atoi(g_cominfoarray.ElementAt(0).ElementAt(88)) && atoi(g_cominfoarray.ElementAt(0).ElementAt(89)))
  189. {
  190. CString content = g_cominfoarray.ElementAt(0).ElementAt(92);
  191. if (content != "" && CheckExist(m_phone) == 0)
  192. {
  193. CString timestamp = CTime::GetCurrentTime().Format("%Y%m%d%H%M%S");
  194. int count = GetLengthEx(content) / 70;
  195. if (GetLengthEx(content) % 70)
  196. count++;
  197. CString scount;
  198. scount.Format("%d", count);
  199. CString sql2 = "***insert into sendreg([phones],[content],[timestamp],[msgcount],[status],[issended],[isautosend],[ren]) values\
  200. ('" + m_phone + "','" + content + "','" + timestamp + "','" + scount + "','0','0','0','系统自动发送')";
  201. sql += sql2;
  202. }
  203. }
  204. g_sendhead.bsql = 1;
  205. g_nYearpos = -1;
  206. g_pMainWnd->ProcessChatMessageRequest2(sql);
  207. int i;
  208. for ( i = 0; i < 20; i++)
  209. {
  210. if (g_bReturned2)break;
  211. ::Sleep(500);
  212. }
  213. if (i >= 20)
  214. {
  215. nNeedConn2 = 1;
  216. // CDialog::OnCancel ();
  217. DestroyWindow();
  218. return 1;
  219. }
  220. }
  221. // CDialog::OnCancel ();
  222. DestroyWindow();
  223. }