DinDanForm2.cpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. // DinDanForm2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "DinDanForm2.h"
  6. #include "DinDanForm.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // DinDanForm2 dialog
  14. DinDanForm2::DinDanForm2(CWnd* pParent /*=NULL*/)
  15. : CDialog(DinDanForm2::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(DinDanForm2)
  18. m_radio1 = 0;
  19. //}}AFX_DATA_INIT
  20. }
  21. void DinDanForm2::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(DinDanForm2)
  25. DDX_Control(pDX, IDC_LIST5, m_List2);
  26. DDX_Control(pDX, IDC_LIST1, m_List1);
  27. DDX_Radio(pDX, IDC_RADIO1, m_radio1);
  28. //}}AFX_DATA_MAP
  29. }
  30. BEGIN_MESSAGE_MAP(DinDanForm2, CDialog)
  31. //{{AFX_MSG_MAP(DinDanForm2)
  32. ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
  33. ON_BN_CLICKED(IDC_RADIO2, OnRadio2)
  34. ON_BN_CLICKED(IDC_RADIO1, OnRadio1)
  35. ON_LBN_SELCHANGE(IDC_LIST5, OnSelchangeList5)
  36. //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // DinDanForm2 message handlers
  40. void DinDanForm2::Init()
  41. {
  42. CRect rc;
  43. GetDlgItem(IDC_RADIO1)->GetWindowRect(rc);
  44. ScreenToClient(rc);
  45. rc.left=5;
  46. GetDlgItem(IDC_RADIO1)->MoveWindow(rc);
  47. int botoom=rc.bottom;
  48. GetClientRect(rc);
  49. rc.left+=5;
  50. rc.top=botoom+5;
  51. rc.right-=5;
  52. rc.bottom-=5;
  53. m_List1.MoveWindow(rc);
  54. m_rc=rc;
  55. m_List1.GetWindowRect(rc);
  56. ScreenToClient(rc);
  57. int hei=rc.Height()/2;
  58. rc.bottom-=hei;
  59. m_List1.MoveWindow(rc);
  60. rc.top=rc.bottom;
  61. rc.bottom+=hei;
  62. m_List2.MoveWindow(rc);
  63. }
  64. void DinDanForm2::TypeChange(CStringArray *pArray)
  65. {
  66. m_array.Copy(*pArray);
  67. m_List1.ResetContent();
  68. for(int i=0; i<pArray->GetSize(); i++)
  69. {
  70. m_List1.AddString(pArray->ElementAt(i));
  71. if(i<10)
  72. m_List1.SetSel(i);
  73. }m_radio1 = 0;UpdateData(0);
  74. FilterChange();
  75. }
  76. void DinDanForm2::TypeChange2(CStringArray *pArray)
  77. {
  78. m_List2.ResetContent();
  79. for(int i=0; i<pArray->GetSize(); i++)
  80. {
  81. m_List2.AddString(pArray->ElementAt(i));
  82. if(i<1)
  83. m_List2.SetSel(i);
  84. }
  85. }
  86. void DinDanForm2::FilterChange()
  87. {
  88. m_pfilterarray->RemoveAll();
  89. int count= m_List1.GetSelCount() ;
  90. if(count==0)return;
  91. if(count>10)
  92. {
  93. for(int i=0; i<m_List1.GetCount(); i++)
  94. {
  95. if(m_List1.GetSel(i))
  96. {
  97. m_List1.SetSel(i, 0);
  98. break;
  99. }
  100. }
  101. FilterChange();
  102. return;
  103. }
  104. int *pIndex=new int[count];
  105. m_List1.GetSelItems(count, pIndex);
  106. CString str;
  107. for(int i=0; i<count; i++)
  108. {
  109. m_List1.GetText (pIndex[i], str);
  110. m_pfilterarray->Add (str);
  111. }
  112. delete []pIndex;
  113. if(m_pfilterarray2->GetSize()==0)
  114. m_pfilterarray2->Add("全部(前期+二销)");
  115. ((DinDanForm*)m_parent)->KindChange();
  116. }
  117. void DinDanForm2::OnSelchangeList1()
  118. {
  119. // TODO: Add your control notification handler code here
  120. FilterChange();
  121. }
  122. void DinDanForm2::OnRadio2()
  123. {
  124. // TODO: Add your control notification handler code here
  125. UpdateData();
  126. m_List1.ResetContent();
  127. if(m_radio1==0)
  128. {
  129. for(int i=0; i<m_array.GetSize(); i++)
  130. {
  131. m_List1.AddString(m_array.ElementAt(i));
  132. if(i<10)
  133. m_List1.SetSel(i);
  134. }
  135. }
  136. else
  137. {
  138. for(int i=m_array.GetSize()-1; i>=0; i--)
  139. {
  140. m_List1.AddString(m_array.ElementAt(i));
  141. if(i>=m_array.GetSize()-10)
  142. m_List1.SetSel(m_array.GetSize()-1-i);
  143. }
  144. }
  145. FilterChange();
  146. }
  147. void DinDanForm2::OnRadio1()
  148. {
  149. // TODO: Add your control notification handler code here
  150. OnRadio2();
  151. }
  152. void DinDanForm2::OnSelchangeList5()
  153. {
  154. // TODO: Add your control notification handler code here
  155. m_pfilterarray2->RemoveAll();
  156. CString str;
  157. int pos=m_List2.GetCurSel();
  158. if(pos!=-1 && m_List2.GetSel(pos) )
  159. {
  160. m_List2.GetText (pos, str);
  161. if(str=="预约收款" || str=="预约补款")
  162. {
  163. m_List2.SetSel(0, 0);
  164. m_List2.SetSel(1, 0);
  165. }
  166. if(str!="预约收款" && str!="预约补款" && pos>2)
  167. {
  168. m_List2.SetSel(0, 0);
  169. m_List2.SetSel(2, 0);
  170. }
  171. if(pos==1 || pos==2)
  172. {
  173. m_List2.SetSel(0, 0);
  174. }
  175. }
  176. BOOL bAll=0;
  177. BOOL bAll1=0;
  178. BOOL bAll2=0;
  179. if(m_List2.GetSel(0))bAll=1;
  180. if(m_List2.GetSel(1))bAll1=1;
  181. if(m_List2.GetSel(2))bAll2=1;
  182. if(bAll)
  183. {
  184. for(int i=1; i<m_List2.GetCount(); i++)
  185. {
  186. m_List2.SetSel(i, 0);
  187. }
  188. }
  189. else
  190. {
  191. if(bAll1)
  192. {
  193. for(int i=3; i<m_List2.GetCount(); i++)
  194. {
  195. m_List2.GetText (i, str);
  196. if(str=="预约收款" || str=="预约补款")
  197. m_List2.SetSel(i, 0);
  198. }
  199. }
  200. if(bAll2)
  201. {
  202. for(int i=3; i<m_List2.GetCount(); i++)
  203. {
  204. m_List2.GetText (i, str);
  205. if(str!="预约收款" && str!="预约补款")
  206. m_List2.SetSel(i, 0);
  207. }
  208. }
  209. }
  210. int count= m_List2.GetSelCount() ;
  211. if(count==0)
  212. {
  213. m_List2.SetSel(0);
  214. OnSelchangeList5();
  215. return;
  216. }
  217. int *pIndex=new int[count];
  218. m_List2.GetSelItems(count, pIndex);
  219. for(int i=0; i<count; i++)
  220. {
  221. m_List2.GetText (pIndex[i], str);
  222. m_pfilterarray2->Add (str);
  223. }
  224. delete []pIndex;
  225. m_pfilterarray->RemoveAll();
  226. ((DinDanForm*)m_parent)->KindChange();
  227. }
  228. void DinDanForm2::ModeChange(int mode)
  229. {
  230. if(mode==0||mode==1||mode==8)
  231. {
  232. ShowWindow(SW_SHOW);
  233. m_List2.ShowWindow(SW_HIDE);
  234. m_List1.MoveWindow(m_rc);
  235. }
  236. else if(mode==7)
  237. {
  238. CRect rc=m_rc;
  239. int hei=rc.Height()/2;
  240. rc.bottom-=hei;
  241. m_List1.MoveWindow(rc);
  242. rc.top=rc.bottom;
  243. rc.bottom+=hei;
  244. m_List2.MoveWindow(rc);
  245. ShowWindow(SW_SHOW);
  246. m_List2.ShowWindow(SW_SHOW);
  247. }
  248. else
  249. ShowWindow(SW_HIDE);
  250. }