// DlgInputUser.cpp : _xZkqqHx_iDeDiDjDiDhGiDiKiDiBiDjDiDgFiBfLiDfGiDiHiDjD_xHqqkZx_ _xZkqqHx_iDhEiDeAiDeDiDiL_xHqqkZx_
//

#include "stdafx.h"
#include "resource.h"		// For IDS_XXX.
#include "UtilErr.h"		// For FFMessageBox.
#include "UtilStr.h"		// For GetResString.
#include "UtilDlg.h"		// For SetUnitString.etc.
#include "UtilMisc.h"		// For FFGetGuidCheckCode.
#include "DlgInputUser.h"	// This header.

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

/////////////////////////////////////////////////////////////////////////////
// CFCDlgInputUser _xZkqqHx_iDfPiDeDiDeBiDiNiDeP_xHqqkZx_

CFCDlgInputUser::CFCDlgInputUser (CWnd* pParent /*=NULL*/)
			:	BASE_CLASS(CFCDlgInputUser::IDD, pParent),
				m_guidUserId(GUID_NULL)
{
	//{{AFX_DATA_INIT(CFCDlgInputUser)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_DATA_INIT

} // CFCDlgInputUser::CFCDlgInputUser.

void CFCDlgInputUser::DoDataExchange (CDataExchange* pDX)
{
	BASE_CLASS::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFCDlgInputUser)
		// _xZkqqHx_iDiBiDiC_xHqqkZx_ - ClassWizard _xZkqqHx_iCmNiClBiCmMiImKjChFiCmJiDhNiDgCiDhDiDjDiDePjHhAiCmMiDhNiDeOiDiNiCpAjCmHiJmBiCnMiClNiCmNiNoNiPjMiClFiCnMiClHiBeC_xHqqkZx_
	//}}AFX_DATA_MAP
} // CFCDlgInputUser::DoDataExchange.

BEGIN_MESSAGE_MAP(CFCDlgInputUser, BASE_CLASS)
	//{{AFX_MSG_MAP(CFCDlgInputUser)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFCDlgInputUser _xZkqqHx_iDiBiDgCiDfKiBfLiDfH_xHqqkZx_ _xZkqqHx_iDgOiDjDiDgIiDiJ_xHqqkZx_

