SearchTake5.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  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. int i = 0;
  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. for( i=0; i<m_List1array.GetSize (); i++)
  79. {
  80. if(::FindArray (&jdarray, m_List1array.ElementAt (i).ElementAt (5+m_nAdd))==-1)
  81. jdarray.Add (m_List1array.ElementAt (i).ElementAt (5+m_nAdd));
  82. }
  83. m_combo1.AddString ("");
  84. for( i=0; i<jdarray.GetSize (); i++)
  85. {
  86. m_combo1.AddString (jdarray.ElementAt (i));
  87. }
  88. return TRUE; // return TRUE unless you set the focus to a control
  89. // EXCEPTION: OCX Property Pages should return FALSE
  90. }
  91. void SearchTake5::OnButton1()
  92. {
  93. // TODO: Add your control notification handler code here
  94. UpdateData();
  95. m_filter.TrimLeft ();
  96. m_filter.TrimRight ();
  97. FillGrid();
  98. }
  99. void SearchTake5::FillGrid()
  100. {
  101. UpdateData();
  102. if(g_bSearchFilter)
  103. {
  104. m_List1.DeleteAllItems2 ();
  105. int ii=0;
  106. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  107. int count=0;
  108. {
  109. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  110. {
  111. if(g_filterdate1!="")
  112. {
  113. if(m_List1array.ElementAt (ii).ElementAt (5+m_nAdd)<g_filterdate1 || m_List1array.ElementAt (ii).ElementAt (5+m_nAdd)>g_filterdate2)
  114. continue;
  115. }
  116. if(g_filterdate3!="")
  117. {
  118. if(m_List1array.ElementAt (ii).ElementAt (6+m_nAdd)<g_filterdate3 || m_List1array.ElementAt (ii).ElementAt (6+m_nAdd)>g_filterdate4)
  119. continue;
  120. }
  121. if(g_filterdate5!="")
  122. {
  123. if(m_List1array.ElementAt (ii).ElementAt (7+m_nAdd)<g_filterdate5 || m_List1array.ElementAt (ii).ElementAt (7+m_nAdd)>g_filterdate6)
  124. continue;
  125. }
  126. if(g_waiter1!="")
  127. {
  128. if(m_List1array.ElementAt (ii).ElementAt (8+m_nAdd)!=g_waiter1)
  129. continue;
  130. }
  131. if(g_bAllBranch && g_filterbranch!="")
  132. {
  133. if(m_List1array.ElementAt (ii).ElementAt (0)!=g_filterbranch)
  134. continue;
  135. }
  136. if(1)
  137. {
  138. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  139. }
  140. }
  141. }
  142. m_List1.m_arLabels.SetSize(count, 1);
  143. ii=count;
  144. m_List1.m_LabelCount=ii;
  145. m_List1.SetItemCountEx (ii);
  146. CString str;
  147. str.Format ("单数:%d", ii);
  148. SetDlgItemText(IDC_STATIC2, str);
  149. }
  150. else
  151. {
  152. m_List1.DeleteAllItems2 ();
  153. int ii=0;
  154. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  155. int count=0;
  156. if(m_filter.IsEmpty ())
  157. {
  158. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  159. {
  160. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  161. }
  162. }
  163. else
  164. {
  165. int type=GetType(m_filter);
  166. if(type==1)//电话
  167. {
  168. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  169. {
  170. if( (m_List1array.ElementAt (ii).ElementAt (3+m_nAdd).Find (m_filter)!=-1 || \
  171. m_List1array.ElementAt (ii).ElementAt (4+m_nAdd).Find (m_filter)!=-1) )
  172. {
  173. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  174. }
  175. }
  176. }
  177. else if(type==2)//拼音
  178. {
  179. m_filter.MakeUpper ();
  180. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  181. {
  182. if( (m_List1array.ElementAt (ii).ElementAt (14+m_nAdd).Find (m_filter)!=-1 || \
  183. m_List1array.ElementAt (ii).ElementAt (15+m_nAdd).Find (m_filter)!=-1) )
  184. {
  185. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  186. }
  187. }
  188. }
  189. else
  190. {
  191. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  192. {
  193. if((m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  194. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  195. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  196. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || \
  197. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 || \
  198. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 || \
  199. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1 || \
  200. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  201. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 || \
  202. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  203. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1|| \
  204. m_List1array.ElementAt (ii).ElementAt (11).Find (m_filter)!=-1|| \
  205. m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1|| \
  206. m_List1array.ElementAt (ii).ElementAt (13+m_nAdd).Find (m_filter)!=-1|| \
  207. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1) )
  208. {
  209. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  210. }
  211. }
  212. }
  213. }
  214. m_List1.m_arLabels.SetSize(count, 1);
  215. ii=count;
  216. m_List1.m_LabelCount=ii;
  217. m_List1.SetItemCountEx (ii);
  218. CString str;
  219. str.Format ("单数:%d", ii);
  220. SetDlgItemText(IDC_STATIC2, str);
  221. }
  222. }
  223. void SearchTake5::OnRadio1()
  224. {
  225. // TODO: Add your control notification handler code here
  226. FillGrid();
  227. }
  228. void SearchTake5::OnRadio2()
  229. {
  230. // TODO: Add your control notification handler code here
  231. FillGrid();
  232. }
  233. void SearchTake5::OnRadio9()
  234. {
  235. // TODO: Add your control notification handler code here
  236. FillGrid();
  237. }
  238. void SearchTake5::OnCloseupCombo1()
  239. {
  240. // TODO: Add your control notification handler code here
  241. SetTimer(1, 100, NULL);
  242. }
  243. void SearchTake5::OnSelchangeCombo1()
  244. {
  245. // TODO: Add your control notification handler code here
  246. SetTimer(1, 100, NULL);
  247. }
  248. void SearchTake5::OnTimer(UINT nIDEvent)
  249. {
  250. // TODO: Add your message handler code here and/or call default
  251. KillTimer(nIDEvent);
  252. OnButton1();
  253. }
  254. void SearchTake5::OnButton2()
  255. {
  256. // TODO: Add your control notification handler code here
  257. POSITION pos;
  258. pos=m_List1.GetFirstSelectedItemPosition();
  259. if(pos==NULL)
  260. {
  261. AfxMessageBox("请先选中您要安排的客人!", MB_ICONINFORMATION);
  262. return;
  263. }
  264. int iItem;
  265. CStringArray idarray;
  266. CStringArray brancharray;
  267. while (pos)
  268. {
  269. iItem = m_List1.GetNextSelectedItem(pos);
  270. idarray.Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  271. if(g_bAllBranch)
  272. brancharray.Add (m_List1.GetItemText (iItem, 0));
  273. }
  274. if(idarray.GetSize ()==1)
  275. {
  276. CString id=idarray.ElementAt (0);
  277. TakeControlDlg9 dlg;
  278. if(g_bAllBranch)
  279. dlg.m_branch=brancharray.ElementAt (0);
  280. dlg.id=id;
  281. dlg.m_bModify=1;
  282. dlg.DoModal ();
  283. }
  284. else
  285. {
  286. TakeControlDlg9 dlg;
  287. dlg.m_pIdArray=&idarray;
  288. dlg.m_pBranchArray=&brancharray;
  289. dlg.m_bModify=1;
  290. dlg.DoModal ();
  291. }
  292. if(g_bAllBranch)
  293. {
  294. if(AfxMessageBox("是否实时更新数据?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  295. }
  296. GetData();
  297. }
  298. void SearchTake5::OnOK()
  299. {
  300. // TODO: Add extra validation here
  301. }
  302. BOOL SearchTake5::PreTranslateMessage(MSG* pMsg)
  303. {
  304. // TODO: Add your specialized code here and/or call the base class
  305. if(pMsg->message==WM_KEYDOWN)
  306. {
  307. switch (pMsg->wParam)
  308. {
  309. case VK_RETURN:
  310. OnButton1();
  311. return 1;
  312. break;
  313. }
  314. }
  315. return CDialog::PreTranslateMessage(pMsg);
  316. }
  317. void SearchTake5::HidePrice()
  318. {
  319. return;
  320. }
  321. void SearchTake5::OnBtnsearchfilter()
  322. {
  323. // TODO: Add your control notification handler code here
  324. SearchFilter2 dlg;
  325. dlg.m_pArray=&jdarray;
  326. if(dlg.DoModal ()==IDOK)
  327. {
  328. FillGrid();
  329. }
  330. g_bSearchFilter=0;
  331. }
  332. void SearchTake5::OnButton3()
  333. {
  334. // TODO: Add your control notification handler code here
  335. POSITION pos;
  336. pos=m_List1.GetFirstSelectedItemPosition();
  337. if(pos==NULL)
  338. {
  339. AfxMessageBox("请选中多对客人!", MB_ICONINFORMATION);
  340. return;
  341. }
  342. int iItem;
  343. if(g_bAllBranch)
  344. {
  345. CStringArray idarray[100];
  346. CStringArray jdarray[100];
  347. CStringArray brancharray;
  348. int idcount=0;
  349. int branchpos;
  350. CString branch;
  351. while (pos)
  352. {
  353. iItem = m_List1.GetNextSelectedItem(pos);
  354. branchpos=::FindArray(&brancharray, m_List1.GetItemText (iItem, 0) );if(branchpos>=100)continue;
  355. if(branchpos==-1)
  356. {
  357. branchpos=brancharray.GetSize();
  358. brancharray.Add(m_List1.GetItemText (iItem, 0));
  359. }
  360. idarray[branchpos].Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  361. jdarray[branchpos].Add (m_List1.GetItemText (iItem, 5+m_nAdd));
  362. idcount++;
  363. }
  364. if(idcount==1)
  365. {
  366. AfxMessageBox("请选中多对客人,或者按预约按钮!", MB_ICONINFORMATION);
  367. return;
  368. }
  369. else
  370. {
  371. InputDate dlg;
  372. dlg.m_mode=1;
  373. if(dlg.DoModal ()!=IDOK)return;
  374. for(int aa=0; aa<brancharray.GetSize(); aa++)
  375. {
  376. branch=brancharray.ElementAt(aa);
  377. CString sql;
  378. sql.Format ("update dindansp set [hqdate]='%s',hqtime='' where ", dlg.m_date);
  379. CString filter,temp;
  380. for(int i=0; i<idarray[aa].GetSize (); i++)
  381. {
  382. if(i==0)
  383. temp="[id]='"+idarray[aa].ElementAt (i)+"' and [name]='"+jdarray[aa].ElementAt (i)+"'";
  384. else
  385. temp=" or [id]='"+idarray[aa].ElementAt (i)+"' and [name]='"+jdarray[aa].ElementAt (i)+"'";
  386. filter+=temp;
  387. }
  388. sql+=filter;
  389. g_sendhead.bsql=1;
  390. g_branchip=GetIP(branch);
  391. g_pMainWnd->OnDisconnect();
  392. g_branchname=branch;
  393. g_bBranchModify=1;
  394. g_pMainWnd->ProcessChatMessageRequest2(sql);
  395. g_pMainWnd->OnDisconnect();g_bBranchModify=0;g_branchip=g_branchname="";
  396. if(g_bSendOK==0)
  397. {
  398. sql.Format("保存分店: %s 失败!", branch);
  399. AfxMessageBox(sql, MB_ICONINFORMATION);
  400. continue;
  401. }
  402. }
  403. }
  404. if(AfxMessageBox("是否实时更新数据?", MB_YESNO|MB_ICONINFORMATION)==IDYES)GetData();
  405. }
  406. else
  407. {
  408. CStringArray idarray;
  409. CStringArray jdarray;
  410. while (pos)
  411. {
  412. iItem = m_List1.GetNextSelectedItem(pos);
  413. idarray.Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  414. jdarray.Add (m_List1.GetItemText (iItem, 5+m_nAdd));
  415. }
  416. if(idarray.GetSize ()==1)
  417. {
  418. AfxMessageBox("请选中多对客人,或者按预约按钮!", MB_ICONINFORMATION);
  419. return;
  420. }
  421. else
  422. {
  423. InputDate dlg;
  424. dlg.m_mode=1;
  425. if(dlg.DoModal ()!=IDOK)return;
  426. CString sql;
  427. sql.Format ("update dindansp set [hqdate]='%s',hqtime='' where ", dlg.m_date);
  428. CString filter,temp;
  429. for(int i=0; i<idarray.GetSize (); i++)
  430. {
  431. if(i==0)
  432. temp="[id]='"+idarray.ElementAt (i)+"' and [name]='"+jdarray.ElementAt (i)+"'";
  433. else
  434. temp=" or [id]='"+idarray.ElementAt (i)+"' and [name]='"+jdarray.ElementAt (i)+"'";
  435. filter+=temp;
  436. }
  437. sql+=filter;
  438. g_sendhead.bsql=1;
  439. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  440. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  441. }
  442. GetData();
  443. }
  444. }
  445. void SearchTake5::GetData()
  446. {
  447. CString sql;
  448. sql.Format ("kind='2'");
  449. if(g_bAllBranch==0)
  450. {
  451. g_sendhead.code[0]=139;
  452. g_sendhead.tabcount=1;
  453. g_sendhead.bsql=0;
  454. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  455. DataToArray(&m_List1array);
  456. HidePrice();
  457. FillGrid();
  458. return;
  459. }
  460. //////////////数据汇总
  461. m_List1array.RemoveAll ();
  462. CStringArray failbrancharray;
  463. CString branch;
  464. int i = 0;
  465. for( i=-1; i<g_brancharray.GetSize ()-1; i++)
  466. {
  467. if(i!=-1)
  468. {
  469. branch=g_brancharray.ElementAt (i).ElementAt (0);
  470. g_branchip=g_brancharray.ElementAt (i).ElementAt (1);
  471. g_pMainWnd->OnDisconnect();
  472. g_branchname=branch;
  473. g_bBranchModify=1;
  474. }
  475. else
  476. branch=g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0);
  477. g_sendhead.bsql=0;
  478. g_sendhead.code[0]=139;
  479. g_sendhead.tabcount=1;
  480. g_pMainWnd->ProcessChatMessageRequest2(sql);
  481. if(g_bSendOK==0)
  482. {
  483. failbrancharray.Add (branch);
  484. continue;
  485. }
  486. CArray<CStringArray, CStringArray>List1array;
  487. DataToArray(&List1array);
  488. int size=m_List1array.GetSize ();
  489. for(int j=0; j<List1array.GetSize (); j++)
  490. {
  491. size++;
  492. m_List1array.SetSize(size , 1 );
  493. size--;
  494. m_List1array.ElementAt (size).Copy (List1array.ElementAt (j));
  495. m_List1array.ElementAt (size).InsertAt (0, branch);
  496. size++;
  497. }
  498. }
  499. for(i=0; i<failbrancharray.GetSize (); i++)
  500. {
  501. // AfxMessageBox("连接"+failbrancharray.ElementAt(i)+"服务器失败!", MB_ICONINFORMATION);
  502. }
  503. g_pMainWnd->OnDisconnect();
  504. g_bBranchModify=0;g_branchip=g_branchname="";
  505. HidePrice();
  506. FillGrid();
  507. }