MissCall.cpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. // MissCall.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "MissCall.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "InputPsw.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. //#pragma comment(lib, "Shlwapi.lib")
  15. /////////////////////////////////////////////////////////////////////////////
  16. // MissCall
  17. IMPLEMENT_DYNCREATE(MissCall, MyFormView)
  18. MissCall::MissCall()
  19. : MyFormView(MissCall::IDD)
  20. {
  21. //{{AFX_DATA_INIT(MissCall)
  22. m_filter = _T("");
  23. //}}AFX_DATA_INIT
  24. }
  25. MissCall::~MissCall()
  26. {
  27. }
  28. void MissCall::DoDataExchange(CDataExchange* pDX)
  29. {
  30. MyFormView::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(MissCall)
  32. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  33. DDX_Control(pDX, IDC_LIST2, m_List1);
  34. DDX_Control(pDX, IDC_STATIC1, m_static1);
  35. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(MissCall, MyFormView)
  39. //{{AFX_MSG_MAP(MissCall)
  40. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  41. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  42. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  43. ON_WM_TIMER()
  44. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  45. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  46. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  47. //}}AFX_MSG_MAP
  48. END_MESSAGE_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // MissCall diagnostics
  51. #ifdef _DEBUG
  52. void MissCall::AssertValid() const
  53. {
  54. MyFormView::AssertValid();
  55. }
  56. void MissCall::Dump(CDumpContext& dc) const
  57. {
  58. MyFormView::Dump(dc);
  59. }
  60. #endif //_DEBUG
  61. /////////////////////////////////////////////////////////////////////////////
  62. // MissCall message handlers
  63. void MissCall::OnInitialUpdate()
  64. {
  65. MyFormView::OnInitialUpdate();
  66. // TODO: Add your specialized code here and/or call the base class
  67. CMyMdi Mdi;
  68. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  69. // Here we create the outbar control using the splitter as its parent
  70. // and setting its id to the first pane.
  71. CRect rc2;
  72. GetWindowRect(rc2);
  73. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  74. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  75. m_static1.SetFont(&g_titlefont);
  76. m_List1.SetHeadings("姓名,160;电话号码,160;来电时间,160;类别,160");
  77. m_List1.LoadColumnInfo(159);
  78. g_sendhead.bsql = 0;
  79. g_sendhead.code[0] = 117;
  80. g_sendhead.tabcount = 1;
  81. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  82. DataToArray(&m_List1array);
  83. FillGrid();
  84. m_combo1.GetWindowRect(rc2);
  85. ScreenToClient(rc2);
  86. rc2.bottom += 200;
  87. m_combo1.MoveWindow(rc2);
  88. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  89. SetComboHei(&m_combo1, rc2.Height());
  90. }
  91. void MissCall::FillGrid(BOOL bStatus)
  92. {
  93. m_List1.DeleteAllItems2();
  94. int ii = 0;
  95. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  96. int count = 0;
  97. if (m_filter.IsEmpty())
  98. {
  99. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  100. {
  101. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  102. }
  103. }
  104. else
  105. {
  106. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  107. {
  108. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  109. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  110. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  111. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1)
  112. {
  113. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  114. }
  115. }
  116. }
  117. m_List1.m_arLabels.SetSize(count, 1);
  118. ii = count;
  119. m_List1.m_LabelCount = ii;
  120. m_List1.SetItemCountEx(ii);
  121. }
  122. void MissCall::OnBUTclose()
  123. {
  124. // TODO: Add your control notification handler code here
  125. GetParent()->SendMessage(WM_CLOSE);
  126. }
  127. void MissCall::OnSelchangeCombo1()
  128. {
  129. // TODO: Add your control notification handler code here
  130. SetTimer(1, 100, NULL);
  131. }
  132. void MissCall::OnTimer(UINT nIDEvent)
  133. {
  134. // TODO: Add your message handler code here and/or call default
  135. KillTimer(nIDEvent);
  136. OnButton1();
  137. }
  138. BOOL MissCall::PreTranslateMessage(MSG* pMsg)
  139. {
  140. // TODO: Add your specialized code here and/or call the base class
  141. try
  142. {
  143. if (pMsg->message == WM_KEYDOWN)
  144. {
  145. switch (pMsg->wParam)
  146. {
  147. case VK_RETURN:
  148. OnButton1();
  149. return 1;
  150. case 0x43: // copy
  151. if ((GetKeyState(VK_CONTROL) & 0x80))
  152. {
  153. GetFocus()->SendMessage(WM_COPY);
  154. return TRUE;
  155. }
  156. break;
  157. case 0x56: //Ctrl + V:
  158. if ((GetKeyState(VK_CONTROL) & 0x80))
  159. {
  160. GetFocus()->SendMessage(WM_PASTE);
  161. return TRUE;
  162. }
  163. break;
  164. case 0x58: // cut
  165. if ((GetKeyState(VK_CONTROL) & 0x80))
  166. {
  167. GetFocus()->SendMessage(WM_CUT);
  168. return TRUE;
  169. }
  170. break;
  171. case 0x5A: //undo
  172. case 0x59: //redo
  173. if ((GetKeyState(VK_CONTROL) & 0x80))
  174. {
  175. GetFocus()->SendMessage(WM_UNDO);
  176. return TRUE;
  177. }
  178. break;
  179. }
  180. }
  181. return MyFormView::PreTranslateMessage(pMsg);
  182. }
  183. catch (...)
  184. {
  185. }
  186. }
  187. void MissCall::OnButton1()
  188. {
  189. // TODO: Add your control notification handler code here
  190. UpdateData();
  191. m_filter.TrimLeft();
  192. m_filter.TrimRight();
  193. FillGrid();
  194. }
  195. void MissCall::OnButton2()
  196. {
  197. // TODO: Add your control notification handler code here
  198. UpdateData();
  199. m_filter.TrimLeft();
  200. m_filter.TrimRight();
  201. FillGrid(1);
  202. }
  203. void MissCall::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  204. {
  205. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  206. // TODO: Add your control notification handler code here
  207. POSITION pos;
  208. pos = m_List1.GetFirstSelectedItemPosition();
  209. if (pos == NULL)
  210. {
  211. return;
  212. }
  213. int iItem = m_List1.GetNextSelectedItem(pos);
  214. CString waiter5 = m_List1.GetItemText(iItem, 8);
  215. if (waiter5.IsEmpty() && IsHasRights2new(5) || IsHasRights2new(49))
  216. {
  217. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
  218. }
  219. else if (waiter5 == g_user.name && IsHasRights2new(5))
  220. {
  221. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
  222. }
  223. else
  224. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(0);
  225. *pResult = 0;
  226. }
  227. BOOL MissCall::CheckOK(CString name)
  228. {
  229. if (name.GetLength() > 4)return 0;
  230. for (int i = 0; i < name.GetLength(); i++)
  231. {
  232. if (name.GetAt(i) < '0' || name.GetAt(i) > '9')return 0;
  233. }
  234. return 1;
  235. }
  236. void MissCall::OnBUTdel()
  237. {
  238. // TODO: Add your control notification handler code here
  239. if (IsHasRights2new(49) == 0)return;
  240. // TODO: Add your control notification handler code here
  241. POSITION pos;
  242. pos = m_List1.GetFirstSelectedItemPosition();
  243. if (pos == NULL)
  244. {
  245. AfxMessageBox("请先选中您要删除的记录!", MB_ICONINFORMATION);
  246. return;
  247. }
  248. if (AfxMessageBox("删除后将无法恢复,是否继续?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  249. int iItem = m_List1.GetNextSelectedItem(pos);
  250. CString datetime = m_List1.GetItemText(iItem, 2);
  251. CString sql;
  252. sql.Format("delete from misscallrecord where datetime='%s' ", datetime);
  253. g_sendhead.bsql = 1;
  254. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  255. g_sendhead.bsql = 0;
  256. g_sendhead.code[0] = 117;
  257. g_sendhead.tabcount = 1;
  258. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  259. DataToArray(&m_List1array);
  260. FillGrid();
  261. }