BOOL CFCDlgInputUser::OnInitDialog ()
{
	// Baseclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnInitDialog();

	if (!m_wstrUserName.IsEmpty())
	//----- _xZkqqHx_iDiGiBfLiDfFjGlMiCkKjAnNjCoIiClDiCoKiCmEiCkCiCoJiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDiGiBfLiDfFjGlMiCpAjAnNjCoIiBeC_xHqqkZx_
		FFSetDlgItemText(this, IDC_PJI_EDT_USER_NAME, m_wstrUserName);
	}
	if (m_guidUserId != GUID_NULL)
	//----- _xZkqqHx_iDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iCkKjAnNjCoIiClDiCoKiCmEiCkCiCoJiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iCpAjAnNjCoIiBeC_xHqqkZx_
		WString wstrGuid0;
		WString wstrGuid1;
		WString wstrGuid2;
		WString wstrGuid3;
		WString wstrGuid4;
		WString wstrGuid5;
		FFGuidToString(wstrGuid1, wstrGuid2, wstrGuid3, wstrGuid4, wstrGuid5, m_guidUserId);
		wstrGuid0.Format(L"%04X", FFGetGuidCheckCode(m_guidUserId));
		FFSetDlgItemText(this, IDC_PJI_EDT_USER_ID0, wstrGuid0);
		FFSetDlgItemText(this, IDC_PJI_EDT_USER_ID1, wstrGuid1);
		FFSetDlgItemText(this, IDC_PJI_EDT_USER_ID2, wstrGuid2);
		FFSetDlgItemText(this, IDC_PJI_EDT_USER_ID3, wstrGuid3);
		FFSetDlgItemText(this, IDC_PJI_EDT_USER_ID4, wstrGuid4);
		FFSetDlgItemText(this, IDC_PJI_EDT_USER_ID5, wstrGuid5);

		// _xZkqqHx_iDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCpA_xHqqkZx_ReadOnly_xZkqqHx_iCmJiBeC_xHqqkZx_
		((CEdit*)GetDlgItem(IDC_PJI_EDT_USER_ID0))->SetReadOnly(TRUE);
		((CEdit*)GetDlgItem(IDC_PJI_EDT_USER_ID0))->SetReadOnly(TRUE);
		((CEdit*)GetDlgItem(IDC_PJI_EDT_USER_ID1))->SetReadOnly(TRUE);
		((CEdit*)GetDlgItem(IDC_PJI_EDT_USER_ID2))->SetReadOnly(TRUE);
		((CEdit*)GetDlgItem(IDC_PJI_EDT_USER_ID3))->SetReadOnly(TRUE);
		((CEdit*)GetDlgItem(IDC_PJI_EDT_USER_ID4))->SetReadOnly(TRUE);
		((CEdit*)GetDlgItem(IDC_PJI_EDT_USER_ID5))->SetReadOnly(TRUE);
	}

	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCmMjCfAiImKjFfMiOkGiCpAjAnNjCoIiClHiCoJiBeC_xHqqkZx_
	::SetUnitString(m_hWnd);
	// _xZkqqHx_jHjIiCkLjIhCjBmOiJjOjFlGiOjKjHpBiCmMjAnNjCoIiCpAiNhDiCkEiBeC_xHqqkZx_
	::RightByLeftHand(m_hWnd);
	// _xZkqqHx_iDfPiDeDiDeBiDiNiDePiCpAiDhNiDeFiDfIiImKjChFiCmJiInKjDkOiBeC_xHqqkZx_
	::FFJustifyWindow(m_hWnd);
	return TRUE;	// _xZkqqHx_iDfCiDjDiDgHiDiNiBfLiDiLiCmJiDhEiDeIiBfLiDeKiDfIiCpAjAnNjCoIiClFiCmIiCkCiCmGiCkLiBeBjGnPiCoIjCgMiCmN_xHqqkZx_ TRUE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
					// _xZkqqHx_jHoBiKeP_xHqqkZx_: OCX _xZkqqHx_iDhGiDiNiDhAiDgFiDeC_xHqqkZx_ _xZkqqHx_iDhJiBfLiDfHiCmMjGnPiCoIjCgMiCmN_xHqqkZx_ FALSE _xZkqqHx_iCmGiCmIiCoIiCnMiClH_xHqqkZx_
} // CFCDlgInputUser::OnInitDialog.

