MissCall.cpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. //#pragma comment(lib, "Shlwapi.lib")
  14. /////////////////////////////////////////////////////////////////////////////
  15. // MissCall
  16. IMPLEMENT_DYNCREATE(MissCall, MyFormView)
  17. MissCall::MissCall()
  18. : MyFormView(MissCall::IDD)
  19. {
  20. //{{AFX_DATA_INIT(MissCall)
  21. m_filter = _T("");
  22. //}}AFX_DATA_INIT
  23. }
  24. MissCall::~MissCall()
  25. {
  26. }
  27. void MissCall::DoDataExchange(CDataExchange* pDX)
  28. {
  29. MyFormView::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(MissCall)
  31. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  32. DDX_Control(pDX, IDC_LIST2, m_List1);
  33. DDX_Control(pDX, IDC_STATIC1, m_static1);
  34. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(MissCall, MyFormView)
  38. //{{AFX_MSG_MAP(MissCall)
  39. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  40. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  41. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  42. ON_WM_TIMER()
  43. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  44. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  45. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // MissCall diagnostics
  50. #ifdef _DEBUG
  51. void MissCall::AssertValid() const
  52. {
  53. MyFormView::AssertValid();
  54. }
  55. void MissCall::Dump(CDumpContext& dc) const
  56. {
  57. MyFormView::Dump(dc);
  58. }
  59. #endif //_DEBUG
  60. /////////////////////////////////////////////////////////////////////////////
  61. // MissCall message handlers
  62. void MissCall::OnInitialUpdate()
  63. {
  64. MyFormView::OnInitialUpdate();
  65. // TODO: Add your specialized code here and/or call the base class
  66. CMyMdi Mdi;
  67. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  68. // Here we create the outbar control using the splitter as its parent
  69. // and setting its id to the first pane.
  70. CRect rc2;
  71. GetWindowRect(rc2);
  72. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  73. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  74. m_static1.SetFont(&g_titlefont);
  75. m_List1.SetHeadings("姓名,160;电话号码,160;来电时间,160;类别,160");
  76. m_List1.LoadColumnInfo(159);
  77. g_sendhead.bsql = 0;
  78. g_sendhead.code[0] = 117;
  79. g_sendhead.tabcount = 1;
  80. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  81. DataToArray(&m_List1array);
  82. FillGrid();
  83. m_combo1.GetWindowRect(rc2);
  84. ScreenToClient(rc2);
  85. rc2.bottom += 200;
  86. m_combo1.MoveWindow(rc2);
  87. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  88. SetComboHei(&m_combo1, rc2.Height());
  89. }
  90. void MissCall::FillGrid(BOOL bStatus)
  91. {
  92. m_List1.DeleteAllItems2();
  93. int ii = 0;
  94. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  95. int count = 0;
  96. if (m_filter.IsEmpty())
  97. {
  98. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  99. {
  100. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  101. }
  102. }
  103. else
  104. {
  105. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  106. {
  107. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  108. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  109. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  110. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1)
  111. {
  112. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  113. }
  114. }
  115. }
  116. m_List1.m_arLabels.SetSize(count, 1);
  117. ii = count;
  118. m_List1.m_LabelCount = ii;
  119. m_List1.SetItemCountEx(ii);
  120. }
  121. void MissCall::OnBUTclose()
  122. {
  123. // TODO: Add your control notification handler code here
  124. GetParent()->SendMessage(WM_CLOSE);
  125. }
  126. void MissCall::OnSelchangeCombo1()
  127. {
  128. // TODO: Add your control notification handler code here
  129. SetTimer(1, 100, NULL);
  130. }
  131. void MissCall::OnTimer(UINT nIDEvent)
  132. {
  133. // TODO: Add your message handler code here and/or call default
  134. KillTimer(nIDEvent);
  135. OnButton1();
  136. }
  137. BOOL MissCall::PreTranslateMessage(MSG* pMsg)
  138. {
  139. // TODO: Add your specialized code here and/or call the base class
  140. try
  141. {
  142. if (pMsg->message == WM_KEYDOWN)
  143. {
  144. switch (pMsg->wParam)
  145. {
  146. case VK_RETURN:
  147. OnButton1();
  148. return 1;
  149. case 0x43: // copy
  150. if ((GetKeyState(VK_CONTROL) & 0x80))
  151. {
  152. GetFocus()->SendMessage(WM_COPY);
  153. return TRUE;
  154. }
  155. break;
  156. case 0x56: //Ctrl + V:
  157. if ((GetKeyState(VK_CONTROL) & 0x80))
  158. {
  159. GetFocus()->SendMessage(WM_PASTE);
  160. return TRUE;
  161. }
  162. break;
  163. case 0x58: // cut
  164. if ((GetKeyState(VK_CONTROL) & 0x80))
  165. {
  166. GetFocus()->SendMessage(WM_CUT);
  167. return TRUE;
  168. }
  169. break;
  170. case 0x5A: //undo
  171. case 0x59: //redo
  172. if ((GetKeyState(VK_CONTROL) & 0x80))
  173. {
  174. GetFocus()->SendMessage(WM_UNDO);
  175. return TRUE;
  176. }
  177. break;
  178. }
  179. }
  180. return MyFormView::PreTranslateMessage(pMsg);
  181. }
  182. catch (...)
  183. {
  184. }
  185. return TRUE;
  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. }