GetPhoneAge.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. // GetPhoneAge.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "GetPhoneAge.h"
  6. #include "MyMdi.H"
  7. #include "SetStyle.h"
  8. #include "CalendarConvert.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. extern float g_WidthScale;
  15. extern float g_HeightScale;
  16. extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
  17. extern BOOL CovertDate(CString &date, CString &date2);
  18. ////////////////////////////////////////////////////////////IDC_STATIC1/////////////////
  19. GetPhoneAge::GetPhoneAge(CWnd* pParent /*=NULL*/)
  20. : CDialog(GetPhoneAge::IDD)
  21. {
  22. //{{AFX_DATA_INIT(GetPhoneAge)
  23. m_age1 = 0;
  24. m_age2 = 0;
  25. m_age3 = 0;
  26. m_age4 = 0;
  27. //}}AFX_DATA_INIT
  28. }
  29. void GetPhoneAge::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CDialog::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(GetPhoneAge)
  33. DDX_Control(pDX, IDC_SPIN6, m_spin4);
  34. DDX_Control(pDX, IDC_SPIN2, m_spin3);
  35. DDX_Control(pDX, IDC_SPIN4, m_spin2);
  36. DDX_Control(pDX, IDC_SPIN1, m_spin1);
  37. DDX_Control(pDX, IDC_LIST2, m_List1);
  38. DDX_Text(pDX, IDC_EDIT1, m_age1);
  39. DDX_Text(pDX, IDC_EDIT2, m_age2);
  40. DDX_Text(pDX, IDC_EDIT3, m_age3);
  41. DDX_Text(pDX, IDC_EDIT7, m_age4);
  42. //}}AFX_DATA_MAP
  43. }
  44. BEGIN_MESSAGE_MAP(GetPhoneAge, CDialog)
  45. //{{AFX_MSG_MAP(GetPhoneAge)
  46. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  47. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  48. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  49. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. /////////////////////////////////////////////////////////////////////////////
  53. // GetPhoneAge diagnostics
  54. #ifdef _DEBUG
  55. void GetPhoneAge::AssertValid() const
  56. {
  57. CDialog::AssertValid();
  58. }
  59. void GetPhoneAge::Dump(CDumpContext& dc) const
  60. {
  61. CDialog::Dump(dc);
  62. }
  63. #endif //_DEBUG
  64. void GetPhoneAge::OnBUTclose()
  65. {
  66. // TO DO: Add your control notification handler code here
  67. CDialog::OnOK ();
  68. }
  69. BOOL GetPhoneAge::OnInitDialog()
  70. {
  71. CDialog::OnInitDialog();
  72. // TODO: Add extra initialization here
  73. CRect rc2;
  74. GetWindowRect(rc2);
  75. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  76. g_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
  77. g_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
  78. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
  79. GetDlgItem(IDC_BUTTON3)->EnableWindow(IsHasRights2new(49));
  80. m_List1.SetHeadings("家长姓名,100;宝宝姓名,100;手机,100;宝宝生日,100;宝宝年龄,100;天数,100;套系名称,100;套系价格,100;预约时间,100" );
  81. m_List1.LoadColumnInfo (184);
  82. m_spin1.SetRange (1, 20);
  83. m_spin2.SetRange (1, 20);
  84. m_spin3.SetRange (1, 20);
  85. m_spin4.SetRange (1, 20);
  86. CArray<CStringArray, CStringArray>List1array[10];
  87. g_sendhead.bsql=0;
  88. g_sendhead.code[0]=64;
  89. g_sendhead.tabcount=1;
  90. g_pMainWnd->ProcessChatMessageRequest2(15);
  91. if(g_bSendOK==0)
  92. {
  93. return true;
  94. }
  95. DataToArray(&(List1array[0]));
  96. int g_nYearposTemp=g_nYearpos;
  97. for(int i=0; i< g_hisyeararray.GetSize (); i++)
  98. {
  99. if(i>=9)break;
  100. g_nYearpos=i;
  101. g_sendhead.bsql=0;
  102. g_sendhead.code[0]=64;
  103. g_sendhead.tabcount=1;
  104. g_pMainWnd->ProcessChatMessageRequest2(15);
  105. if(g_bSendOK==0)
  106. {
  107. g_nYearpos=g_nYearposTemp;
  108. return true;
  109. }
  110. DataToArray(&(List1array[i+1]));
  111. }
  112. g_nYearpos=g_nYearposTemp;
  113. int size=0;
  114. for(i=0; i<10; i++)
  115. {
  116. size+=List1array[i].GetSize ();
  117. }
  118. m_List1array.SetSize(size);
  119. int pos=0;
  120. for(i=0; i<10; i++)
  121. {
  122. if(List1array[i].GetSize ()==0)continue;
  123. for(int a=0; a<List1array[i].GetSize (); a++)
  124. {
  125. m_List1array.ElementAt (pos).Copy (List1array[i].ElementAt (a));
  126. pos++;
  127. }
  128. }
  129. CString date1,date2,str;
  130. CTime tm=CTime::GetCurrentTime ();
  131. int days;
  132. for(i=0; i<m_List1array.GetSize (); i++)
  133. {
  134. date1=m_List1array.ElementAt (i).ElementAt (3);
  135. if(m_List1array.ElementAt (i).ElementAt (7)=="1")
  136. {
  137. date2.Empty ();
  138. CovertDate(date1,date2);
  139. if(date2!="")date1=date2;
  140. }
  141. if(date1.GetLength ()==10)
  142. {
  143. CTime tm2( atoi(date1.Mid (0,4)), atoi(date1.Mid (5,2)), atoi(date1.Mid (8,2)), CTime::GetCurrentTime ().GetHour (), CTime::GetCurrentTime ().GetMinute (),CTime::GetCurrentTime ().GetSecond ());
  144. CTimeSpan dt=tm-tm2;
  145. days=dt.GetDays ()+1;
  146. str.Format ("%d", days);
  147. m_List1array.ElementAt (i).InsertAt (4, str);
  148. if(days%365==0)
  149. days/=365;
  150. else
  151. {
  152. days/=365;
  153. days++;
  154. }
  155. str.Format ("%d", days);
  156. m_List1array.ElementAt (i).InsertAt (4, str);
  157. }
  158. else
  159. {
  160. m_List1array.ElementAt (i).InsertAt (4, "未知");
  161. m_List1array.ElementAt (i).InsertAt (4, "未知");
  162. }
  163. m_List1array.ElementAt (i).SetAt (9, m_List1array.ElementAt (i).ElementAt (2));
  164. if(IsHasRights2new(31)==0)
  165. {
  166. m_List1array.ElementAt (i).SetAt (2, "***");
  167. }
  168. }
  169. FillGrid();
  170. return TRUE; // return TRUE unless you set the focus to a control
  171. // EXCEPTION: OCX Property Pages should return FALSE
  172. }
  173. //messagebox
  174. void GetPhoneAge::FillGrid()
  175. {
  176. UpdateData();
  177. m_List1.DeleteAllItems2 ();
  178. int ii=0;
  179. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  180. int count=0;
  181. m_pArray->RemoveAll ();
  182. BOOL bcheck=0;
  183. int age1=m_age1;
  184. int age2=m_age2;
  185. if(age1==0 && age2==0)
  186. {
  187. bcheck=1;
  188. age2=1000;
  189. }
  190. //生日
  191. {
  192. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  193. {
  194. if(bcheck==0 && "未知"==m_List1array.ElementAt (ii).ElementAt (4))continue;
  195. if( atoi(m_List1array.ElementAt (ii).ElementAt (4))>=age1 && atoi(m_List1array.ElementAt (ii).ElementAt (4))<=age2 )
  196. {
  197. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  198. if(!m_List1array.ElementAt (ii).ElementAt (9).IsEmpty ())
  199. {
  200. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (0));
  201. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (9));
  202. }
  203. }
  204. }
  205. }
  206. m_List1.m_arLabels.SetSize(count, 1);
  207. ii=count;
  208. m_List1.m_LabelCount=ii;
  209. m_List1.SetItemCountEx (ii);
  210. }
  211. void GetPhoneAge::FillGrid2()
  212. {
  213. UpdateData();
  214. m_List1.DeleteAllItems2 ();
  215. int ii=0;
  216. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  217. int count=0;
  218. m_pArray->RemoveAll ();
  219. BOOL bcheck=0;
  220. int age1=m_age3;
  221. int age2=m_age4;
  222. if(age1==0 && age2==0)
  223. {
  224. bcheck=1;
  225. age2=1000000;
  226. }
  227. //生日
  228. {
  229. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  230. {
  231. if(bcheck==0 && "未知"==m_List1array.ElementAt (ii).ElementAt (5))continue;
  232. if( atoi(m_List1array.ElementAt (ii).ElementAt (5))>=age1 && atoi(m_List1array.ElementAt (ii).ElementAt (5))<=age2 )
  233. {
  234. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  235. if(!m_List1array.ElementAt (ii).ElementAt (9).IsEmpty ())
  236. {
  237. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (0));
  238. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (9));
  239. }
  240. }
  241. }
  242. }
  243. m_List1.m_arLabels.SetSize(count, 1);
  244. ii=count;
  245. m_List1.m_LabelCount=ii;
  246. m_List1.SetItemCountEx (ii);
  247. }
  248. void GetPhoneAge::OnButton1()
  249. {
  250. // TODO: Add your control notification handler code here
  251. FillGrid();
  252. }
  253. void GetPhoneAge::OnButton2()
  254. {
  255. // TODO: Add your control notification handler code here
  256. FillGrid2();
  257. }
  258. void GetPhoneAge::OnButton3()
  259. {
  260. // TODO: Add your control notification handler code here
  261. ListToXLS(&m_List1, "c:\\客户资料.xls", 0);
  262. }