Скачиваний:
71
Добавлен:
01.05.2014
Размер:
4.45 Кб
Скачать
// SessionByDate.cpp : implementation file
//

#include "stdafx.h"
#include "DBKino.h"
#include "SessionByDate.h"
#include "CSchedule.h"


// SessionByDate dialog

IMPLEMENT_DYNAMIC(SessionByDate, CDialog)
SessionByDate::SessionByDate(CWnd* pParent /*=NULL*/)
	: CDialog(SessionByDate::IDD, pParent)
	, ctimeSessionByDate(0)
{
}

SessionByDate::~SessionByDate()
{
}

void SessionByDate::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST_SESSION, myListCtrl);
	DDX_Control(pDX, IDC_MONTHCALENDAR_DATE, m_Month);
	DDX_Control(pDX, IDC_DATETIMEPICKER, m_DateCtrl);
	DDX_MonthCalCtrl(pDX, IDC_MONTHCALENDAR_DATE, ctimeSessionByDate);
}


BEGIN_MESSAGE_MAP(SessionByDate, CDialog)
	ON_NOTIFY(MCN_SELECT, IDC_MONTHCALENDAR_DATE, OnMcnSelectMonthcalendarDate)
	ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATETIMEPICKER, OnDtnDatetimechangeDatetimepicker)
	ON_NOTIFY(MCN_SELCHANGE, IDC_MONTHCALENDAR_DATE, OnMcnSelchangeMonthcalendarDate)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_SESSION, OnLvnItemchangedListSession)
END_MESSAGE_MAP()


// SessionByDate message handlers
BOOL SessionByDate::OnInitDialog()
{   
	CDialog::OnInitDialog();

	 DWORD ExStyle = myListCtrl.GetExtendedStyle();
     ExStyle |= LVS_EX_FULLROWSELECT;
     myListCtrl.SetExtendedStyle(ExStyle);

	 myListCtrl.DeleteAllItems();
     ShowSessionColumn();

	 FlagTime = 0;

return TRUE;
}

void SessionByDate::OnMcnSelectMonthcalendarDate(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMSELCHANGE pSelChange = reinterpret_cast<LPNMSELCHANGE>(pNMHDR);
	    CTime temp_Time;	
		m_Month.GetCurSel( temp_Time );	
		m_DateCtrl.SetTime( &temp_Time );	
						
	*pResult = 0;
}

void SessionByDate::OnDtnDatetimechangeDatetimepicker(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMDATETIMECHANGE pDTChange = reinterpret_cast<LPNMDATETIMECHANGE>(pNMHDR);
	CTime temp_Time;	
	m_DateCtrl.GetTime( temp_Time );	
	m_Month.SetCurSel( temp_Time );
	*pResult = 0;
		GetSessionByDate( cMapRep );	
}
void SessionByDate::GetSessionByDate(CMapStringToPtr* cMapRep)
{
    UpdateData(TRUE);
    if( FlagTime != ctimeSessionByDate )
	{
	int i = 0;
	void* ptr;
	CString sFilm;
	POSITION p = cMapRep -> GetStartPosition();
	while(p)
	{
		cMapRep ->GetNextAssoc(p, sFilm, ptr);
        CPtrList* ptrList = ((CPtrList*) ptr);
		for(POSITION pos = ptrList -> GetHeadPosition(); pos != NULL;)
		{
			ptr = ptrList -> GetNext(pos);
			CSchedule* schedule = ((CSchedule*) ptr);
			if( (schedule -> d_DateSession) == ctimeSessionByDate )
			{
				CString Str;		  
				myListCtrl.InsertItem(
							  LVIF_TEXT|LVIF_STATE, i, schedule->s_FilmSession,                                  
	                                                      0, 	
		                                                  LVIS_SELECTED,
                                                          0, 0);
                                     
										 
										 Str = schedule->d_TimeSession.Format("%H : %M");
	                                     myListCtrl.SetItemText(i, 1, Str);
										 Str.Format("%d", schedule ->i_TicketSession);
	                                     myListCtrl.SetItemText(i, 2, Str);
		i++;
			}
		}
	}
	FlagTime = ctimeSessionByDate;
	}
}
void SessionByDate::ShowSessionColumn()
{
    for(int Col=ColumnCount; Col>=0; Col-- )
		{
			myListCtrl.DeleteColumn (Col);
		}
	ColumnCount = 0; 
	LV_COLUMN lvc;

	lvc.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;

	lvc.iSubItem = 0;
	lvc.pszText = _T("Фильм");
	lvc.cx = 150;
	myListCtrl.InsertColumn(0,&lvc);
	ColumnCount++;
	lvc.iSubItem = 1;
	lvc.pszText = _T("Сеанс");
	lvc.cx = 120;
	myListCtrl.InsertColumn(1,&lvc);
	ColumnCount++;
	lvc.iSubItem = 2;
	lvc.pszText = _T("Продано билетов");
	lvc.cx = 70;
	myListCtrl.InsertColumn(2,&lvc);
	ColumnCount++;

}
void SessionByDate::SetMAP(CMapStringToPtr* cMapRep)
{
	this -> cMapRep = cMapRep;
}
void SessionByDate::OnMcnSelchangeMonthcalendarDate(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMSELCHANGE pSelChange = reinterpret_cast<LPNMSELCHANGE>(pNMHDR);
	// TODO: Add your control notification handler code here
	*pResult = 0;
}

void SessionByDate::OnLvnItemchangedListSession(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
	// TODO: Add your control notification handler code here
	*pResult = 0;
}
Соседние файлы в папке DBKino_Last_Release