GetPhoneAge.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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 i = 0;
  97. int g_nYearposTemp=g_nYearpos;
  98. for( i=0; i< g_hisyeararray.GetSize (); i++)
  99. {
  100. if(i>=9)break;
  101. g_nYearpos=i;
  102. g_sendhead.bsql=0;
  103. g_sendhead.code[0]=64;
  104. g_sendhead.tabcount=1;
  105. g_pMainWnd->ProcessChatMessageRequest2(15);
  106. if(g_bSendOK==0)
  107. {
  108. g_nYearpos=g_nYearposTemp;
  109. return true;
  110. }
  111. DataToArray(&(List1array[i+1]));
  112. }
  113. g_nYearpos=g_nYearposTemp;
  114. int size=0;
  115. for(i=0; i<10; i++)
  116. {
  117. size+=List1array[i].GetSize ();
  118. }
  119. m_List1array.SetSize(size);
  120. int pos=0;
  121. for(i=0; i<10; i++)
  122. {
  123. if(List1array[i].GetSize ()==0)continue;
  124. for(int a=0; a<List1array[i].GetSize (); a++)
  125. {
  126. m_List1array.ElementAt (pos).Copy (List1array[i].ElementAt (a));
  127. pos++;
  128. }
  129. }
  130. CString date1,date2,str;
  131. CTime tm=CTime::GetCurrentTime ();
  132. int days;
  133. for(i=0; i<m_List1array.GetSize (); i++)
  134. {
  135. date1=m_List1array.ElementAt (i).ElementAt (3);
  136. if(m_List1array.ElementAt (i).ElementAt (7)=="1")
  137. {
  138. date2.Empty ();
  139. CovertDate(date1,date2);
  140. if(date2!="")date1=date2;
  141. }
  142. if(date1.GetLength ()==10)
  143. {
  144. 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 ());
  145. CTimeSpan dt=tm-tm2;
  146. days=dt.GetDays ()+1;
  147. str.Format ("%d", days);
  148. m_List1array.ElementAt (i).InsertAt (4, str);
  149. if(days%365==0)
  150. days/=365;
  151. else
  152. {
  153. days/=365;
  154. days++;
  155. }
  156. str.Format ("%d", days);
  157. m_List1array.ElementAt (i).InsertAt (4, str);
  158. }
  159. else
  160. {
  161. m_List1array.ElementAt (i).InsertAt (4, "未知");
  162. m_List1array.ElementAt (i).InsertAt (4, "未知");
  163. }
  164. m_List1array.ElementAt (i).SetAt (9, m_List1array.ElementAt (i).ElementAt (2));
  165. if(IsHasRights2new(31)==0)
  166. {
  167. m_List1array.ElementAt (i).SetAt (2, "***");
  168. }
  169. }
  170. FillGrid();
  171. return TRUE; // return TRUE unless you set the focus to a control
  172. // EXCEPTION: OCX Property Pages should return FALSE
  173. }
  174. //messagebox
  175. void GetPhoneAge::FillGrid()
  176. {
  177. UpdateData();
  178. m_List1.DeleteAllItems2 ();
  179. int ii=0;
  180. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  181. int count=0;
  182. m_pArray->RemoveAll ();
  183. BOOL bcheck=0;
  184. int age1=m_age1;
  185. int age2=m_age2;
  186. if(age1==0 && age2==0)
  187. {
  188. bcheck=1;
  189. age2=1000;
  190. }
  191. //生日
  192. {
  193. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  194. {
  195. if(bcheck==0 && "未知"==m_List1array.ElementAt (ii).ElementAt (4))continue;
  196. if( atoi(m_List1array.ElementAt (ii).ElementAt (4))>=age1 && atoi(m_List1array.ElementAt (ii).ElementAt (4))<=age2 )
  197. {
  198. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  199. if(!m_List1array.ElementAt (ii).ElementAt (9).IsEmpty ())
  200. {
  201. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (0));
  202. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (9));
  203. }
  204. }
  205. }
  206. }
  207. m_List1.m_arLabels.SetSize(count, 1);
  208. ii=count;
  209. m_List1.m_LabelCount=ii;
  210. m_List1.SetItemCountEx (ii);
  211. }
  212. void GetPhoneAge::FillGrid2()
  213. {
  214. UpdateData();
  215. m_List1.DeleteAllItems2 ();
  216. int ii=0;
  217. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  218. int count=0;
  219. m_pArray->RemoveAll ();
  220. BOOL bcheck=0;
  221. int age1=m_age3;
  222. int age2=m_age4;
  223. if(age1==0 && age2==0)
  224. {
  225. bcheck=1;
  226. age2=1000000;
  227. }
  228. //生日
  229. {
  230. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  231. {
  232. if(bcheck==0 && "未知"==m_List1array.ElementAt (ii).ElementAt (5))continue;
  233. if( atoi(m_List1array.ElementAt (ii).ElementAt (5))>=age1 && atoi(m_List1array.ElementAt (ii).ElementAt (5))<=age2 )
  234. {
  235. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  236. if(!m_List1array.ElementAt (ii).ElementAt (9).IsEmpty ())
  237. {
  238. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (0));
  239. m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (9));
  240. }
  241. }
  242. }
  243. }
  244. m_List1.m_arLabels.SetSize(count, 1);
  245. ii=count;
  246. m_List1.m_LabelCount=ii;
  247. m_List1.SetItemCountEx (ii);
  248. }
  249. void GetPhoneAge::OnButton1()
  250. {
  251. // TODO: Add your control notification handler code here
  252. FillGrid();
  253. }
  254. void GetPhoneAge::OnButton2()
  255. {
  256. // TODO: Add your control notification handler code here
  257. FillGrid2();
  258. }
  259. void GetPhoneAge::OnButton3()
  260. {
  261. // TODO: Add your control notification handler code here
  262. ListToXLS(&m_List1, "c:\\客户资料.xls", 0);
  263. }