SearchTake5.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. // SearchTake5.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "SearchTake5.h"
  6. #include "TakeControlDlg9.h"
  7. #include "SearchFilter2.h"
  8. #include "InputDate.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // SearchTake5 dialog
  16. SearchTake5::SearchTake5(CWnd* pParent /*=NULL*/)
  17. : CDialog(SearchTake5::IDD, pParent)
  18. {
  19. //{{AFX_DATA_INIT(SearchTake5)
  20. m_filter = _T("");
  21. m_radio1 = 1;
  22. //}}AFX_DATA_INIT
  23. }
  24. void SearchTake5::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(SearchTake5)
  28. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  29. DDX_Control(pDX, IDC_LIST2, m_List1);
  30. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  31. DDX_Radio(pDX, IDC_RADIO1, m_radio1);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(SearchTake5, CDialog)
  35. //{{AFX_MSG_MAP(SearchTake5)
  36. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  37. ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
  38. ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  39. ON_BN_CLICKED(IDC_RADIO9, OnRadio9)
  40. ON_CBN_CLOSEUP(IDC_COMBO1, OnCloseupCombo1)
  41. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  42. ON_WM_TIMER()
  43. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  44. ON_BN_CLICKED(IDC_BTNSEARCHFILTER, OnBtnsearchfilter)
  45. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // SearchTake5 message handlers
  50. extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
  51. BOOL SearchTake5::OnInitDialog()
  52. {
  53. CDialog::OnInitDialog();
  54. // TODO: Add extra initialization here
  55. CRect rc2;
  56. GetWindowRect(rc2);
  57. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  58. g_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
  59. g_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
  60. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
  61. m_combo1.GetWindowRect (rc2);
  62. ScreenToClient(rc2);
  63. rc2.bottom +=200;
  64. m_combo1.MoveWindow (rc2);
  65. if(g_bAllBranch==0)
  66. {
  67. m_nAdd=0;
  68. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;男宾电话,100;女宾电话,100;婚庆内容,100;婚庆日期,100;时间,100;婚期,100;摄影师,100;化妆师,100;接单人,100;套系名称,100;套系价格,100" );
  69. m_List1.LoadColumnInfo (208);
  70. }
  71. else
  72. {
  73. m_nAdd=1;
  74. m_List1.SetHeadings("店名,100;订单号,100;男宾姓名,100;女宾姓名,100;男宾电话,100;女宾电话,100;婚庆内容,100;婚庆日期,100;时间,100;婚期,100;摄影师,100;化妆师,100;接单人,100;套系名称,100;套系价格,100" );
  75. m_List1.LoadColumnInfo (209);
  76. }
  77. GetData();
  78. int i = 0;
  79. for( i=0; i<m_List1array.GetSize (); i++)
  80. {
  81. if(::FindArray (&jdarray, m_List1array.ElementAt (i).ElementAt (5+m_nAdd))==-1)
  82. jdarray.Add (m_List1array.ElementAt (i).ElementAt (5+m_nAdd));
  83. }
  84. m_combo1.AddString ("");
  85. for( i=0; i<jdarray.GetSize (); i++)
  86. {
  87. m_combo1.AddString (jdarray.ElementAt (i));
  88. }
  89. return TRUE; // return TRUE unless you set the focus to a control
  90. // EXCEPTION: OCX Property Pages should return FALSE
  91. }
  92. void SearchTake5::OnButton1()
  93. {
  94. // TODO: Add your control notification handler code here
  95. UpdateData();
  96. m_filter.TrimLeft ();
  97. m_filter.TrimRight ();
  98. FillGrid();
  99. }
  100. void SearchTake5::FillGrid()
  101. {
  102. UpdateData();
  103. if(g_bSearchFilter)
  104. {
  105. m_List1.DeleteAllItems2 ();
  106. int ii=0;
  107. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  108. int count=0;
  109. {
  110. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  111. {
  112. if(g_filterdate1!="")
  113. {
  114. if(m_List1array.ElementAt (ii).ElementAt (5+m_nAdd)<g_filterdate1 || m_List1array.ElementAt (ii).ElementAt (5+m_nAdd)>g_filterdate2)
  115. continue;
  116. }
  117. if(g_filterdate3!="")
  118. {
  119. if(m_List1array.ElementAt (ii).ElementAt (6+m_nAdd)<g_filterdate3 || m_List1array.ElementAt (ii).ElementAt (6+m_nAdd)>g_filterdate4)
  120. continue;
  121. }
  122. if(g_filterdate5!="")
  123. {
  124. if(m_List1array.ElementAt (ii).ElementAt (7+m_nAdd)<g_filterdate5 || m_List1array.ElementAt (ii).ElementAt (7+m_nAdd)>g_filterdate6)
  125. continue;
  126. }
  127. if(g_waiter1!="")
  128. {
  129. if(m_List1array.ElementAt (ii).ElementAt (8+m_nAdd)!=g_waiter1)
  130. continue;
  131. }
  132. if(g_bAllBranch && g_filterbranch!="")
  133. {
  134. if(m_List1array.ElementAt (ii).ElementAt (0)!=g_filterbranch)
  135. continue;
  136. }
  137. if(1)
  138. {
  139. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  140. }
  141. }
  142. }
  143. m_List1.m_arLabels.SetSize(count, 1);
  144. ii=count;
  145. m_List1.m_LabelCount=ii;
  146. m_List1.SetItemCountEx (ii);
  147. CString str;
  148. str.Format ("单数:%d", ii);
  149. SetDlgItemText(IDC_STATIC2, str);
  150. }
  151. else
  152. {
  153. m_List1.DeleteAllItems2 ();
  154. int ii=0;
  155. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  156. int count=0;
  157. if(m_filter.IsEmpty ())
  158. {
  159. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  160. {
  161. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  162. }
  163. }
  164. else
  165. {
  166. int type=GetType(m_filter);
  167. if(type==1)//电话
  168. {
  169. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  170. {
  171. if( (m_List1array.ElementAt (ii).ElementAt (3+m_nAdd).Find (m_filter)!=-1 || \
  172. m_List1array.ElementAt (ii).ElementAt (4+m_nAdd).Find (m_filter)!=-1) )
  173. {
  174. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  175. }
  176. }
  177. }
  178. else if(type==2)//拼音
  179. {
  180. m_filter.MakeUpper ();
  181. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  182. {
  183. if( (m_List1array.ElementAt (ii).ElementAt (14+m_nAdd).Find (m_filter)!=-1 || \
  184. m_List1array.ElementAt (ii).ElementAt (15+m_nAdd).Find (m_filter)!=-1) )
  185. {
  186. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  187. }
  188. }
  189. }
  190. else
  191. {
  192. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  193. {
  194. if((m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  195. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  196. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  197. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || \
  198. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 || \
  199. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 || \
  200. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1 || \
  201. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  202. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 || \
  203. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  204. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1|| \
  205. m_List1array.ElementAt (ii).ElementAt (11).Find (m_filter)!=-1|| \
  206. m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1|| \
  207. m_List1array.ElementAt (ii).ElementAt (13+m_nAdd).Find (m_filter)!=-1|| \
  208. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1) )
  209. {
  210. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  211. }
  212. }
  213. }
  214. }
  215. m_List1.m_arLabels.SetSize(count, 1);
  216. ii=count;
  217. m_List1.m_LabelCount=ii;
  218. m_List1.SetItemCountEx (ii);
  219. CString str;
  220. str.Format ("单数:%d", ii);
  221. SetDlgItemText(IDC_STATIC2, str);
  222. }
  223. }
  224. void SearchTake5::OnRadio1()
  225. {
  226. // TODO: Add your control notification handler code here
  227. FillGrid();
  228. }
  229. void SearchTake5::OnRadio2()
  230. {
  231. // TODO: Add your control notification handler code here
  232. FillGrid();
  233. }
  234. void SearchTake5::OnRadio9()
  235. {
  236. // TODO: Add your control notification handler code here
  237. FillGrid();
  238. }
  239. void SearchTake5::OnCloseupCombo1()
  240. {
  241. // TODO: Add your control notification handler code here
  242. SetTimer(1, 100, NULL);
  243. }
  244. void SearchTake5::OnSelchangeCombo1()
  245. {
  246. // TODO: Add your control notification handler code here
  247. SetTimer(1, 100, NULL);
  248. }
  249. void SearchTake5::OnTimer(UINT nIDEvent)
  250. {
  251. // TODO: Add your message handler code here and/or call default
  252. KillTimer(nIDEvent);
  253. OnButton1();
  254. }
  255. void SearchTake5::OnButton2()
  256. {
  257. // TODO: Add your control notification handler code here
  258. POSITION pos;
  259. pos=m_List1.GetFirstSelectedItemPosition();
  260. if(pos==NULL)
  261. {
  262. AfxMessageBox("请先选中您要安排的客人!", MB_ICONINFORMATION);
  263. return;
  264. }
  265. int iItem;
  266. CStringArray idarray;
  267. CStringArray brancharray;
  268. while (pos)
  269. {
  270. iItem = m_List1.GetNextSelectedItem(pos);
  271. idarray.Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  272. if(g_bAllBranch)
  273. brancharray.Add (m_List1.GetItemText (iItem, 0));
  274. }
  275. if(idarray.GetSize ()==1)
  276. {
  277. CString id=idarray.ElementAt (0);
  278. TakeControlDlg9 dlg;
  279. if(g_bAllBranch)
  280. dlg.m_branch=brancharray.ElementAt (0);
  281. dlg.id=id;
  282. dlg.m_bModify=1;
  283. dlg.DoModal ();
  284. }
  285. else
  286. {
  287. TakeControlDlg9 dlg;
  288. dlg.m_pIdArray=&idarray;
  289. dlg.m_pBranchArray=&brancharray;
  290. dlg.m_bModify=1;
  291. dlg.DoModal ();
  292. }
  293. if(g_bAllBranch)
  294. {
  295. if(AfxMessageBox("是否实时更新数据?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  296. }
  297. GetData();
  298. }
  299. void SearchTake5::OnOK()
  300. {
  301. // TODO: Add extra validation here
  302. }
  303. BOOL SearchTake5::PreTranslateMessage(MSG* pMsg)
  304. {
  305. // TODO: Add your specialized code here and/or call the base class
  306. if(pMsg->message==WM_KEYDOWN)
  307. {
  308. switch (pMsg->wParam)
  309. {
  310. case VK_RETURN:
  311. OnButton1();
  312. return 1;
  313. break;
  314. }
  315. }
  316. return CDialog::PreTranslateMessage(pMsg);
  317. }
  318. void SearchTake5::HidePrice()
  319. {
  320. if(IsHasRights2new(31))return;
  321. for(int i=0; i< m_List1array.GetSize (); i++)
  322. {
  323. m_List1array.ElementAt (i).SetAt (16+m_nAdd, "***");
  324. m_List1array.ElementAt (i).SetAt (17+m_nAdd, "***");
  325. }
  326. }
  327. void SearchTake5::OnBtnsearchfilter()
  328. {
  329. // TODO: Add your control notification handler code here
  330. SearchFilter2 dlg;
  331. dlg.m_pArray=&jdarray;
  332. if(dlg.DoModal ()==IDOK)
  333. {
  334. FillGrid();
  335. }
  336. g_bSearchFilter=0;
  337. }
  338. void SearchTake5::OnButton3()
  339. {
  340. // TODO: Add your control notification handler code here
  341. POSITION pos;
  342. pos=m_List1.GetFirstSelectedItemPosition();
  343. if(pos==NULL)
  344. {
  345. AfxMessageBox("请选中多对客人!", MB_ICONINFORMATION);
  346. return;
  347. }
  348. int iItem;
  349. if(g_bAllBranch)
  350. {
  351. CStringArray idarray[100];
  352. CStringArray jdarray[100];
  353. CStringArray brancharray;
  354. int idcount=0;
  355. int branchpos;
  356. CString branch;
  357. while (pos)
  358. {
  359. iItem = m_List1.GetNextSelectedItem(pos);
  360. branchpos=::FindArray(&brancharray, m_List1.GetItemText (iItem, 0) );if(branchpos>=100)continue;
  361. if(branchpos==-1)
  362. {
  363. branchpos=brancharray.GetSize();
  364. brancharray.Add(m_List1.GetItemText (iItem, 0));
  365. }
  366. idarray[branchpos].Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  367. jdarray[branchpos].Add (m_List1.GetItemText (iItem, 5+m_nAdd));
  368. idcount++;
  369. }
  370. if(idcount==1)
  371. {
  372. AfxMessageBox("请选中多对客人,或者按预约按钮!", MB_ICONINFORMATION);
  373. return;
  374. }
  375. else
  376. {
  377. InputDate dlg;
  378. dlg.m_mode=1;
  379. if(dlg.DoModal ()!=IDOK)return;
  380. for(int aa=0; aa<brancharray.GetSize(); aa++)
  381. {
  382. branch=brancharray.ElementAt(aa);
  383. CString sql;
  384. sql.Format ("update dindansp set [hqdate]='%s',hqtime='' where ", dlg.m_date);
  385. CString filter,temp;
  386. for(int i=0; i<idarray[aa].GetSize (); i++)
  387. {
  388. if(i==0)
  389. temp="[id]='"+idarray[aa].ElementAt (i)+"' and [name]='"+jdarray[aa].ElementAt (i)+"'";
  390. else
  391. temp=" or [id]='"+idarray[aa].ElementAt (i)+"' and [name]='"+jdarray[aa].ElementAt (i)+"'";
  392. filter+=temp;
  393. }
  394. sql+=filter;
  395. g_sendhead.bsql=1;
  396. g_branchip=GetIP(branch);
  397. g_pMainWnd->OnDisconnect();
  398. g_branchname=branch;
  399. g_bBranchModify=1;
  400. g_pMainWnd->ProcessChatMessageRequest2(sql);
  401. g_pMainWnd->OnDisconnect();g_bBranchModify=0;g_branchip=g_branchname="";
  402. if(g_bSendOK==0)
  403. {
  404. sql.Format("保存分店: %s 失败!", branch);
  405. AfxMessageBox(sql, MB_ICONINFORMATION);
  406. continue;
  407. }
  408. }
  409. }
  410. if(AfxMessageBox("是否实时更新数据?", MB_YESNO|MB_ICONINFORMATION)==IDYES)GetData();
  411. }
  412. else
  413. {
  414. CStringArray idarray;
  415. CStringArray jdarray;
  416. while (pos)
  417. {
  418. iItem = m_List1.GetNextSelectedItem(pos);
  419. idarray.Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  420. jdarray.Add (m_List1.GetItemText (iItem, 5+m_nAdd));
  421. }
  422. if(idarray.GetSize ()==1)
  423. {
  424. AfxMessageBox("请选中多对客人,或者按预约按钮!", MB_ICONINFORMATION);
  425. return;
  426. }
  427. else
  428. {
  429. InputDate dlg;
  430. dlg.m_mode=1;
  431. if(dlg.DoModal ()!=IDOK)return;
  432. CString sql;
  433. sql.Format ("update dindansp set [hqdate]='%s',hqtime='' where ", dlg.m_date);
  434. CString filter,temp;
  435. for(int i=0; i<idarray.GetSize (); i++)
  436. {
  437. if(i==0)
  438. temp="[id]='"+idarray.ElementAt (i)+"' and [name]='"+jdarray.ElementAt (i)+"'";
  439. else
  440. temp=" or [id]='"+idarray.ElementAt (i)+"' and [name]='"+jdarray.ElementAt (i)+"'";
  441. filter+=temp;
  442. }
  443. sql+=filter;
  444. g_sendhead.bsql=1;
  445. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  446. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  447. }
  448. GetData();
  449. }
  450. }
  451. void SearchTake5::GetData()
  452. {
  453. CString sql;
  454. sql.Format ("kind='2'");
  455. if(g_bAllBranch==0)
  456. {
  457. g_sendhead.code[0]=139;
  458. g_sendhead.tabcount=1;
  459. g_sendhead.bsql=0;
  460. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  461. DataToArray(&m_List1array);
  462. HidePrice();
  463. FillGrid();
  464. return;
  465. }
  466. //////////////数据汇总
  467. m_List1array.RemoveAll ();
  468. CStringArray failbrancharray;
  469. CString branch;
  470. int i = 0;
  471. for( i=-1; i<g_brancharray.GetSize ()-1; i++)
  472. {
  473. if(i!=-1)
  474. {
  475. branch=g_brancharray.ElementAt (i).ElementAt (0);
  476. g_branchip=g_brancharray.ElementAt (i).ElementAt (1);
  477. g_pMainWnd->OnDisconnect();
  478. g_branchname=branch;
  479. g_bBranchModify=1;
  480. }
  481. else
  482. branch=g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0);
  483. g_sendhead.bsql=0;
  484. g_sendhead.code[0]=139;
  485. g_sendhead.tabcount=1;
  486. g_pMainWnd->ProcessChatMessageRequest2(sql);
  487. if(g_bSendOK==0)
  488. {
  489. failbrancharray.Add (branch);
  490. continue;
  491. }
  492. CArray<CStringArray, CStringArray>List1array;
  493. DataToArray(&List1array);
  494. int size=m_List1array.GetSize ();
  495. for(int j=0; j<List1array.GetSize (); j++)
  496. {
  497. size++;
  498. m_List1array.SetSize(size , 1 );
  499. size--;
  500. m_List1array.ElementAt (size).Copy (List1array.ElementAt (j));
  501. m_List1array.ElementAt (size).InsertAt (0, branch);
  502. size++;
  503. }
  504. }
  505. for(i=0; i<failbrancharray.GetSize (); i++)
  506. {
  507. // AfxMessageBox("连接"+failbrancharray.ElementAt(i)+"服务器失败!", MB_ICONINFORMATION);
  508. }
  509. g_pMainWnd->OnDisconnect();
  510. g_bBranchModify=0;g_branchip=g_branchname="";
  511. HidePrice();
  512. FillGrid();
  513. }