ShowHireReg.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. // ShowHireReg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowHireReg.h"
  6. #include "MyMdi.H"
  7. #include "HireDress.h"
  8. #include "HireDress2.h"
  9. #include "HireDressReturn.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // ShowHireReg
  17. IMPLEMENT_DYNCREATE(ShowHireReg, MyFormView)
  18. ShowHireReg::ShowHireReg()
  19. : MyFormView(ShowHireReg::IDD)
  20. {
  21. //{{AFX_DATA_INIT(ShowHireReg)
  22. m_filter = _T("");
  23. //}}AFX_DATA_INIT
  24. }
  25. ShowHireReg::~ShowHireReg()
  26. {
  27. }
  28. void ShowHireReg::DoDataExchange(CDataExchange* pDX)
  29. {
  30. MyFormView::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(ShowHireReg)
  32. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  33. DDX_Control(pDX, IDC_LIST2, m_List1);
  34. DDX_Control(pDX, IDC_STATIC1, m_static1);
  35. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(ShowHireReg, MyFormView)
  39. //{{AFX_MSG_MAP(ShowHireReg)
  40. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  41. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  42. ON_WM_TIMER()
  43. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  44. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  45. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  46. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  47. ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
  48. ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
  49. ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
  50. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  51. ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
  52. //}}AFX_MSG_MAP
  53. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // ShowHireReg diagnostics
  57. #ifdef _DEBUG
  58. void ShowHireReg::AssertValid() const
  59. {
  60. MyFormView::AssertValid();
  61. }
  62. void ShowHireReg::Dump(CDumpContext& dc) const
  63. {
  64. MyFormView::Dump(dc);
  65. }
  66. #endif //_DEBUG
  67. /////////////////////////////////////////////////////////////////////////////
  68. // ShowHireReg message handlers
  69. void ShowHireReg::OnInitialUpdate()
  70. {
  71. MyFormView::OnInitialUpdate();
  72. GetDlgItem(IDC_BUTTON4)->EnableWindow(IsHasRights2new(41));
  73. GetDlgItem(IDC_BUTTON5)->EnableWindow(IsHasRights2new(41));
  74. GetDlgItem(IDC_BUTTON2)->EnableWindow(IsHasRights2new(41));
  75. GetDlgItem(IDC_BUTTON6)->EnableWindow(IsHasRights2new(42));
  76. GetDlgItem(IDC_BUTTON3)->EnableWindow(IsHasRights2new(49));
  77. // TODO: Add your specialized code here and/or call the base class
  78. CMyMdi Mdi;
  79. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  80. // Here we create the outbar control using the splitter as its parent
  81. // and setting its id to the first pane.
  82. CRect rc2;
  83. GetWindowRect(rc2);
  84. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  85. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  86. m_static1.SetFont(&g_titlefont);
  87. m_List1.SetHeadings("单号,120;金额,60;押金,60;客人,60;电话,60;经手人,60;日期,90;取件日,90;还件日,90;租/售,60;备注,150;礼服,100;件数,60;是否收回,90;日期,90;经手人,80");
  88. m_List1.LoadColumnInfo(134);
  89. m_List1.m_bSortSupport = 0;
  90. g_sendhead.bsql = 0;
  91. g_sendhead.code[0] = 75;
  92. g_sendhead.tabcount = 1;
  93. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  94. DataToArray(&m_List1array);
  95. FillGrid();
  96. m_combo1.GetWindowRect(rc2);
  97. ScreenToClient(rc2);
  98. rc2.bottom += 200;
  99. m_combo1.MoveWindow(rc2);
  100. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  101. SetComboHei(&m_combo1, rc2.Height());
  102. m_combo1.AddString("租");
  103. m_combo1.AddString("售");
  104. }
  105. void ShowHireReg::FillGrid()
  106. {
  107. m_List1.DeleteAllItems2();
  108. int ii = 0;
  109. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  110. int count = 0;
  111. if (m_filter.IsEmpty())
  112. {
  113. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  114. {
  115. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  116. }
  117. }
  118. else
  119. {
  120. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  121. {
  122. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  123. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  124. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  125. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  126. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
  127. m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1)
  128. {
  129. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  130. }
  131. }
  132. }
  133. m_List1.m_arLabels.SetSize(count, 1);
  134. ii = count;
  135. m_List1.m_LabelCount = ii;
  136. m_List1.SetItemCountEx(ii);
  137. CString str;
  138. str.Format("单数:%d", ii);
  139. SetDlgItemText(IDC_STATIC2, str);
  140. CRect rc;
  141. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  142. ScreenToClient(rc);
  143. InvalidateRect(rc);
  144. }
  145. void ShowHireReg::OnBUTclose()
  146. {
  147. // TODO: Add your control notification handler code here
  148. GetParent()->SendMessage(WM_CLOSE);
  149. }
  150. void ShowHireReg::OnTimer(UINT nIDEvent)
  151. {
  152. // TODO: Add your message handler code here and/or call default
  153. KillTimer(nIDEvent);
  154. OnButton1();
  155. }
  156. BOOL ShowHireReg::PreTranslateMessage(MSG* pMsg)
  157. {
  158. // TODO: Add your specialized code here and/or call the base class
  159. try
  160. {
  161. if (pMsg->message == WM_KEYDOWN)
  162. {
  163. switch (pMsg->wParam)
  164. {
  165. case VK_RETURN:
  166. OnButton1();
  167. return 1;
  168. case 0x43: // copy
  169. if ((GetKeyState(VK_CONTROL) & 0x80))
  170. {
  171. GetFocus()->SendMessage(WM_COPY);
  172. return TRUE;
  173. }
  174. break;
  175. case 0x56: //Ctrl + V:
  176. if ((GetKeyState(VK_CONTROL) & 0x80))
  177. {
  178. GetFocus()->SendMessage(WM_PASTE);
  179. return TRUE;
  180. }
  181. break;
  182. case 0x58: // cut
  183. if ((GetKeyState(VK_CONTROL) & 0x80))
  184. {
  185. GetFocus()->SendMessage(WM_CUT);
  186. return TRUE;
  187. }
  188. break;
  189. case 0x5A: //undo
  190. case 0x59: //redo
  191. if ((GetKeyState(VK_CONTROL) & 0x80))
  192. {
  193. GetFocus()->SendMessage(WM_UNDO);
  194. return TRUE;
  195. }
  196. break;
  197. }
  198. }
  199. return MyFormView::PreTranslateMessage(pMsg);
  200. }
  201. catch (...)
  202. {
  203. }
  204. }
  205. void ShowHireReg::OnButton1()
  206. {
  207. // TODO: Add your control notification handler code here
  208. UpdateData();
  209. m_filter.TrimLeft();
  210. m_filter.TrimRight();
  211. FillGrid();
  212. }
  213. void ShowHireReg::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  214. {
  215. // TODO: Add your control notification handler code here
  216. if (IsHasRights2new(42) == 0)return;
  217. POSITION pos;
  218. pos = m_List1.GetFirstSelectedItemPosition();
  219. if (pos == NULL)
  220. {
  221. AfxMessageBox("请先选中您要修改单!", MB_ICONINFORMATION);
  222. return;
  223. }
  224. int iItem = m_List1.GetNextSelectedItem(pos);
  225. CString id = m_List1.GetItemText(iItem, 0);
  226. while (id == "")
  227. {
  228. iItem--;
  229. id = m_List1.GetItemText(iItem, 0);
  230. }
  231. if (m_List1.GetItemText(iItem, 9) == "洗")
  232. {
  233. HireDress2 dlg;
  234. dlg.m_id = id;
  235. dlg.m_bAdd = 0;
  236. if (dlg.DoModal() == IDOK)GetData();
  237. }
  238. else
  239. {
  240. HireDress dlg;
  241. if (m_List1.GetItemText(iItem, 9) == "售")
  242. dlg.m_bIsSale = 1;
  243. dlg.m_id = id;
  244. dlg.m_bAdd = 0;
  245. if (dlg.DoModal() == IDOK)GetData();
  246. }
  247. *pResult = 0;
  248. }
  249. void ShowHireReg::OnSelchangeCombo1()
  250. {
  251. // TODO: Add your control notification handler code here
  252. SetTimer(1, 100, NULL);
  253. }
  254. void ShowHireReg::GetData()
  255. {
  256. g_sendhead.bsql = 0;
  257. g_sendhead.code[0] = 75;
  258. g_sendhead.tabcount = 1;
  259. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  260. DataToArray(&m_List1array);
  261. FillGrid();
  262. }
  263. void ShowHireReg::OnButton3() // 删除按钮;
  264. {
  265. // TODO: Add your control notification handler code here
  266. if (IsHasRights2new(49) == 0)return;
  267. POSITION pos;
  268. pos = m_List1.GetFirstSelectedItemPosition();
  269. if (pos == NULL)
  270. {
  271. AfxMessageBox("请先选中您要删除的单!", MB_ICONINFORMATION);
  272. return;
  273. }
  274. if (AfxMessageBox("警告:删除后记录将丢失, 继续吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  275. int iItem = m_List1.GetNextSelectedItem(pos);
  276. CString id = m_List1.GetItemText(iItem, 0);
  277. while (id == "")
  278. {
  279. iItem--;
  280. id = m_List1.GetItemText(iItem, 0);
  281. }
  282. /* CString sql;
  283. sql="delete from [dresshire] where [id]='"+id+"'";
  284. sql+="***delete from [dresshiredata] where [id]='"+id+"'";
  285. sql+="***delete from [client] where [id]='"+id+"'";
  286. g_sendhead.bsql=1;
  287. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  288. GetData();*/
  289. /////更新库存
  290. CStringArray m_seldressarray;
  291. m_seldressarray.Add(id);
  292. CMemFile memfile;
  293. CArchive ar(&memfile, CArchive::store);
  294. m_seldressarray.Serialize(ar);
  295. ar.Close();
  296. int length = memfile.GetLength();
  297. BYTE *pData = memfile.Detach();
  298. g_nSendCode = 19;
  299. g_pMainWnd->ProcessChatMessageRequest2(pData, length);
  300. g_nSendCode = 0;
  301. delete[]pData; if (g_bSendOK == 0)return;
  302. GetData();
  303. }
  304. void ShowHireReg::OnButton4() // 出租按钮;
  305. {
  306. // TODO: Add your control notification handler code here
  307. if (IsHasRights2new(41) == 0)return;
  308. HireDress dlg;
  309. if (dlg.DoModal() == IDOK)GetData();
  310. }
  311. void ShowHireReg::OnButton5() // 出售按钮;
  312. {
  313. // TODO: Add your control notification handler code here
  314. if (IsHasRights2new(41) == 0)return;
  315. HireDress dlg;
  316. dlg.m_bIsSale = 1;
  317. if (dlg.DoModal() == IDOK)GetData();
  318. }
  319. void ShowHireReg::OnButton2() // 还回按钮;
  320. {
  321. // TODO: Add your control notifi cation handler code here
  322. if (IsHasRights2new(41) == 0)return;
  323. POSITION pos;
  324. pos = m_List1.GetFirstSelectedItemPosition();
  325. if (pos == NULL)
  326. {
  327. AfxMessageBox("请先选中您要返还礼服的单!", MB_ICONINFORMATION);
  328. return;
  329. }
  330. int iItem = m_List1.GetNextSelectedItem(pos);
  331. CString id = m_List1.GetItemText(iItem, 0);
  332. while (id == "")
  333. {
  334. iItem--;
  335. id = m_List1.GetItemText(iItem, 0);
  336. }
  337. HireDressReturn dlg;
  338. dlg.m_id = id;
  339. if (dlg.DoModal() == IDOK)GetData();
  340. }
  341. void ShowHireReg::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
  342. {
  343. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
  344. // Take the default processing unless we set this to something else below.
  345. *pResult = 0;
  346. // First thing - check the draw stage. If it's the control's prepaint
  347. // stage, then tell Windows we want messages for every item.
  348. if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
  349. {
  350. *pResult = CDRF_NOTIFYITEMDRAW;
  351. }
  352. else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
  353. {
  354. // This is the prepaint stage for an item. Here's where we set the
  355. // item's text color. Our return value will tell Windows to draw the
  356. // item itself, but it will use the new color we set here.
  357. // We'll cycle the colors through red, green, and light blue.
  358. COLORREF crText;
  359. int pos = pLVCD->nmcd.dwItemSpec;
  360. if (pos % 2)
  361. pLVCD->clrTextBk = g_gridcol1;
  362. else
  363. pLVCD->clrTextBk = g_gridcol2;
  364. while (m_List1.m_arLabels.ElementAt(pos).ElementAt(0).IsEmpty())
  365. {
  366. pos--;
  367. if (pos < 1)break;
  368. }
  369. if (m_List1.m_arLabels.ElementAt(pos).ElementAt(9) != "售" && m_List1.m_arLabels.ElementAt(pLVCD->nmcd.dwItemSpec).ElementAt(13) == "未还")
  370. crText = RGB(220, 0, 0);
  371. else
  372. crText = RGB(20, 133, 20);
  373. // Store the color back in the NMLVCUSTOMDRAW struct.
  374. pLVCD->clrText = crText;
  375. // Tell Windows to paint the control itself.
  376. *pResult = CDRF_DODEFAULT;
  377. }
  378. }
  379. void ShowHireReg::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  380. {
  381. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  382. // TODO: Add your control notification handler code here
  383. if (IsHasRights2new(41) == 0)return;
  384. POSITION pos;
  385. pos = m_List1.GetFirstSelectedItemPosition();
  386. if (pos == NULL)
  387. {
  388. return;
  389. }
  390. int iItem = m_List1.GetNextSelectedItem(pos);
  391. int iItembak = iItem;
  392. while (m_List1.m_arLabels.ElementAt(iItem).ElementAt(0).IsEmpty())
  393. {
  394. iItem--;
  395. }
  396. if (m_List1.GetItemText(iItem, 9) != "售" && m_List1.GetItemText(iItembak, 13) == "未还")
  397. GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
  398. else
  399. GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  400. *pResult = 0;
  401. }
  402. void ShowHireReg::OnButton10() // 送洗按钮;
  403. {
  404. // TODO: Add your control notification handler code here
  405. if (IsHasRights2new(41) == 0)return;
  406. HireDress2 dlg;
  407. if (dlg.DoModal() == IDOK)GetData();
  408. }
  409. void ShowHireReg::OnButton6() // 打印按钮;
  410. {
  411. // TODO: Add your control notification handler code here
  412. POSITION pos;
  413. pos = m_List1.GetFirstSelectedItemPosition();
  414. if (pos == NULL)
  415. {
  416. return;
  417. }
  418. int iItem = m_List1.GetNextSelectedItem(pos);
  419. while (m_List1.m_arLabels.ElementAt(iItem).ElementAt(0).IsEmpty())
  420. {
  421. iItem--;
  422. }
  423. #if 1
  424. g_pMainWnd->PrintHireDress(m_List1.GetItemText(iItem, 0));
  425. #else
  426. g_pMainWnd->PrintHireDress_01(m_List1.GetItemText(iItem, 0));
  427. #endif
  428. }