// SetStyle.cpp : implementation file
//

#include "stdafx.h"
#include "ylgl.h"
#include "SetStyle.h"

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

/////////////////////////////////////////////////////////////////////////////
// SetStyle dialog


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


void SetStyle::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(SetStyle)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(SetStyle, CDialog)
	//{{AFX_MSG_MAP(SetStyle)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// SetStyle message handlers

void SetStyle::OnOK() 
{
	// TODO: Add extra validation here
	m_style=GetRights();
	CDialog::OnOK();
}

BOOL SetStyle::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CStringArray strarray;

	g_sendhead.bsql=0;
	g_sendhead.code[0]=77;
	g_sendhead.tabcount=1;
	int g_nYearposTemp=g_nYearpos;
	g_nYearpos=-1;
	g_pMainWnd->ProcessChatMessageRequest2(1);
	g_nYearpos=g_nYearposTemp;
	if(g_bSendOK==0)
	{
		CDialog::OnCancel();
		return 1;
	}
	DataToArray(&g_List1array);
	if(g_List1array.GetSize ()==12)
	{
		for(int i=0; i<12; i++)
			strarray.Add (g_List1array.ElementAt (i).ElementAt (0));
	}
	else
	{
	strarray.Add("���ŵ���");
	strarray.Add("������");
	strarray.Add("��������");
	strarray.Add("��ͳ��");
	strarray.Add("�³�����");
	strarray.Add("��������");
	strarray.Add("������");
	strarray.Add("��������");
	strarray.Add("������ܰ");
	strarray.Add("�����ͻ�");
	strarray.Add("�������");
	strarray.Add("�崿�ɰ�");
	}
	for(int i=0; i<12; i++)
	{
		SetDlgItemText(IDC_CHECK1+i, strarray.ElementAt (i));
	}
	SetRights(m_style);
	CenterWindow();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

CString SetStyle::GetRights()
{
	CString ret,temp;
	for(int i=0; i<12; i++)
	{
		temp.Format ("%d",((CButton*)GetDlgItem(IDC_CHECK1+i))->GetCheck());
		ret+=temp;
	}
	return ret;
}

void SetStyle::SetRights(CString rights)
{
	for(int i=0; i<rights.GetLength (); i++)
	{
		if(i>=12)break;
		((CButton*)GetDlgItem(IDC_CHECK1+i))->SetCheck(rights.GetAt (i)=='1');
	}
}