TakeControlForm.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. // TakeControlForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "TakeControlForm.h"
  6. #include "MyMdi.H"
  7. #include "TakeControlDlg.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // TakeControlForm
  15. IMPLEMENT_DYNCREATE(TakeControlForm, MyFormView)
  16. TakeControlForm::TakeControlForm()
  17. : MyFormView(TakeControlForm::IDD)
  18. {
  19. //{{AFX_DATA_INIT(TakeControlForm)
  20. m_filter = _T("");
  21. //}}AFX_DATA_INIT
  22. }
  23. TakeControlForm::~TakeControlForm()
  24. {
  25. }
  26. void TakeControlForm::DoDataExchange(CDataExchange* pDX)
  27. {
  28. MyFormView::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(TakeControlForm)
  30. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  31. DDX_Control(pDX, IDC_LIST2, m_List1);
  32. DDX_Control(pDX, IDC_STATIC1, m_static1);
  33. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  34. //}}AFX_DATA_MAP
  35. }
  36. BEGIN_MESSAGE_MAP(TakeControlForm, MyFormView)
  37. //{{AFX_MSG_MAP(TakeControlForm)
  38. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  39. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  40. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  41. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  42. ON_WM_TIMER()
  43. ON_BN_CLICKED(IDC_BUTmodify, OnBUTmodify)
  44. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // TakeControlForm diagnostics
  49. #ifdef _DEBUG
  50. void TakeControlForm::AssertValid() const
  51. {
  52. MyFormView::AssertValid();
  53. }
  54. void TakeControlForm::Dump(CDumpContext& dc) const
  55. {
  56. MyFormView::Dump(dc);
  57. }
  58. #endif //_DEBUG
  59. /////////////////////////////////////////////////////////////////////////////
  60. // TakeControlForm message handlers
  61. void TakeControlForm::OnInitialUpdate()
  62. {
  63. MyFormView::OnInitialUpdate();
  64. // TODO: Add your specialized code here and/or call the base class
  65. CMyMdi Mdi;
  66. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  67. // Here we create the outbar control using the splitter as its parent
  68. // and setting its id to the first pane.
  69. CRect rc2;
  70. GetWindowRect(rc2);
  71. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  72. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  73. m_static1.SetFont(&g_titlefont);
  74. #ifdef CHILD_VERSION
  75. m_List1.SetHeadings("拍摄日期,100;拍摄时间,100;订单号,100;家长姓名,100;宝宝姓名,100;手机,100;固定电话,100;套系名称,100;摄影师,100;化妆师,100;门市,100");
  76. #else
  77. m_List1.SetHeadings("拍摄日期,100;拍摄时间,100;订单号,100;男宾姓名,100;女宾姓名,100;男宾电话,100;女宾电话,100;套系名称,100;摄影师,100;化妆师,100;门市,100" );
  78. #endif
  79. m_List1.LoadColumnInfo(113);
  80. if (g_bShowOK == 0)
  81. {
  82. CString filter = "status3='未取'";
  83. g_sendhead.bsql = 0;
  84. g_sendhead.code[0] = 53;
  85. g_sendhead.tabcount = 1;
  86. g_pMainWnd->ProcessChatMessageRequest2(filter); if (g_bSendOK == 0)return;
  87. }
  88. else
  89. {
  90. g_sendhead.bsql = 0;
  91. g_sendhead.code[0] = 53;
  92. g_sendhead.tabcount = 1;
  93. g_pMainWnd->ProcessChatMessageRequest2(53); if (g_bSendOK == 0)return;
  94. }
  95. DataToArray(&m_List1array);
  96. m_combo1.AddString(g_user.name);
  97. for (int i = 0; i < g_userarray.GetSize(); i++)
  98. {
  99. m_combo1.AddString(g_userarray.ElementAt(i).ElementAt(1));
  100. }
  101. FillGrid();
  102. m_combo1.GetWindowRect(rc2);
  103. ScreenToClient(rc2);
  104. rc2.bottom += 200;
  105. m_combo1.MoveWindow(rc2);
  106. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  107. SetComboHei(&m_combo1, rc2.Height());
  108. GetDlgItem(IDC_BUTmodify)->EnableWindow(IsHasRights2new(2));
  109. }
  110. void TakeControlForm::FillGrid(BOOL bStatus)
  111. {
  112. m_List1.DeleteAllItems2();
  113. int ii = 0;
  114. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  115. int count = 0;
  116. if (m_filter.IsEmpty())
  117. {
  118. if (bStatus)
  119. {
  120. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  121. {
  122. if (m_List1array.ElementAt(ii).ElementAt(0).IsEmpty())
  123. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  124. }
  125. }
  126. else
  127. {
  128. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  129. {
  130. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  131. }
  132. }
  133. }
  134. else
  135. {
  136. if (bStatus)
  137. {
  138. int type = GetType(m_filter);
  139. if (type == 1)//电话
  140. {
  141. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  142. {
  143. if (m_List1array.ElementAt(ii).ElementAt(0).IsEmpty() && (m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \
  144. m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1))
  145. {
  146. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  147. }
  148. }
  149. }
  150. else if (type == 2)//拼音
  151. {
  152. m_filter.MakeUpper();
  153. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  154. {
  155. if (m_List1array.ElementAt(ii).ElementAt(0).IsEmpty() && (m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1 || \
  156. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1))
  157. {
  158. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  159. }
  160. }
  161. }
  162. else
  163. {
  164. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  165. {//0,2,3,4,5,6,7,8,9,10
  166. if (m_List1array.ElementAt(ii).ElementAt(0).IsEmpty() && (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  167. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  168. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  169. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
  170. m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \
  171. m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1 || \
  172. m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \
  173. m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \
  174. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \
  175. m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1))
  176. {
  177. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  178. }
  179. }
  180. }
  181. }
  182. else
  183. {
  184. int type = GetType(m_filter);
  185. if (type == 1)//电话
  186. {
  187. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  188. {
  189. if (m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \
  190. m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1)
  191. {
  192. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  193. }
  194. }
  195. }
  196. else if (type == 2)//拼音
  197. {
  198. m_filter.MakeUpper();
  199. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  200. {
  201. if (m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1 || \
  202. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1)
  203. {
  204. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  205. }
  206. }
  207. }
  208. else
  209. {
  210. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  211. {//0,2,3,4,5,6,7,8,9,10
  212. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  213. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  214. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  215. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
  216. m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \
  217. m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1 || \
  218. m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \
  219. m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \
  220. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \
  221. m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1)
  222. {
  223. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  224. }
  225. }
  226. }
  227. }
  228. }
  229. m_List1.m_arLabels.SetSize(count, 1);
  230. ii = count;
  231. m_List1.m_LabelCount = ii;
  232. m_List1.SetItemCountEx(ii);
  233. }
  234. void TakeControlForm::OnBUTclose()
  235. {
  236. // TODO: Add your control notification handler code here
  237. GetParent()->SendMessage(WM_CLOSE);
  238. }
  239. void TakeControlForm::OnButton1()
  240. {
  241. // TODO: Add your control notification handler code here
  242. UpdateData();
  243. m_filter.TrimLeft();
  244. m_filter.TrimRight();
  245. FillGrid();
  246. }
  247. void TakeControlForm::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  248. {
  249. // TODO: Add your control notification handler code here
  250. OnBUTmodify();
  251. *pResult = 0;
  252. }
  253. void TakeControlForm::OnSelchangeCombo1()
  254. {
  255. // TODO: Add your control notification handler code here
  256. SetTimer(1, 100, NULL);
  257. }
  258. void TakeControlForm::OnTimer(UINT nIDEvent)
  259. {
  260. // TODO: Add your message handler code here and/or call default
  261. KillTimer(nIDEvent);
  262. OnButton1();
  263. }
  264. void TakeControlForm::OnBUTmodify()
  265. {
  266. // TODO: Add your control notification handler code here
  267. if (IsHasRights2new(2) == 0)return;
  268. POSITION pos;
  269. pos = m_List1.GetFirstSelectedItemPosition();
  270. if (pos == NULL)
  271. {
  272. return;
  273. }
  274. int iItem = m_List1.GetNextSelectedItem(pos);
  275. CString id = m_List1.GetItemText(iItem, 2);
  276. TakeControlDlg dlg;
  277. dlg.id = id;
  278. if (dlg.DoModal() == IDOK)
  279. {
  280. for (int i = 0; i < m_List1array.GetSize(); i++)
  281. {
  282. if (dlg.id == m_List1array.ElementAt(i).ElementAt(2))
  283. {
  284. m_List1array.ElementAt(i).SetAt(0, dlg.m_time2);
  285. m_List1array.ElementAt(i).SetAt(1, dlg.m_taketime);
  286. m_List1array.ElementAt(i).SetAt(8, dlg.m_waiter1);
  287. m_List1array.ElementAt(i).SetAt(9, dlg.m_waiter2);
  288. FillGrid();
  289. break;
  290. }
  291. }
  292. }
  293. }
  294. BOOL TakeControlForm::PreTranslateMessage(MSG* pMsg)
  295. {
  296. // TODO: Add your specialized code here and/or call the base class
  297. try
  298. {
  299. if (pMsg->message == WM_KEYDOWN)
  300. {
  301. switch (pMsg->wParam)
  302. {
  303. case VK_RETURN:
  304. OnButton1();
  305. return 1;
  306. case 0x43: // copy
  307. if ((GetKeyState(VK_CONTROL) & 0x80))
  308. {
  309. GetFocus()->SendMessage(WM_COPY);
  310. return TRUE;
  311. }
  312. break;
  313. case 0x56: //Ctrl + V:
  314. if ((GetKeyState(VK_CONTROL) & 0x80))
  315. {
  316. GetFocus()->SendMessage(WM_PASTE);
  317. return TRUE;
  318. }
  319. break;
  320. case 0x58: // cut
  321. if ((GetKeyState(VK_CONTROL) & 0x80))
  322. {
  323. GetFocus()->SendMessage(WM_CUT);
  324. return TRUE;
  325. }
  326. break;
  327. case 0x5A: //undo
  328. case 0x59: //redo
  329. if ((GetKeyState(VK_CONTROL) & 0x80))
  330. {
  331. GetFocus()->SendMessage(WM_UNDO);
  332. return TRUE;
  333. }
  334. break;
  335. }
  336. }
  337. return MyFormView::PreTranslateMessage(pMsg);
  338. }
  339. catch (...)
  340. {
  341. }
  342. }
  343. void TakeControlForm::OnButton2()
  344. {
  345. // TODO: Add your control notification handler code here
  346. UpdateData();
  347. m_filter.TrimLeft();
  348. m_filter.TrimRight();
  349. FillGrid(1);
  350. }