DressEarlyWarning.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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. m_dtdays=AfxGetApp()->GetProfileInt (LYFZVERSION, "dtdays", 2);
  111. UpdateData(0);
  112. }
  113. void DressEarlyWarning::FillGrid()
  114. {
  115. m_filter.MakeUpper();
  116. m_List1.DeleteAllItems2 ();
  117. int ii=0;
  118. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  119. int count=0;
  120. if(m_filter.IsEmpty ())
  121. {
  122. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  123. {
  124. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  125. }
  126. }
  127. else
  128. {
  129. BOOL bFinded=0;
  130. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  131. {
  132. if(bFinded && m_List1array.ElementAt (ii).ElementAt (0).IsEmpty ())
  133. {
  134. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  135. continue;
  136. }
  137. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  138. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  139. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1|| \
  140. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 )
  141. {
  142. bFinded=1;
  143. while(m_List1array.ElementAt (ii).ElementAt (0)=="")
  144. {
  145. ii--;
  146. }
  147. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  148. }
  149. else
  150. {
  151. bFinded=0;
  152. }
  153. }
  154. }
  155. m_List1.m_arLabels.SetSize(count, 1);
  156. ii=count;
  157. m_List1.m_LabelCount=ii;
  158. m_List1.SetItemCountEx (ii);
  159. CString str;
  160. str.Format ("单数:%d", ii);
  161. SetDlgItemText(IDC_STATIC2, str);
  162. }
  163. void DressEarlyWarning::OnBUTclose()
  164. {
  165. // TODO: Add your control notification handler code here
  166. GetParent()->SendMessage(WM_CLOSE);
  167. }
  168. void DressEarlyWarning::OnTimer(UINT nIDEvent)
  169. {
  170. // TODO: Add your message handler code here and/or call default
  171. KillTimer(nIDEvent);
  172. OnButton1();
  173. }
  174. BOOL DressEarlyWarning::PreTranslateMessage(MSG* pMsg)
  175. {
  176. // TODO: Add your specialized code here and/or call the base class
  177. try
  178. {
  179. if(pMsg->message==WM_KEYDOWN)
  180. {
  181. switch (pMsg->wParam)
  182. {
  183. case VK_RETURN:
  184. OnButton1();
  185. return 1;
  186. case 0x43: // copy
  187. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  188. {
  189. GetFocus()->SendMessage(WM_COPY);
  190. return TRUE;
  191. }
  192. break;
  193. case 0x56: //Ctrl + V:
  194. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  195. {
  196. GetFocus()->SendMessage(WM_PASTE);
  197. return TRUE;
  198. }
  199. break;
  200. case 0x58: // cut
  201. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  202. {
  203. GetFocus()->SendMessage(WM_CUT);
  204. return TRUE;
  205. }
  206. break;
  207. case 0x5A: //undo
  208. case 0x59: //redo
  209. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  210. {
  211. GetFocus()->SendMessage(WM_UNDO);
  212. return TRUE;
  213. }
  214. break;
  215. }
  216. }
  217. return MyFormView::PreTranslateMessage(pMsg);
  218. }
  219. catch(...)
  220. {
  221. }
  222. return true;
  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. AfxGetApp()->WriteProfileInt (LYFZVERSION, "dtdays", m_dtdays);
  298. }
  299. void DressEarlyWarning::OnButton3()
  300. {
  301. UpdateData();
  302. POSITION pos;
  303. CStringArray array; CString name;
  304. pos=m_List1.GetFirstSelectedItemPosition();
  305. if(pos==NULL)
  306. {
  307. AfxMessageBox("请先选中您要发送短信的客人!", MB_ICONINFORMATION);
  308. return;
  309. }
  310. int iItem;
  311. while (pos)
  312. {
  313. iItem = m_List1.GetNextSelectedItem(pos);
  314. array.Add (m_List1.GetItemText (iItem, 5));
  315. }
  316. SendMsgDlg dlg;
  317. // if(m_radio==5)
  318. dlg.m_mode=1;
  319. dlg.m_pArray=&array;
  320. dlg.DoModal ();
  321. }
  322. void DressEarlyWarning::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  323. {
  324. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  325. // Take the default processing unless we set this to something else below.
  326. *pResult = 0;
  327. // First thing - check the draw stage. If it's the control's prepaint
  328. // stage, then tell Windows we want messages for every item.
  329. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  330. {
  331. *pResult = CDRF_NOTIFYITEMDRAW;
  332. }
  333. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  334. {
  335. // This is the prepaint stage for an item. Here's where we set the
  336. // item's text color. Our return value will tell Windows to draw the
  337. // item itself, but it will use the new color we set here.
  338. // We'll cycle the colors through red, green, and light blue.
  339. COLORREF crText;
  340. int pos=pLVCD->nmcd.dwItemSpec;
  341. if(pos%2)
  342. pLVCD->clrTextBk = g_gridcol1;
  343. else
  344. pLVCD->clrTextBk = g_gridcol2;
  345. int posbase=pos;
  346. while(m_List1.m_arLabels.ElementAt (posbase).ElementAt (0).IsEmpty ())
  347. {
  348. posbase--;
  349. if(posbase<1)break;
  350. }
  351. BOOL bNeedReturn=0;
  352. CTimeSpan dt(m_dtdays, 0, 0, 0);
  353. CTime todaytm(atoi(g_date.Mid (0,4)),atoi(g_date.Mid (5,2)),atoi(g_date.Mid (8,2)),0,0,0);
  354. todaytm+=dt;
  355. int cot=atoi(m_List1.m_arLabels.ElementAt (posbase).ElementAt (2))-atoi(m_List1.m_arLabels.ElementAt (posbase).ElementAt (3));
  356. if(posbase==pos)
  357. {
  358. bNeedReturn=0;
  359. CString time1=m_List1.m_arLabels.ElementAt (pos).ElementAt (8);
  360. if(time1.GetLength()>5)
  361. {
  362. CTime returntm(atoi(time1.Mid (0,4)),atoi(time1.Mid (5,2)),atoi(time1.Mid (8,2)),0,0,0);
  363. if(todaytm>=returntm)
  364. bNeedReturn=1;
  365. }
  366. if(bNeedReturn||atoi(m_List1.m_arLabels.ElementAt (posbase).ElementAt (6))>cot)
  367. crText = RGB(220,0,0);
  368. else
  369. crText = RGB(20,133,20);
  370. pLVCD->clrText = crText;
  371. }
  372. else
  373. {
  374. CString time1=m_List1.m_arLabels.ElementAt (pos).ElementAt (7);
  375. CTime taketm(atoi(time1.Mid (0,4)),atoi(time1.Mid (5,2)),atoi(time1.Mid (8,2)),0,0,0); //取衣日
  376. for(int i=posbase; i<pos; i++)
  377. {
  378. time1=m_List1.m_arLabels.ElementAt (i).ElementAt (8);
  379. CTime returntm(atoi(time1.Mid (0,4)),atoi(time1.Mid (5,2)),atoi(time1.Mid (8,2)),0,0,0);
  380. if((returntm+dt)>=taketm)
  381. cot-=atoi(m_List1.m_arLabels.ElementAt (i).ElementAt (6));
  382. // else if(returntm<=todaytm)
  383. // cot-=atoi(m_List1.m_arLabels.ElementAt (i).ElementAt (6));
  384. }
  385. bNeedReturn=0;
  386. time1=m_List1.m_arLabels.ElementAt (pos).ElementAt (8);
  387. if(time1.GetLength()>5)
  388. {
  389. CTime returntm(atoi(time1.Mid (0,4)),atoi(time1.Mid (5,2)),atoi(time1.Mid (8,2)),0,0,0);
  390. if(returntm<=todaytm)
  391. bNeedReturn=1;
  392. }
  393. if(bNeedReturn==0 && cot>=atoi(m_List1.m_arLabels.ElementAt (pos).ElementAt (6)))
  394. crText = RGB(20,133,20);
  395. else
  396. crText = RGB(220,0,0);
  397. pLVCD->clrText = crText;
  398. }
  399. // Store the color back in the NMLVCUSTOMDRAW struct.
  400. // Tell Windows to paint the control itself.
  401. *pResult = CDRF_DODEFAULT;
  402. }
  403. }