123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- // GetPhoneAge.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "GetPhoneAge.h"
- #include "MyMdi.H"
- #include "SetStyle.h"
- #include "CalendarConvert.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern float g_WidthScale;
- extern float g_HeightScale;
- extern BOOL CALLBACK EnumChildProc2(HWND hwnd,LPARAM lParam);
- extern BOOL CovertDate(CString &date, CString &date2);
- ////////////////////////////////////////////////////////////IDC_STATIC1/////////////////
- GetPhoneAge::GetPhoneAge(CWnd* pParent /*=NULL*/)
- : CDialog(GetPhoneAge::IDD)
- {
- //{{AFX_DATA_INIT(GetPhoneAge)
- m_age1 = 0;
- m_age2 = 0;
- m_age3 = 0;
- m_age4 = 0;
- //}}AFX_DATA_INIT
- }
- void GetPhoneAge::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(GetPhoneAge)
- DDX_Control(pDX, IDC_SPIN6, m_spin4);
- DDX_Control(pDX, IDC_SPIN2, m_spin3);
- DDX_Control(pDX, IDC_SPIN4, m_spin2);
- DDX_Control(pDX, IDC_SPIN1, m_spin1);
- DDX_Control(pDX, IDC_LIST2, m_List1);
- DDX_Text(pDX, IDC_EDIT1, m_age1);
- DDX_Text(pDX, IDC_EDIT2, m_age2);
- DDX_Text(pDX, IDC_EDIT3, m_age3);
- DDX_Text(pDX, IDC_EDIT7, m_age4);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(GetPhoneAge, CDialog)
- //{{AFX_MSG_MAP(GetPhoneAge)
- ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // GetPhoneAge diagnostics
- #ifdef _DEBUG
- void GetPhoneAge::AssertValid() const
- {
- CDialog::AssertValid();
- }
- void GetPhoneAge::Dump(CDumpContext& dc) const
- {
- CDialog::Dump(dc);
- }
- #endif //_DEBUG
- void GetPhoneAge::OnBUTclose()
- {
- // TO DO: Add your control notification handler code here
- CDialog::OnOK ();
- }
- BOOL GetPhoneAge::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
- g_WidthScale2 = (float)g_rc.Width()/(float)rc2.Width(); // new/Old
- g_HeightScale2 = (float)g_rc.Height()/(float)rc2.Height();
- EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc2,0);
- GetDlgItem(IDC_BUTTON3)->EnableWindow(IsHasRights2new(49));
- m_List1.SetHeadings("家长姓名,100;宝宝姓名,100;手机,100;宝宝生日,100;宝宝年龄,100;天数,100;套系名称,100;套系价格,100;预约时间,100" );
- m_List1.LoadColumnInfo (184);
- m_spin1.SetRange (1, 20);
- m_spin2.SetRange (1, 20);
- m_spin3.SetRange (1, 20);
- m_spin4.SetRange (1, 20);
- CArray<CStringArray, CStringArray>List1array[10];
- g_sendhead.bsql=0;
- g_sendhead.code[0]=64;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(15);
- if(g_bSendOK==0)
- {
- return true;
- }
- DataToArray(&(List1array[0]));
- int i = 0;
- int g_nYearposTemp=g_nYearpos;
- for( i=0; i< g_hisyeararray.GetSize (); i++)
- {
- if(i>=9)break;
- g_nYearpos=i;
- g_sendhead.bsql=0;
- g_sendhead.code[0]=64;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(15);
- if(g_bSendOK==0)
- {
- g_nYearpos=g_nYearposTemp;
- return true;
- }
- DataToArray(&(List1array[i+1]));
- }
- g_nYearpos=g_nYearposTemp;
- int size=0;
- for(i=0; i<10; i++)
- {
- size+=List1array[i].GetSize ();
- }
- m_List1array.SetSize(size);
- int pos=0;
- for(i=0; i<10; i++)
- {
- if(List1array[i].GetSize ()==0)continue;
- for(int a=0; a<List1array[i].GetSize (); a++)
- {
- m_List1array.ElementAt (pos).Copy (List1array[i].ElementAt (a));
- pos++;
- }
- }
- CString date1,date2,str;
- CTime tm=CTime::GetCurrentTime ();
- int days;
- for(i=0; i<m_List1array.GetSize (); i++)
- {
- date1=m_List1array.ElementAt (i).ElementAt (3);
- if(m_List1array.ElementAt (i).ElementAt (7)=="1")
- {
- date2.Empty ();
- CovertDate(date1,date2);
- if(date2!="")date1=date2;
- }
- if(date1.GetLength ()==10)
- {
- 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 ());
- CTimeSpan dt=tm-tm2;
- days=dt.GetDays ()+1;
- str.Format ("%d", days);
- m_List1array.ElementAt (i).InsertAt (4, str);
- if(days%365==0)
- days/=365;
- else
- {
- days/=365;
- days++;
- }
- str.Format ("%d", days);
- m_List1array.ElementAt (i).InsertAt (4, str);
- }
- else
- {
- m_List1array.ElementAt (i).InsertAt (4, "未知");
- m_List1array.ElementAt (i).InsertAt (4, "未知");
- }
- m_List1array.ElementAt (i).SetAt (9, m_List1array.ElementAt (i).ElementAt (2));
- if(IsHasRights2new(31)==0)
- {
- m_List1array.ElementAt (i).SetAt (2, "***");
- }
- }
- FillGrid();
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- //messagebox
- void GetPhoneAge::FillGrid()
- {
- UpdateData();
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
- int count=0;
- m_pArray->RemoveAll ();
- BOOL bcheck=0;
- int age1=m_age1;
- int age2=m_age2;
- if(age1==0 && age2==0)
- {
- bcheck=1;
- age2=1000;
- }
- //生日
- {
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
- if(bcheck==0 && "未知"==m_List1array.ElementAt (ii).ElementAt (4))continue;
- if( atoi(m_List1array.ElementAt (ii).ElementAt (4))>=age1 && atoi(m_List1array.ElementAt (ii).ElementAt (4))<=age2 )
- {
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
- if(!m_List1array.ElementAt (ii).ElementAt (9).IsEmpty ())
- {
- m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (0));
- m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (9));
- }
- }
- }
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- }
- void GetPhoneAge::FillGrid2()
- {
- UpdateData();
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
- int count=0;
- m_pArray->RemoveAll ();
- BOOL bcheck=0;
- int age1=m_age3;
- int age2=m_age4;
- if(age1==0 && age2==0)
- {
- bcheck=1;
- age2=1000000;
- }
- //生日
- {
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
- if(bcheck==0 && "未知"==m_List1array.ElementAt (ii).ElementAt (5))continue;
- if( atoi(m_List1array.ElementAt (ii).ElementAt (5))>=age1 && atoi(m_List1array.ElementAt (ii).ElementAt (5))<=age2 )
- {
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
- if(!m_List1array.ElementAt (ii).ElementAt (9).IsEmpty ())
- {
- m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (0));
- m_pArray->Add (m_List1array.ElementAt (ii).ElementAt (9));
- }
- }
- }
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- }
- void GetPhoneAge::OnButton1()
- {
- // TODO: Add your control notification handler code here
- FillGrid();
- }
- void GetPhoneAge::OnButton2()
- {
- // TODO: Add your control notification handler code here
- FillGrid2();
- }
- void GetPhoneAge::OnButton3()
- {
- // TODO: Add your control notification handler code here
- ListToXLS(&m_List1, "c:\\客户资料.xls", 0);
- }
|