ShowDress.cpp 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. // ShowDress.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ShowDress.h"
  6. #include "MyMdi.H"
  7. #include "ShowHireReg2.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // ShowDress
  15. IMPLEMENT_DYNCREATE(ShowDress, MyFormView)
  16. ShowDress::ShowDress()
  17. : MyFormView(ShowDress::IDD)
  18. {
  19. //{{AFX_DATA_INIT(ShowDress)
  20. m_filter = _T("");
  21. m_radio1 = 0;
  22. //}}AFX_DATA_INIT
  23. }
  24. ShowDress::~ShowDress()
  25. {
  26. }
  27. void ShowDress::DoDataExchange(CDataExchange* pDX)
  28. {
  29. MyFormView::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(ShowDress)
  31. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  32. DDX_Control(pDX, IDC_LIST2, m_List1);
  33. DDX_Control(pDX, IDC_STATIC1, m_static1);
  34. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  35. DDX_Radio(pDX, IDC_RADIO1, m_radio1);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(ShowDress, MyFormView)
  39. //{{AFX_MSG_MAP(ShowDress)
  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_RADIO1, OnRadio1)
  48. ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. // ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  52. /////////////////////////////////////////////////////////////////////////////
  53. // ShowDress diagnostics
  54. #ifdef _DEBUG
  55. void ShowDress::AssertValid() const
  56. {
  57. MyFormView::AssertValid();
  58. }
  59. void ShowDress::Dump(CDumpContext& dc) const
  60. {
  61. MyFormView::Dump(dc);
  62. }
  63. #endif //_DEBUG
  64. /////////////////////////////////////////////////////////////////////////////
  65. // ShowDress message handlers
  66. void ShowDress::OnInitialUpdate()
  67. {
  68. MyFormView::OnInitialUpdate();
  69. // TODO: Add your specialized code here and/or call the base class
  70. CMyMdi Mdi;
  71. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  72. // Here we create the outbar control using the splitter as its parent 13
  73. // and setting its id to the first pane.
  74. CRect rc2;
  75. GetWindowRect(rc2);
  76. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  77. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  78. m_static1.SetFont (&g_titlefont);
  79. m_List1.SetHeadings("礼服类别,100;编号,100;名称,100;区域,100;数量,60;已租,60;已售,60;送洗,60;租价,60;售价,60;备注,100;购买日期,100" );
  80. m_List1.LoadColumnInfo (133);
  81. g_sendhead.bsql=0;
  82. g_sendhead.code[0]=72;
  83. g_sendhead.code[1]=71;
  84. g_sendhead.tabcount=2;
  85. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  86. DataToArray(&m_List1array, &g_List1array);
  87. FillGrid();
  88. m_combo1.GetWindowRect (rc2);
  89. ScreenToClient(rc2);
  90. rc2.bottom +=200;
  91. m_combo1.MoveWindow (rc2);
  92. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  93. SetComboHei(&m_combo1, rc2.Height ());
  94. for(int i=0; i<g_List1array.GetSize (); i++)
  95. m_combo1.AddString (g_List1array.ElementAt (i).ElementAt (0));
  96. }
  97. void ShowDress::FillGrid()
  98. {
  99. m_List1.DeleteAllItems2 ();
  100. int ii=0;
  101. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  102. int count=0;
  103. if(m_filter.IsEmpty ())
  104. {
  105. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  106. { if(m_radio1!=atoi(m_List1array.ElementAt (ii).ElementAt (12)))continue;
  107. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  108. }
  109. }
  110. else
  111. {
  112. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  113. {
  114. if(m_radio1!=atoi(m_List1array.ElementAt (ii).ElementAt (12)))continue;
  115. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  116. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  117. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  118. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1 )
  119. {
  120. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  121. }
  122. }
  123. }
  124. m_List1.m_arLabels.SetSize(count, 1);
  125. ii=count;
  126. m_List1.m_LabelCount=ii;
  127. m_List1.SetItemCountEx (ii);
  128. CString str;
  129. str.Format ("数量:%d", ii);
  130. SetDlgItemText(IDC_STATIC2, str);
  131. }
  132. void ShowDress::OnBUTclose()
  133. {
  134. // TODO: Add your control notification handler code here
  135. GetParent()->SendMessage(WM_CLOSE);
  136. }
  137. void ShowDress::OnTimer(UINT nIDEvent)
  138. {
  139. // TODO: Add your message handler code here and/or call default
  140. KillTimer(nIDEvent);
  141. OnButton1();
  142. }
  143. BOOL ShowDress::PreTranslateMessage(MSG* pMsg)
  144. {
  145. // TODO: Add your specialized code here and/or call the base class
  146. try
  147. {
  148. if(pMsg->message==WM_KEYDOWN)
  149. {
  150. switch (pMsg->wParam)
  151. {
  152. case VK_RETURN:
  153. OnButton1();
  154. return 1;
  155. case 0x43: // copy
  156. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  157. {
  158. GetFocus()->SendMessage(WM_COPY);
  159. return TRUE;
  160. }
  161. break;
  162. case 0x56: //Ctrl + V:
  163. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  164. {
  165. GetFocus()->SendMessage(WM_PASTE);
  166. return TRUE;
  167. }
  168. break;
  169. case 0x58: // cut
  170. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  171. {
  172. GetFocus()->SendMessage(WM_CUT);
  173. return TRUE;
  174. }
  175. break;
  176. case 0x5A: //undo
  177. case 0x59: //redo
  178. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  179. {
  180. GetFocus()->SendMessage(WM_UNDO);
  181. return TRUE;
  182. }
  183. break;
  184. }
  185. }
  186. return MyFormView::PreTranslateMessage(pMsg);
  187. }
  188. catch(...)
  189. {
  190. }
  191. return true;
  192. }
  193. void ShowDress::OnButton1()
  194. {
  195. // TODO: Add your control notification handler code here
  196. UpdateData();
  197. m_filter.TrimLeft ();
  198. m_filter.TrimRight ();
  199. FillGrid();
  200. }
  201. void ShowDress::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  202. {
  203. // TODO: Add your control notification handler code here
  204. OnButton3();
  205. *pResult = 0;
  206. }
  207. void ShowDress::OnSelchangeCombo1()
  208. {
  209. // TODO: Add your control notification handler code here
  210. SetTimer(1, 100, NULL);
  211. }
  212. void ShowDress::GetData()
  213. {
  214. g_sendhead.bsql=0;
  215. g_sendhead.code[0]=72;
  216. g_sendhead.tabcount=1;
  217. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  218. DataToArray(&m_List1array);
  219. FillGrid();
  220. }
  221. void ShowDress::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  222. {
  223. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  224. // Take the default processing unless we set this to something else below.
  225. *pResult = 0;
  226. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  227. {
  228. *pResult = CDRF_NOTIFYITEMDRAW;
  229. }
  230. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  231. {
  232. // This is the notification message for an item. We'll request
  233. // notifications before each subitem's prepaint stage.
  234. *pResult = CDRF_NOTIFYSUBITEMDRAW;
  235. }
  236. else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
  237. // else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  238. {
  239. // This is the prepaint stage for an item. Here's where we set the
  240. // item's text color. Our return value will tell Windows to draw the
  241. // item itself, but it will use the new color we set here.
  242. // We'll cycle the colors through red, green, and light blue.
  243. if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (8)=="0" && m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (6)!="0")
  244. {
  245. if(pLVCD->iSubItem<6)
  246. pLVCD->clrText = RGB(212,20,212);
  247. else
  248. pLVCD->clrText = RGB(220,0,0);
  249. }
  250. else if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (8)=="0")
  251. pLVCD->clrText = RGB(220,0,0);
  252. else if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (6)!="0")
  253. pLVCD->clrText = RGB(212,20,212);
  254. else
  255. pLVCD->clrText = RGB(20,133,20);
  256. if(pLVCD->nmcd.dwItemSpec%2)
  257. pLVCD->clrTextBk = g_gridcol1;
  258. else
  259. pLVCD->clrTextBk = g_gridcol2;
  260. // Store the color back in the NMLVCUSTOMDRAW struct.
  261. // Tell Windows to paint the control itself.
  262. *pResult = CDRF_DODEFAULT;
  263. }
  264. }
  265. void ShowDress::OnButton3()
  266. {
  267. // TODO: Add your control notification handler code here
  268. POSITION pos;
  269. pos=m_List1.GetFirstSelectedItemPosition();
  270. if(pos==NULL)
  271. {
  272. AfxMessageBox("请先选中您要查看的礼服!", MB_ICONINFORMATION);
  273. return;
  274. }
  275. int iItem=m_List1.GetNextSelectedItem(pos);
  276. CString no=m_List1.GetItemText (iItem, 1);
  277. ShowHireReg2 dlg;
  278. dlg.m_no=no;
  279. dlg.DoModal ();
  280. }
  281. void ShowDress::OnRadio1()
  282. {
  283. // TODO: Add your control notification handler code here
  284. OnRadio2();
  285. }
  286. void ShowDress::OnRadio2()
  287. {
  288. // TODO: Add your control notification handler code here
  289. UpdateData();
  290. FillGrid();
  291. }
  292. void ShowDress::OnButton2()
  293. {
  294. // TODO: Add your control notification handler code here
  295. }