SearchTake5.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  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. for(int 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. if(IsHasRights2new(31))return;
  320. for(int i=0; i< m_List1array.GetSize (); i++)
  321. {
  322. m_List1array.ElementAt (i).SetAt (16+m_nAdd, "***");
  323. m_List1array.ElementAt (i).SetAt (17+m_nAdd, "***");
  324. }
  325. }
  326. void SearchTake5::OnBtnsearchfilter()
  327. {
  328. // TODO: Add your control notification handler code here
  329. SearchFilter2 dlg;
  330. dlg.m_pArray=&jdarray;
  331. if(dlg.DoModal ()==IDOK)
  332. {
  333. FillGrid();
  334. }
  335. g_bSearchFilter=0;
  336. }
  337. void SearchTake5::OnButton3()
  338. {
  339. // TODO: Add your control notification handler code here
  340. POSITION pos;
  341. pos=m_List1.GetFirstSelectedItemPosition();
  342. if(pos==NULL)
  343. {
  344. AfxMessageBox("请选中多对客人!", MB_ICONINFORMATION);
  345. return;
  346. }
  347. int iItem;
  348. if(g_bAllBranch)
  349. {
  350. CStringArray idarray[100];
  351. CStringArray jdarray[100];
  352. CStringArray brancharray;
  353. int idcount=0;
  354. int branchpos;
  355. CString branch;
  356. while (pos)
  357. {
  358. iItem = m_List1.GetNextSelectedItem(pos);
  359. branchpos=::FindArray(&brancharray, m_List1.GetItemText (iItem, 0) );if(branchpos>=100)continue;
  360. if(branchpos==-1)
  361. {
  362. branchpos=brancharray.GetSize();
  363. brancharray.Add(m_List1.GetItemText (iItem, 0));
  364. }
  365. idarray[branchpos].Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  366. jdarray[branchpos].Add (m_List1.GetItemText (iItem, 5+m_nAdd));
  367. idcount++;
  368. }
  369. if(idcount==1)
  370. {
  371. AfxMessageBox("请选中多对客人,或者按预约按钮!", MB_ICONINFORMATION);
  372. return;
  373. }
  374. else
  375. {
  376. InputDate dlg;
  377. dlg.m_mode=1;
  378. if(dlg.DoModal ()!=IDOK)return;
  379. for(int aa=0; aa<brancharray.GetSize(); aa++)
  380. {
  381. branch=brancharray.ElementAt(aa);
  382. CString sql;
  383. sql.Format ("update dindansp set [hqdate]='%s',hqtime='' where ", dlg.m_date);
  384. CString filter,temp;
  385. for(int i=0; i<idarray[aa].GetSize (); i++)
  386. {
  387. if(i==0)
  388. temp="[id]='"+idarray[aa].ElementAt (i)+"' and [name]='"+jdarray[aa].ElementAt (i)+"'";
  389. else
  390. temp=" or [id]='"+idarray[aa].ElementAt (i)+"' and [name]='"+jdarray[aa].ElementAt (i)+"'";
  391. filter+=temp;
  392. }
  393. sql+=filter;
  394. g_sendhead.bsql=1;
  395. g_branchip=GetIP(branch);
  396. g_pMainWnd->OnDisconnect();
  397. g_branchname=branch;
  398. g_bBranchModify=1;
  399. g_pMainWnd->ProcessChatMessageRequest2(sql);
  400. g_pMainWnd->OnDisconnect();g_bBranchModify=0;g_branchip=g_branchname="";
  401. if(g_bSendOK==0)
  402. {
  403. sql.Format("保存分店: %s 失败!", branch);
  404. AfxMessageBox(sql, MB_ICONINFORMATION);
  405. continue;
  406. }
  407. }
  408. }
  409. if(AfxMessageBox("是否实时更新数据?", MB_YESNO|MB_ICONINFORMATION)==IDYES)GetData();
  410. }
  411. else
  412. {
  413. CStringArray idarray;
  414. CStringArray jdarray;
  415. while (pos)
  416. {
  417. iItem = m_List1.GetNextSelectedItem(pos);
  418. idarray.Add (m_List1.GetItemText (iItem, 0+m_nAdd));
  419. jdarray.Add (m_List1.GetItemText (iItem, 5+m_nAdd));
  420. }
  421. if(idarray.GetSize ()==1)
  422. {
  423. AfxMessageBox("请选中多对客人,或者按预约按钮!", MB_ICONINFORMATION);
  424. return;
  425. }
  426. else
  427. {
  428. InputDate dlg;
  429. dlg.m_mode=1;
  430. if(dlg.DoModal ()!=IDOK)return;
  431. CString sql;
  432. sql.Format ("update dindansp set [hqdate]='%s',hqtime='' where ", dlg.m_date);
  433. CString filter,temp;
  434. for(int i=0; i<idarray.GetSize (); i++)
  435. {
  436. if(i==0)
  437. temp="[id]='"+idarray.ElementAt (i)+"' and [name]='"+jdarray.ElementAt (i)+"'";
  438. else
  439. temp=" or [id]='"+idarray.ElementAt (i)+"' and [name]='"+jdarray.ElementAt (i)+"'";
  440. filter+=temp;
  441. }
  442. sql+=filter;
  443. g_sendhead.bsql=1;
  444. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  445. AfxMessageBox("保存成功!", MB_ICONINFORMATION);
  446. }
  447. GetData();
  448. }
  449. }
  450. void SearchTake5::GetData()
  451. {
  452. CString sql;
  453. sql.Format ("kind='2'");
  454. if(g_bAllBranch==0)
  455. {
  456. g_sendhead.code[0]=139;
  457. g_sendhead.tabcount=1;
  458. g_sendhead.bsql=0;
  459. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  460. DataToArray(&m_List1array);
  461. HidePrice();
  462. FillGrid();
  463. return;
  464. }
  465. //////////////数据汇总
  466. m_List1array.RemoveAll ();
  467. CStringArray failbrancharray;
  468. CString branch;
  469. for(int i=-1; i<g_brancharray.GetSize ()-1; i++)
  470. {
  471. if(i!=-1)
  472. {
  473. branch=g_brancharray.ElementAt (i).ElementAt (0);
  474. g_branchip=g_brancharray.ElementAt (i).ElementAt (1);
  475. g_pMainWnd->OnDisconnect();
  476. g_branchname=branch;
  477. g_bBranchModify=1;
  478. }
  479. else
  480. branch=g_brancharray.ElementAt (g_brancharray.GetSize ()-1).ElementAt (0);
  481. g_sendhead.bsql=0;
  482. g_sendhead.code[0]=139;
  483. g_sendhead.tabcount=1;
  484. g_pMainWnd->ProcessChatMessageRequest2(sql);
  485. if(g_bSendOK==0)
  486. {
  487. failbrancharray.Add (branch);
  488. continue;
  489. }
  490. CArray<CStringArray, CStringArray>List1array;
  491. DataToArray(&List1array);
  492. int size=m_List1array.GetSize ();
  493. for(int j=0; j<List1array.GetSize (); j++)
  494. {
  495. size++;
  496. m_List1array.SetSize(size , 1 );
  497. size--;
  498. m_List1array.ElementAt (size).Copy (List1array.ElementAt (j));
  499. m_List1array.ElementAt (size).InsertAt (0, branch);
  500. size++;
  501. }
  502. }
  503. for(i=0; i<failbrancharray.GetSize (); i++)
  504. {
  505. // AfxMessageBox("连接"+failbrancharray.ElementAt(i)+"服务器失败!", MB_ICONINFORMATION);
  506. }
  507. g_pMainWnd->OnDisconnect();
  508. g_bBranchModify=0;g_branchip=g_branchname="";
  509. HidePrice();
  510. FillGrid();
  511. }