// ModalaDlg.cpp : implementation file
//

#include "stdafx.h"
#include "wiz5.h"
#include "ModalaDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CModalaDlg dialog


CModalaDlg::CModalaDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CModalaDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CModalaDlg)
	m_strNume = _T("");
	m_strPrenume = _T("");
	m_nVirsta = 0;
	//}}AFX_DATA_INIT
}


void CModalaDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CModalaDlg)
	DDX_Control(pDX, IDC_SEX, m_cbSex);
	DDX_Text(pDX, IDC_NUME, m_strNume);
	DDX_Text(pDX, IDC_PRENUME, m_strPrenume);
	DDV_ValidPren(pDX, m_strPrenume);
	DDX_Text(pDX, IDC_VIRSTA, m_nVirsta);
	DDV_MinMaxInt(pDX, m_nVirsta, 0, 18);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CModalaDlg, CDialog)
	//{{AFX_MSG_MAP(CModalaDlg)
	ON_CBN_SELCHANGE(IDC_SEX, OnSelchangeSex)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CModalaDlg message handlers

BOOL CModalaDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	PopulezCombo();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CModalaDlg::PopulezCombo()
{
	m_cbSex.AddString("F");
	m_cbSex.AddString("M");
	int nIndex=m_cbSex.SelectString(-1,"F");
	m_cbSex.GetLBText(nIndex, m_strSex);
}

void CModalaDlg::OnSelchangeSex() 
{
	// TODO: Add your control notification handler code here
	int nIndex=m_cbSex.GetCurSel();
	if (nIndex != CB_ERR)
	m_cbSex.GetLBText(nIndex, m_strSex);
	
}


void CModalaDlg::DDV_ValidPren(CDataExchange *pDX, CString &nPren)
{
   if (pDX->m_bSaveAndValidate)
   {
	   for (int i=0;i<nPren.GetLength();i++)
	   {
	      if (!isalpha(nPren[i]))
		  {
		     MessageBox(" Nu sunt acceptate caractere nealfabetice",
               "EOARE",MB_ICONSTOP);
			  pDX->Fail();
			  break;
		  }
       }
	   if (!isupper(nPren[0]))
	   {
		   TCHAR x=nPren.GetAt(0);
		   x-=32;
		   nPren.SetAt(0,x);
	   }
   }
}

