AddOldClient2.cpp 6.6 KB

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