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_AryStaff.GetSize (); i++)
  98. {
  99. // 员工姓名;
  100. m_combo1.AddString (DAL::GetStaffName(i) );
  101. }
  102. FillGrid();
  103. m_combo1.GetWindowRect (rc2);
  104. ScreenToClient(rc2);
  105. rc2.bottom +=200;
  106. m_combo1.MoveWindow (rc2);
  107. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  108. SetComboHei(&m_combo1, rc2.Height ());
  109. GetDlgItem(IDC_BUTmodify)->EnableWindow(IsHasRights2new(2));
  110. }
  111. void TakeControlForm::FillGrid(BOOL bStatus)
  112. {
  113. m_List1.DeleteAllItems2 ();
  114. int ii=0;
  115. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  116. int count=0;
  117. if(m_filter.IsEmpty ())
  118. {
  119. if(bStatus)
  120. {
  121. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  122. {
  123. if(m_List1array.ElementAt (ii).ElementAt (0).IsEmpty ())
  124. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  125. }
  126. }
  127. else
  128. {
  129. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  130. {
  131. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  132. }
  133. }
  134. }
  135. else
  136. {
  137. if(bStatus)
  138. {
  139. int type=GetType(m_filter);
  140. if(type==1)//电话
  141. {
  142. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  143. {
  144. if(m_List1array.ElementAt (ii).ElementAt (0).IsEmpty () && (m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 || \
  145. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1))
  146. {
  147. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  148. }
  149. }
  150. }
  151. else if(type==2)//拼音
  152. {
  153. m_filter.MakeUpper ();
  154. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  155. {
  156. if(m_List1array.ElementAt (ii).ElementAt (0).IsEmpty ()&& (m_List1array.ElementAt (ii).ElementAt (11).Find (m_filter)!=-1 || \
  157. m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1))
  158. {
  159. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  160. }
  161. }
  162. }
  163. else
  164. {
  165. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  166. {//0,2,3,4,5,6,7,8,9,10
  167. if(m_List1array.ElementAt (ii).ElementAt (0).IsEmpty ()&&(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 || \
  168. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 ||\
  169. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 ||\
  170. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 ||\
  171. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 ||\
  172. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1 ||\
  173. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 ||\
  174. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 ||\
  175. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 ||\
  176. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1))
  177. {
  178. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  179. }
  180. }
  181. }
  182. }
  183. else
  184. {
  185. int type=GetType(m_filter);
  186. if(type==1)//电话
  187. {
  188. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  189. {
  190. if(m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 || \
  191. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1)
  192. {
  193. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  194. }
  195. }
  196. }
  197. else if(type==2)//拼音
  198. {
  199. m_filter.MakeUpper ();
  200. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  201. {
  202. if(m_List1array.ElementAt (ii).ElementAt (11).Find (m_filter)!=-1 || \
  203. m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1)
  204. {
  205. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  206. }
  207. }
  208. }
  209. else
  210. {
  211. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  212. {//0,2,3,4,5,6,7,8,9,10
  213. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 || \
  214. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 ||\
  215. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 ||\
  216. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 ||\
  217. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 ||\
  218. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1 ||\
  219. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 ||\
  220. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 ||\
  221. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 ||\
  222. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1)
  223. {
  224. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  225. }
  226. }
  227. }
  228. }
  229. }
  230. m_List1.m_arLabels.SetSize(count, 1);
  231. ii=count;
  232. m_List1.m_LabelCount=ii;
  233. m_List1.SetItemCountEx (ii);
  234. }
  235. void TakeControlForm::OnBUTclose()
  236. {
  237. // TODO: Add your control notification handler code here
  238. GetParent()->SendMessage(WM_CLOSE);
  239. }
  240. void TakeControlForm::OnButton1()
  241. {
  242. // TODO: Add your control notification handler code here
  243. UpdateData();
  244. m_filter.TrimLeft ();
  245. m_filter.TrimRight ();
  246. FillGrid();
  247. }
  248. void TakeControlForm::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  249. {
  250. // TODO: Add your control notification handler code here
  251. OnBUTmodify();
  252. *pResult = 0;
  253. }
  254. void TakeControlForm::OnSelchangeCombo1()
  255. {
  256. // TODO: Add your control notification handler code here
  257. SetTimer(1, 100, NULL);
  258. }
  259. void TakeControlForm::OnTimer(UINT nIDEvent)
  260. {
  261. // TODO: Add your message handler code here and/or call default
  262. KillTimer(nIDEvent);
  263. OnButton1();
  264. }
  265. void TakeControlForm::OnBUTmodify()
  266. {
  267. // TODO: Add your control notification handler code here
  268. if(IsHasRights2new(2)==0)return;
  269. POSITION pos;
  270. pos=m_List1.GetFirstSelectedItemPosition();
  271. if(pos==NULL)
  272. {
  273. return;
  274. }
  275. int iItem=m_List1.GetNextSelectedItem(pos);
  276. CString id=m_List1.GetItemText (iItem, 2);
  277. TakeControlDlg dlg;
  278. dlg.id =id;
  279. if(dlg.DoModal ()==IDOK)
  280. {
  281. for(int i=0; i<m_List1array.GetSize (); i++)
  282. {
  283. if(dlg.id==m_List1array.ElementAt (i).ElementAt (2))
  284. {
  285. m_List1array.ElementAt (i).SetAt (0, dlg.m_time2 );
  286. m_List1array.ElementAt (i).SetAt (1, dlg.m_taketime );
  287. m_List1array.ElementAt (i).SetAt (8, dlg.m_waiter1 );
  288. m_List1array.ElementAt (i).SetAt (9, dlg.m_waiter2 );
  289. FillGrid();
  290. break;
  291. }
  292. }
  293. }
  294. }
  295. BOOL TakeControlForm::PreTranslateMessage(MSG* pMsg)
  296. {
  297. // TODO: Add your specialized code here and/or call the base class
  298. try
  299. {
  300. if(pMsg->message==WM_KEYDOWN)
  301. {
  302. switch (pMsg->wParam)
  303. {
  304. case VK_RETURN:
  305. OnButton1();
  306. return 1;
  307. case 0x43: // copy
  308. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  309. {
  310. GetFocus()->SendMessage(WM_COPY);
  311. return TRUE;
  312. }
  313. break;
  314. case 0x56: //Ctrl + V:
  315. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  316. {
  317. GetFocus()->SendMessage(WM_PASTE);
  318. return TRUE;
  319. }
  320. break;
  321. case 0x58: // cut
  322. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  323. {
  324. GetFocus()->SendMessage(WM_CUT);
  325. return TRUE;
  326. }
  327. break;
  328. case 0x5A: //undo
  329. case 0x59: //redo
  330. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  331. {
  332. GetFocus()->SendMessage(WM_UNDO);
  333. return TRUE;
  334. }
  335. break;
  336. }
  337. }
  338. return MyFormView::PreTranslateMessage(pMsg);
  339. }
  340. catch(...)
  341. {
  342. }
  343. }
  344. void TakeControlForm::OnButton2()
  345. {
  346. // TODO: Add your control notification handler code here
  347. UpdateData();
  348. m_filter.TrimLeft ();
  349. m_filter.TrimRight ();
  350. FillGrid(1);
  351. }