ShowHireReg.cpp 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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. return true;
  205. }
  206. void ShowHireReg::OnButton1()
  207. {
  208. // TODO: Add your control notification handler code here
  209. UpdateData();
  210. m_filter.TrimLeft();
  211. m_filter.TrimRight();
  212. FillGrid();
  213. }
  214. void ShowHireReg::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  215. {
  216. // TODO: Add your control notification handler code here
  217. if (IsHasRights2new(42) == 0)return;
  218. POSITION pos;
  219. pos = m_List1.GetFirstSelectedItemPosition();
  220. if (pos == NULL)
  221. {
  222. AfxMessageBox("请先选中您要修改单!", MB_ICONINFORMATION);
  223. return;
  224. }
  225. int iItem = m_List1.GetNextSelectedItem(pos);
  226. CString id = m_List1.GetItemText(iItem, 0);
  227. while (id == "")
  228. {
  229. iItem--;
  230. id = m_List1.GetItemText(iItem, 0);
  231. }
  232. if (m_List1.GetItemText(iItem, 9) == "洗")
  233. {
  234. HireDress2 dlg;
  235. dlg.m_id = id;
  236. dlg.m_bAdd = 0;
  237. if (dlg.DoModal() == IDOK)GetData();
  238. }
  239. else
  240. {
  241. HireDress dlg;
  242. if (m_List1.GetItemText(iItem, 9) == "售")
  243. dlg.m_bIsSale = 1;
  244. dlg.m_id = id;
  245. dlg.m_bAdd = 0;
  246. if (dlg.DoModal() == IDOK)GetData();
  247. }
  248. *pResult = 0;
  249. }
  250. void ShowHireReg::OnSelchangeCombo1()
  251. {
  252. // TODO: Add your control notification handler code here
  253. SetTimer(1, 100, NULL);
  254. }
  255. void ShowHireReg::GetData()
  256. {
  257. g_sendhead.bsql = 0;
  258. g_sendhead.code[0] = 75;
  259. g_sendhead.tabcount = 1;
  260. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  261. DataToArray(&m_List1array);
  262. FillGrid();
  263. }
  264. void ShowHireReg::OnButton3() // 删除按钮;
  265. {
  266. // TODO: Add your control notification handler code here
  267. if (IsHasRights2new(49) == 0)return;
  268. POSITION pos;
  269. pos = m_List1.GetFirstSelectedItemPosition();
  270. if (pos == NULL)
  271. {
  272. AfxMessageBox("请先选中您要删除的单!", MB_ICONINFORMATION);
  273. return;
  274. }
  275. if (AfxMessageBox("警告:删除后记录将丢失, 继续吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  276. int iItem = m_List1.GetNextSelectedItem(pos);
  277. CString id = m_List1.GetItemText(iItem, 0);
  278. while (id == "")
  279. {
  280. iItem--;
  281. id = m_List1.GetItemText(iItem, 0);
  282. }
  283. /* CString sql;
  284. sql="delete from [dresshire] where [id]='"+id+"'";
  285. sql+="***delete from [dresshiredata] where [id]='"+id+"'";
  286. sql+="***delete from [client] where [id]='"+id+"'";
  287. g_sendhead.bsql=1;
  288. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  289. GetData();*/
  290. /////更新库存
  291. CStringArray m_seldressarray;
  292. m_seldressarray.Add(id);
  293. CMemFile memfile;
  294. CArchive ar(&memfile, CArchive::store);
  295. m_seldressarray.Serialize(ar);
  296. ar.Close();
  297. int length = memfile.GetLength();
  298. BYTE *pData = memfile.Detach();
  299. g_nSendCode = 19;
  300. g_pMainWnd->ProcessChatMessageRequest2(pData, length);
  301. g_nSendCode = 0;
  302. delete[]pData; if (g_bSendOK == 0)return;
  303. GetData();
  304. }
  305. void ShowHireReg::OnButton4() // 出租按钮;
  306. {
  307. // TODO: Add your control notification handler code here
  308. if (IsHasRights2new(41) == 0)return;
  309. HireDress dlg;
  310. if (dlg.DoModal() == IDOK)GetData();
  311. }
  312. void ShowHireReg::OnButton5() // 出售按钮;
  313. {
  314. // TODO: Add your control notification handler code here
  315. if (IsHasRights2new(41) == 0)return;
  316. HireDress dlg;
  317. dlg.m_bIsSale = 1;
  318. if (dlg.DoModal() == IDOK)GetData();
  319. }
  320. void ShowHireReg::OnButton2() // 还回按钮;
  321. {
  322. // TODO: Add your control notifi cation handler code here
  323. if (IsHasRights2new(41) == 0)return;
  324. POSITION pos;
  325. pos = m_List1.GetFirstSelectedItemPosition();
  326. if (pos == NULL)
  327. {
  328. AfxMessageBox("请先选中您要返还礼服的单!", MB_ICONINFORMATION);
  329. return;
  330. }
  331. int iItem = m_List1.GetNextSelectedItem(pos);
  332. CString id = m_List1.GetItemText(iItem, 0);
  333. while (id == "")
  334. {
  335. iItem--;
  336. id = m_List1.GetItemText(iItem, 0);
  337. }
  338. HireDressReturn dlg;
  339. dlg.m_id = id;
  340. if (dlg.DoModal() == IDOK)GetData();
  341. }
  342. void ShowHireReg::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
  343. {
  344. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
  345. // Take the default processing unless we set this to something else below.
  346. *pResult = 0;
  347. // First thing - check the draw stage. If it's the control's prepaint
  348. // stage, then tell Windows we want messages for every item.
  349. if (CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
  350. {
  351. *pResult = CDRF_NOTIFYITEMDRAW;
  352. }
  353. else if (CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage)
  354. {
  355. // This is the prepaint stage for an item. Here's where we set the
  356. // item's text color. Our return value will tell Windows to draw the
  357. // item itself, but it will use the new color we set here.
  358. // We'll cycle the colors through red, green, and light blue.
  359. COLORREF crText;
  360. int pos = pLVCD->nmcd.dwItemSpec;
  361. if (pos % 2)
  362. pLVCD->clrTextBk = g_gridcol1;
  363. else
  364. pLVCD->clrTextBk = g_gridcol2;
  365. while (m_List1.m_arLabels.ElementAt(pos).ElementAt(0).IsEmpty())
  366. {
  367. pos--;
  368. if (pos < 1)break;
  369. }
  370. if (m_List1.m_arLabels.ElementAt(pos).ElementAt(9) != "售" && m_List1.m_arLabels.ElementAt(pLVCD->nmcd.dwItemSpec).ElementAt(13) == "未还")
  371. crText = RGB(220, 0, 0);
  372. else
  373. crText = RGB(20, 133, 20);
  374. // Store the color back in the NMLVCUSTOMDRAW struct.
  375. pLVCD->clrText = crText;
  376. // Tell Windows to paint the control itself.
  377. *pResult = CDRF_DODEFAULT;
  378. }
  379. }
  380. void ShowHireReg::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  381. {
  382. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  383. // TODO: Add your control notification handler code here
  384. if (IsHasRights2new(41) == 0)return;
  385. POSITION pos;
  386. pos = m_List1.GetFirstSelectedItemPosition();
  387. if (pos == NULL)
  388. {
  389. return;
  390. }
  391. int iItem = m_List1.GetNextSelectedItem(pos);
  392. int iItembak = iItem;
  393. while (m_List1.m_arLabels.ElementAt(iItem).ElementAt(0).IsEmpty())
  394. {
  395. iItem--;
  396. }
  397. if (m_List1.GetItemText(iItem, 9) != "售" && m_List1.GetItemText(iItembak, 13) == "未还")
  398. GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
  399. else
  400. GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  401. *pResult = 0;
  402. }
  403. void ShowHireReg::OnButton10() // 送洗按钮;
  404. {
  405. // TODO: Add your control notification handler code here
  406. if (IsHasRights2new(41) == 0)return;
  407. HireDress2 dlg;
  408. if (dlg.DoModal() == IDOK)GetData();
  409. }
  410. void ShowHireReg::OnButton6() // 打印按钮;
  411. {
  412. // TODO: Add your control notification handler code here
  413. POSITION pos;
  414. pos = m_List1.GetFirstSelectedItemPosition();
  415. if (pos == NULL)
  416. {
  417. return;
  418. }
  419. int iItem = m_List1.GetNextSelectedItem(pos);
  420. while (m_List1.m_arLabels.ElementAt(iItem).ElementAt(0).IsEmpty())
  421. {
  422. iItem--;
  423. }
  424. #if 1
  425. g_pMainWnd->PrintHireDress(m_List1.GetItemText(iItem, 0));
  426. #else
  427. g_pMainWnd->PrintHireDress_01(m_List1.GetItemText(iItem, 0));
  428. #endif
  429. }