Card2Reg.cpp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. // Card2Reg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "Card2Reg.h"
  6. #include "MyMdi.H"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // Card2Reg
  14. IMPLEMENT_DYNCREATE(Card2Reg, MyFormView)
  15. Card2Reg::Card2Reg()
  16. : MyFormView(Card2Reg::IDD)
  17. {
  18. //{{AFX_DATA_INIT(Card2Reg)
  19. m_year = atoi(g_date.Mid (0,4));
  20. m_month = atoi(g_date.Mid (5,2));
  21. m_day = atoi(g_date.Mid (8,2));
  22. m_bInit=0;
  23. m_filter = _T("");
  24. //}}AFX_DATA_INIT
  25. //m_date = CTime::GetCurrentTime ().Format ("%Y-%m-%d");
  26. }
  27. Card2Reg::~Card2Reg()
  28. {
  29. }
  30. void Card2Reg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. MyFormView::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(Card2Reg)
  34. DDX_Control(pDX, IDC_SPIN3, m_spinday);
  35. DDX_Control(pDX, IDC_SPIN2, m_spinmonth);
  36. DDX_Control(pDX, IDC_SPIN1, m_spinyear);
  37. DDX_Control(pDX, IDC_LIST2, m_List1);
  38. DDX_Control(pDX, IDC_STATIC1, m_static1);
  39. DDX_Text(pDX, IDC_EDITyear, m_year);
  40. DDV_MinMaxUInt(pDX, m_year, 1900, 3000);
  41. DDX_Text(pDX, IDC_EDITmonth, m_month);
  42. DDV_MinMaxUInt(pDX, m_month, 1, 12);
  43. DDX_Text(pDX, IDC_EDITday, m_day);
  44. DDV_MinMaxUInt(pDX, m_day, 1, 31);
  45. DDX_Text(pDX, IDC_EDIT1, m_filter);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(Card2Reg, MyFormView)
  49. //{{AFX_MSG_MAP(Card2Reg)
  50. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  51. ON_EN_CHANGE(IDC_EDITyear, OnChangeEDITyear)
  52. ON_EN_CHANGE(IDC_EDITmonth, OnChangeEDITmonth)
  53. ON_EN_CHANGE(IDC_EDITday, OnChangeEDITday)
  54. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  55. //}}AFX_MSG_MAP
  56. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  57. END_MESSAGE_MAP()
  58. /////////////////////////////////////////////////////////////////////////////
  59. // Card2Reg diagnostics
  60. #ifdef _DEBUG
  61. void Card2Reg::AssertValid() const
  62. {
  63. MyFormView::AssertValid();
  64. }
  65. void Card2Reg::Dump(CDumpContext& dc) const
  66. {
  67. MyFormView::Dump(dc);
  68. }
  69. #endif //_DEBUG
  70. /////////////////////////////////////////////////////////////////////////////
  71. // Card2Reg message handlers
  72. void Card2Reg::OnInitialUpdate()
  73. {
  74. MyFormView::OnInitialUpdate();
  75. // TODO: Add your specialized code here and/or call the base class
  76. CMyMdi Mdi;
  77. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  78. // Here we create the outbar control using the splitter as its parent
  79. // and setting its id to the first pane.
  80. CRect rc2;
  81. GetWindowRect(rc2);
  82. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  83. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  84. m_static1.SetFont (&g_titlefont);
  85. m_List1.SetHeadings("主卡号,100;姓名,100;性别,100;电话,100;副卡号,100;发卡日期,100;副卡订单,100;副卡套系,100;积分,100;收回日期,100" );
  86. m_List1.LoadColumnInfo (167);
  87. m_spinyear.SetRange (1900, 3000);
  88. m_spinmonth.SetRange (1, 12);
  89. m_spinday.SetRange (1, 31);
  90. m_bInit=1;
  91. DateChange();
  92. }
  93. void Card2Reg::FillGrid()
  94. {
  95. m_List1.DeleteAllItems2 ();
  96. int ii=0;
  97. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  98. int count=0;
  99. int nret=0;
  100. int point=0;
  101. if(m_filter.IsEmpty ())
  102. {
  103. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  104. {
  105. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  106. if(m_List1array.ElementAt (ii).ElementAt (9)!="")
  107. {
  108. point+=atol(m_List1array.ElementAt (ii).ElementAt (8));
  109. nret++;
  110. }
  111. }
  112. }
  113. else
  114. {
  115. int type=GetType(m_filter);
  116. if(type==1)//电话
  117. {
  118. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  119. {
  120. if(m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1)
  121. {
  122. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  123. if(m_List1array.ElementAt (ii).ElementAt (9)!="")
  124. {
  125. point+=atol(m_List1array.ElementAt (ii).ElementAt (8));
  126. nret++;
  127. }
  128. }
  129. }
  130. }
  131. else if(type==2)//拼音
  132. {
  133. m_filter.MakeUpper ();
  134. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  135. {
  136. if(m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1)
  137. {
  138. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  139. if(m_List1array.ElementAt (ii).ElementAt (9)!="")
  140. {
  141. point+=atol(m_List1array.ElementAt (ii).ElementAt (8));
  142. nret++;
  143. }
  144. }
  145. }
  146. }
  147. else
  148. {
  149. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  150. {
  151. if(m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 ||\
  152. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  153. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || \
  154. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1|| \
  155. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 || \
  156. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1 || \
  157. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  158. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 || \
  159. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  160. m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 )
  161. {
  162. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  163. if(m_List1array.ElementAt (ii).ElementAt (9)!="")
  164. {
  165. point+=atol(m_List1array.ElementAt (ii).ElementAt (8));
  166. nret++;
  167. }
  168. }
  169. }
  170. }
  171. }
  172. m_List1.m_arLabels.SetSize(count, 1);
  173. ii=count;
  174. m_List1.m_LabelCount=ii;
  175. m_List1.SetItemCountEx (ii);
  176. CString str;
  177. str.Format ("%d", ii);
  178. SetDlgItemText(IDC_EDITmoney1, str);
  179. str.Format ("%d", nret);
  180. SetDlgItemText(IDC_EDITmoney2, str);
  181. str.Format ("%d", point);
  182. SetDlgItemText(IDC_EDITmoney3, str);
  183. }
  184. void Card2Reg::OnBUTclose()
  185. {
  186. // TODO: Add your control notification handler code here
  187. GetParent()->SendMessage(WM_CLOSE);
  188. }
  189. void Card2Reg::OnChangeEDITyear()
  190. {
  191. // TODO: If this is a RICHEDIT control, the control will not
  192. // send this notification unless you override the MyFormView::OnInitDialog()
  193. // function and call CRichEditCtrl().SetEventMask()
  194. // with the ENM_CHANGE flag ORed into the mask.
  195. DateChange();
  196. // TODO: Add your control notification handler code here
  197. }
  198. void Card2Reg::OnChangeEDITmonth()
  199. {
  200. // TODO: If this is a RICHEDIT control, the control will not
  201. // send this notification unless you override the MyFormView::OnInitDialog()
  202. // function and call CRichEditCtrl().SetEventMask()
  203. // with the ENM_CHANGE flag ORed into the mask.
  204. // DateChange();
  205. // TODO: Add your control notification handler code here
  206. }
  207. void Card2Reg::OnChangeEDITday()
  208. {
  209. // TODO: If this is a RICHEDIT control, the control will not
  210. // send this notification unless you override the MyFormView::OnInitDialog()
  211. // function and call CRichEditCtrl().SetEventMask()
  212. // with the ENM_CHANGE flag ORed into the mask.
  213. // DateChange();
  214. // TODO: Add your control notification handler code here
  215. }
  216. void Card2Reg::DateChange()
  217. {
  218. if(m_bInit==0)return;
  219. m_spinyear.EnableWindow(0);
  220. m_spinmonth.EnableWindow(0);
  221. m_spinday.EnableWindow(0);
  222. UpdateData();
  223. g_sendhead.bsql=0;
  224. g_sendhead.code[0]=129;
  225. g_sendhead.tabcount=1;
  226. CString sql,strdate;
  227. strdate.Format ("%04d", m_year);
  228. m_static1.SetWindowText (strdate+"转介绍积分");
  229. g_pMainWnd->ProcessChatMessageRequest2(strdate);
  230. if(g_bSendOK==0)
  231. {
  232. m_spinyear.EnableWindow(1);
  233. m_spinmonth.EnableWindow(1);
  234. m_spinday.EnableWindow(1);
  235. return;
  236. }
  237. DataToArray(&m_List1array);
  238. KindChange();
  239. m_spinyear.EnableWindow(1);
  240. m_spinmonth.EnableWindow(1);
  241. m_spinday.EnableWindow(1);
  242. }
  243. void Card2Reg::KindChange()
  244. {
  245. FillGrid();
  246. }
  247. void Card2Reg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  248. {
  249. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  250. // Take the default processing unless we set this to something else below.
  251. *pResult = 0;
  252. // First thing - check the draw stage. If it's the control's prepaint
  253. // stage, then tell Windows we want messages for every item.
  254. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  255. {
  256. *pResult = CDRF_NOTIFYITEMDRAW;
  257. }
  258. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  259. {
  260. // This is the prepaint stage for an item. Here's where we set the
  261. // item's text color. Our return value will tell Windows to draw the
  262. // item itself, but it will use the new color we set here.
  263. // We'll cycle the colors through red, green, and light blue.
  264. if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (8)=="")
  265. pLVCD->clrText = RGB(220,0,0);
  266. else
  267. pLVCD->clrText = RGB(20,133,20);
  268. if(pLVCD->nmcd.dwItemSpec%2)
  269. pLVCD->clrTextBk = g_gridcol1;
  270. else
  271. pLVCD->clrTextBk = g_gridcol2;
  272. // Store the color back in the NMLVCUSTOMDRAW struct.
  273. // Tell Windows to paint the control itself.
  274. *pResult = CDRF_DODEFAULT;
  275. }
  276. }
  277. void Card2Reg::OnButton1()
  278. {
  279. // TODO: Add your control notification handler code here
  280. UpdateData();
  281. m_filter.TrimLeft ();
  282. m_filter.TrimRight ();
  283. FillGrid();
  284. }
  285. BOOL Card2Reg::PreTranslateMessage(MSG* pMsg)
  286. {
  287. // TODO: Add your specialized code here and/or call the base class
  288. try
  289. {
  290. if(pMsg->message==WM_KEYDOWN)
  291. {
  292. switch (pMsg->wParam)
  293. {
  294. case VK_RETURN:
  295. InputOK();
  296. OnButton1();
  297. return 1;
  298. case 0x43: // copy
  299. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  300. {
  301. GetFocus()->SendMessage(WM_COPY);
  302. return TRUE;
  303. }
  304. break;
  305. case 0x56: //Ctrl + V:
  306. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  307. {
  308. GetFocus()->SendMessage(WM_PASTE);
  309. return TRUE;
  310. }
  311. break;
  312. case 0x58: // cut
  313. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  314. {
  315. GetFocus()->SendMessage(WM_CUT);
  316. return TRUE;
  317. }
  318. break;
  319. case 0x5A: //undo
  320. case 0x59: //redo
  321. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  322. {
  323. GetFocus()->SendMessage(WM_UNDO);
  324. return TRUE;
  325. }
  326. break;
  327. case '0':
  328. case VK_NUMPAD0:
  329. m_no+="0";
  330. break;
  331. case '1':
  332. case VK_NUMPAD1:
  333. m_no+="1";
  334. break;
  335. case '2':
  336. case VK_NUMPAD2:
  337. m_no+="2";
  338. break;
  339. case '3':
  340. case VK_NUMPAD3:
  341. m_no+="3";
  342. break;
  343. case '4':
  344. case VK_NUMPAD4:
  345. m_no+="4";
  346. break;
  347. case '5':
  348. case VK_NUMPAD5:
  349. m_no+="5";
  350. break;
  351. case '6':
  352. case VK_NUMPAD6:
  353. m_no+="6";
  354. break;
  355. case '7':
  356. case VK_NUMPAD7:
  357. m_no+="7";
  358. break;
  359. case '8':
  360. case VK_NUMPAD8:
  361. m_no+="8";
  362. break;
  363. case '9':
  364. case VK_NUMPAD9:
  365. m_no+="9";
  366. break;
  367. case 187:
  368. m_no+="=";
  369. break;
  370. case VK_BACK:
  371. if(m_no.GetLength ())
  372. {
  373. m_no.Delete (m_no.GetLength ()-1);
  374. }
  375. break;
  376. }
  377. }
  378. return MyFormView::PreTranslateMessage(pMsg);
  379. }
  380. catch(...)
  381. {
  382. }
  383. return TRUE;
  384. }
  385. void Card2Reg::InputOK()
  386. {
  387. if(m_no.IsEmpty ())return;
  388. m_filter=m_no;
  389. m_no.Empty ();
  390. UpdateData(0);
  391. }