DressEarlyWarning.cpp 12 KB

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