// ShowHistoryClient.cpp : implementation file
//

#include "stdafx.h"
#include "ylgl.h"
#include "ShowHistoryClient.h"
#include "Booking2.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// ShowHistoryClient dialog


ShowHistoryClient::ShowHistoryClient(CWnd* pParent /*=NULL*/)
	: CDialog(ShowHistoryClient::IDD, pParent)
{
	//{{AFX_DATA_INIT(ShowHistoryClient)
		// NOTE: the ClassWizard will add member initialization here
	m_pos=0;
	//}}AFX_DATA_INIT
}


void ShowHistoryClient::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(ShowHistoryClient)
	DDX_Control(pDX, IDC_LIST1, m_List1);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ShowHistoryClient, CDialog)
	//{{AFX_MSG_MAP(ShowHistoryClient)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ShowHistoryClient message handlers

BOOL ShowHistoryClient::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here m_poldclientarray g_oldclientarray
	CString str;
	int pos;
 	for(int i=0; i<m_poldclientarray->GetSize (); i++)
	{
		pos=m_poldclientarray->ElementAt(i);
		str.Format("����:%s ����:%s", g_oldclientarray.ElementAt(pos).ElementAt(1)+g_oldclientarray.ElementAt(pos).ElementAt(2), g_oldclientarray.ElementAt(pos).ElementAt(0));
	 

		if(m_List1.GetCount()%2)
			m_List1.AddEntry( str , g_gridcol1, m_List1.GetCount());
		else
			m_List1.AddEntry( str , g_gridcol2, m_List1.GetCount());
#ifdef CHILD_VERSION
		m_yearposarray.Add(atoi(g_oldclientarray.ElementAt(pos).ElementAt(12)));
#else
		m_yearposarray.Add(atoi(g_oldclientarray.ElementAt(pos).ElementAt(19)));
#endif
	}
	m_List1.Invalidate (); 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void ShowHistoryClient::OnButton1() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	int pos= m_List1.GetCurSel() ;
	if(pos==-1)
	{
		AfxMessageBox("����ѡ����Ҫ�鿴�Ķ���", MB_ICONINFORMATION);return;
	}
	CString str,id;
	m_List1.GetText (pos, str);
	id=str.Right(str.GetLength()-str.Find("����:")-5);
	Booking2 dlg;
	dlg.m_id = id;	
	dlg.m_bModify =2;
	int g_nYearposTemp=g_nYearpos;
	g_nYearpos=m_yearposarray.ElementAt(pos);
	dlg.DoModal ();
	g_nYearpos=g_nYearposTemp;
}

void ShowHistoryClient::OnOK() 
{
	// TODO: Add extra validation here
	int pos= m_List1.GetCurSel() ;
	if(pos==-1)
	{
		AfxMessageBox("����ѡ�ж���", MB_ICONINFORMATION);return;
	}
	m_pos=pos;
	CDialog::OnOK();
}