void CFCDlgInputUser::OnOK ()
{
	// _xZkqqHx_jAfGiLeLiDiGiBfLiDfFjGlMiBeC_xHqqkZx_
	WString wstrUserName;
	// _xZkqqHx_jAfGiLeLiDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iBeC_xHqqkZx_
	GUID guidUserId = GUID_NULL;

	// _xZkqqHx_iDiGiBfLiDfFjGlMiCpAiOoGjDlOiBeC_xHqqkZx_
	FFGetDlgItemText(this, IDC_PJI_EDT_USER_NAME, wstrUserName);
	wstrUserName.TrimLeft();
	wstrUserName.TrimRight();
	if (wstrUserName.empty())
	//----- _xZkqqHx_iDiGiBfLiDfFjGlMiCkKjDpMjHmNiClDiCoKiCmEiCkCiCmIiCkCiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iCkKjDpMjHmNiClDiCoKiCmEiCkCiCnMiClJiCpBiBeC_xHqqkZx_
		FFMessageBox(IDS_ERR_MSG_USER_NAME_EMPTY);
		return;
	}
	if (m_guidUserId == GUID_NULL)
	//----- _xZkqqHx_iDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iCkKjAnNjCoIiClDiCoKiCmEiCkCiCmIiCkCiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_iDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iCpAiOoGjDlOiBeC_xHqqkZx_
		WString wstrGuid0;
		WString wstrGuid1;
		WString wstrGuid2;
		WString wstrGuid3;
		WString wstrGuid4;
		WString wstrGuid5;
		FFGetDlgItemText(this, IDC_PJI_EDT_USER_ID0, wstrGuid0);
		FFGetDlgItemText(this, IDC_PJI_EDT_USER_ID1, wstrGuid1);
		FFGetDlgItemText(this, IDC_PJI_EDT_USER_ID2, wstrGuid2);
		FFGetDlgItemText(this, IDC_PJI_EDT_USER_ID3, wstrGuid3);
		FFGetDlgItemText(this, IDC_PJI_EDT_USER_ID4, wstrGuid4);
		FFGetDlgItemText(this, IDC_PJI_EDT_USER_ID5, wstrGuid5);

		if (!FFStringToGuid(guidUserId, wstrGuid1, wstrGuid2,
							wstrGuid3, wstrGuid4, wstrGuid5))
		//---- GUID_xZkqqHx_iCmJjFmPiKlHiCmFiCkLiCmIiCkCiPoKiNiH_xHqqkZx_ -----
		{
			// _xZkqqHx_iDiGiBfLiDfFiBfL_xHqqkZx_ID_xZkqqHx_iCkKjAlDiClFiCkNiCkAiCoIiCnMiClJiCpBiBeC_xHqqkZx_
			FFMessageBox(IDS_ERR_MSG_USER_ID_ILLEGAL);
			return;
		}
		// _xZkqqHx_jFlGiOjKjHpBiCmMiDgAiDeGiDgCiDeOiDfCiBfLiDgIiCpAiOoGjDlOiBeC_xHqqkZx_
		const long lCheckCode = wcstoul(wstrGuid0, NULL, 16);
		if (lCheckCode != long(FFGetGuidCheckCode(guidUserId)))
		//----- _xZkqqHx_iDgAiDeGiDgCiDeOiDfCiBfLiDgIiCmJiMoLiCoIiCkKiCkAiCoJiPoKiNiH_xHqqkZx_ -----
		{
			// _xZkqqHx_iDiGiBfLiDfFiBfL_xHqqkZx_ID_xZkqqHx_iCkKjAlDiClFiCkNiCkAiCoIiCnMiClJiCpBiBeC_xHqqkZx_
			FFMessageBox(IDS_ERR_MSG_USER_ID_ILLEGAL);
			return;
		}

		if (m_stUsedUserId.find(guidUserId) != m_stUsedUserId.end())
		//----- _xZkqqHx_iKpJjBlGiDiGiBfLiDfFiCmJjDkPiClG_xHqqkZx_ID_xZkqqHx_iCkKjDgPjIfOiClDiCoKiCmEiCkCiCoJiPoKiNiH_xHqqkZx_ -----
		{
			// _xZkqqHx_jDkPiClGiDiGiBfLiDfFiBfL_xHqqkZx_ID_xZkqqHx_iCmNiKpJiCmJiDhGiDiNiDfHiDeGiDeOiDgHiCmJjDgPjIfOiClDiCoKiCmEiCkCiCnMiClHiBeC_xHqqkZx_"
			FFMessageBox(IDS_ERR_MSG_SAME_USER_ID_EXIST);
			return;
		}
	}
	if (m_stUsedUserName.find(wstrUserName) != m_stUsedUserName.end())
	//----- _xZkqqHx_iKpJjBlGiDiGiBfLiDfFiCmJjDkPiClGjGlMjBePiCkKjDgPjIfOiClDiCoKiCmEiCkCiCoJiPoKiNiH_xHqqkZx_ -----
	{
		// _xZkqqHx_jDkPiClGiDiGiBfLiDfFiBfLjGlMiCkKjBlGiNnNiClFiCnMiClHiBeCjDgPjIfOiClFiCnMiClHiCkJiBeI_xHqqkZx_
		if (FFMessageBox(IDS_MSG_SAME_USER_NAME_EXIST_IS_REGISTER, 0, MB_YESNO) != IDYES)
			return;
	}
	// _xZkqqHx_jAfGiLeLiDiGiBfLiDfFjGlMiCpAjAnNjCoIiBeC_xHqqkZx_
	m_wstrUserName = wstrUserName;
	// _xZkqqHx_jAfGiLeLiDiGiBfLiDfF_xHqqkZx_ID_xZkqqHx_iCpAjAnNjCoIiBeC_xHqqkZx_
	if (guidUserId != GUID_NULL)
		m_guidUserId = guidUserId;

	// Baseclass_xZkqqHx_iKnGjAjEiOmAiNhDiBeC_xHqqkZx_
	BASE_CLASS::OnOK();
} // CFCDlgInputUser::OnOK.
