// Palace Ice CreamDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Palace Ice Cream.h"
#include "Palace Ice CreamDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPalaceIceCreamDlg dialog
CPalaceIceCreamDlg::CPalaceIceCreamDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPalaceIceCreamDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPalaceIceCreamDlg)
m_FirstName = _T("");
m_LastName = _T("");
m_Address = _T("");
m_City = _T("");
m_State = _T("");
m_ZIPCode = 0;
m_HourlySalary = 0.0;
m_EmploymentStatus = 0;
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPalaceIceCreamDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPalaceIceCreamDlg)
DDX_Text(pDX, IDC_FIRST_NAME, m_FirstName);
DDX_Text(pDX, IDC_LAST_NAME, m_LastName);
DDX_Text(pDX, IDC_ADDRESS, m_Address);
DDX_Text(pDX, IDC_CITY, m_City);
DDX_Text(pDX, IDC_STATE, m_State);
DDX_Text(pDX, IDC_ZIP_CODE, m_ZIPCode);
DDX_Text(pDX, IDC_HOURLY_SALARY, m_HourlySalary);
DDX_Radio(pDX, IDC_PART_TIME, m_EmploymentStatus);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPalaceIceCreamDlg, CDialog)
//{{AFX_MSG_MAP(CPalaceIceCreamDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_SAVE_BTN, OnSaveBtn)
ON_BN_CLICKED(IDC_OPEN_BTN, OnOpenBtn)
ON_BN_CLICKED(IDC_RESET_BTN, OnResetBtn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPalaceIceCreamDlg message handlers
. . .
void CPalaceIceCreamDlg::OnSaveBtn()
{
// TODO: Add your control notification handler code here
this->UpdateData();
CFile flEmployees;
char strFilter[] = { "Employees Records (*.mpl)|*.mpl|Palace Ice Cream Files (*.pis)|*.pis|All Files (*.*)|*.*||" };
CFileDialog FileDlg(FALSE, ".mpl", NULL, 0, strFilter);
if( FileDlg.DoModal() == IDOK )
{
if( flEmployees.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite) == FALSE )
return;
CArchive ar(&flEmployees, CArchive::store);
ar << m_FirstName << m_LastName << m_Address << m_City << m_State << m_ZIPCode << m_HourlySalary << m_EmploymentStatus;
ar.Close();
}
else
return;
flEmployees.Close();
}
void CPalaceIceCreamDlg::OnOpenBtn()
{
// TODO: Add your control notification handler code here
CFile flEmployees;
char strFilter[] = { "Employees Records (*.mpl)|*.mpl|Palace Ice Cream Files (*.pis)|*.pis|All Files (*.*)|*.*||" };
CFileDialog FileDlg(TRUE, ".mpl", NULL, 0, strFilter);
if( FileDlg.DoModal() == IDOK )
{
if( flEmployees.Open(FileDlg.GetFileName(), CFile::modeRead) == FALSE )
return;
CArchive ar(&flEmployees, CArchive::load);
ar >> m_FirstName >> m_LastName >> m_Address >> m_City >> m_State >> m_ZIPCode >> m_HourlySalary >> m_EmploymentStatus;
ar.Close();
}
else
return;
flEmployees.Close();
UpdateData(FALSE);
}
void CPalaceIceCreamDlg::OnResetBtn()
{
// TODO: Add your control notification handler code here
this->m_FirstName.Format("");
this->m_LastName.Format("");
this->m_Address.Format("");
this->m_City.Format("");
this->m_State.Format("");
this->m_ZIPCode = 0;
this->m_HourlySalary = 10.15;
this->m_EmploymentStatus = 1;
this->UpdateData(FALSE);
}
|