// PhoneMsgSet.cpp : implementation file
//

#include "stdafx.h"
#include "ylgl.h"
#include "PhoneMsgSet.h"

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

/////////////////////////////////////////////////////////////////////////////
// PhoneMsgSet dialog
PhoneMsgSet::PhoneMsgSet(CWnd* pParent /*=NULL*/)
	: CDialog(PhoneMsgSet::IDD, pParent)
{
	//{{AFX_DATA_INIT(PhoneMsgSet)
	m_msgcheck8 = FALSE;
	m_msgcheck9 = FALSE;
	m_msgcheck10 = FALSE;
	m_msgcontent8 = _T("");
	m_msgcontent9 = _T("");
	m_msgcontent10 = _T("");
	//}}AFX_DATA_INIT
}


void PhoneMsgSet::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(PhoneMsgSet)
	DDX_Check(pDX, IDC_CHECK8, m_msgcheck8);
	DDX_Check(pDX, IDC_CHECK9, m_msgcheck9);
	DDX_Check(pDX, IDC_CHECK10, m_msgcheck10);
	DDX_Text(pDX, IDC_EDITcontent8, m_msgcontent8);
	DDV_MaxChars(pDX, m_msgcontent8, 1000);
	DDX_Text(pDX, IDC_EDITcontent9, m_msgcontent9);
	DDV_MaxChars(pDX, m_msgcontent9, 1000);
	DDX_Text(pDX, IDC_EDITcontent10, m_msgcontent10);
	DDV_MaxChars(pDX, m_msgcontent10, 1000);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(PhoneMsgSet, CDialog)
	//{{AFX_MSG_MAP(PhoneMsgSet)
	ON_EN_CHANGE(IDC_EDITcontent8, OnChangeEDITcontent8)
	ON_EN_CHANGE(IDC_EDITcontent9, OnChangeEDITcontent9)
	ON_EN_CHANGE(IDC_EDITcontent10, OnChangeEDITcontent10)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// PhoneMsgSet message handlers

BOOL PhoneMsgSet::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
 
	g_sendhead.bsql=0;
	g_sendhead.code[0]=24;
	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_cominfoarray);
 
	m_msgcheck8 = atoi(g_cominfoarray.ElementAt(0).ElementAt(89));
	m_msgcheck9 = atoi(g_cominfoarray.ElementAt(0).ElementAt(90));
	m_msgcheck10 = atoi(g_cominfoarray.ElementAt(0).ElementAt(91));
	m_msgcontent8 = g_cominfoarray.ElementAt(0).ElementAt(92);
	m_msgcontent9 = g_cominfoarray.ElementAt(0).ElementAt(93);
	m_msgcontent10 = g_cominfoarray.ElementAt(0).ElementAt(94);
	UpdateData(false);
	CenterWindow();
 
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void PhoneMsgSet::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	m_msgcontent8.TrimLeft ();
	m_msgcontent8.TrimRight ();
 	m_msgcontent9.TrimLeft ();
	m_msgcontent9.TrimRight ();
 	m_msgcontent10.TrimLeft ();
	m_msgcontent10.TrimRight ();
	if(CheckBadWords(m_msgcontent8)==0 || CheckBadWords2(m_msgcontent8)==0)
	{
		AfxMessageBox("��Ϣ�����̽�ֹ�ķǷ��ַ�:("+g_temp+")ϣ�����½�!");
		return;
	}
	if(CheckBadWords(m_msgcontent9)==0 || CheckBadWords2(m_msgcontent9)==0)
	{
		AfxMessageBox("��Ϣ�����̽�ֹ�ķǷ��ַ�:("+g_temp+")ϣ�����½�!");
		return;
	}
	if(CheckBadWords(m_msgcontent10)==0 || CheckBadWords2(m_msgcontent10)==0)
	{
		AfxMessageBox("��Ϣ�����̽�ֹ�ķǷ��ַ�:("+g_temp+")ϣ�����½�!");
		return;
	}
 
	CString sql;
 	sql.Format("update version set [msgcontent8]='"+m_msgcontent8+"',[msgcontent9]='"+m_msgcontent9+"',[msgcontent10]='"+m_msgcontent10+"',[msgcheck8]='%d',[msgcheck9]='%d',[msgcheck10]='%d'",m_msgcheck8, m_msgcheck9, m_msgcheck10 );
 
 

	g_sendhead.bsql=1;
	g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
	AfxMessageBox("����ɹ�!", MB_ICONINFORMATION);

	g_sendhead.bsql=0;
	g_sendhead.code[0]=24;
	g_sendhead.tabcount=1;
	int g_nYearposTemp=g_nYearpos;
	g_nYearpos=-1;
	g_pMainWnd->ProcessChatMessageRequest2(1);
	g_nYearpos=g_nYearposTemp;
	if(g_bSendOK)
	DataToArray(&g_cominfoarray);
	CDialog::OnOK ();
}

void PhoneMsgSet::OnChangeEDITcontent8() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	UpdateData();
	m_msgcontent8.Replace ("'", "��");
	m_msgcontent8.Replace ("(", "��");
	m_msgcontent8.Replace (")", "��");
 	UpdateData(false);
	CString str;
	int count=0;
	int leng=GetLengthEx(m_msgcontent8);
 

		count+=(leng/MSG_LENGTH);
		if(leng%MSG_LENGTH)
			count+=1;

	str.Format ("%d��/��,��%d��,��%d��)", MSG_LENGTH, leng,count);
	GetDlgItem(IDC_STATIC8)->SetWindowText(str);	
	// TODO: Add your control notification handler code here
	
}

void PhoneMsgSet::OnChangeEDITcontent9() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	UpdateData();
	m_msgcontent9.Replace ("'", "��");
	m_msgcontent9.Replace ("(", "��");
	m_msgcontent9.Replace (")", "��");
 	UpdateData(false);
	CString str;
	int count=0;
	int leng=GetLengthEx(m_msgcontent9);
 

		count+=(leng/MSG_LENGTH);
		if(leng%MSG_LENGTH)
			count+=1;

	str.Format ("%d��/��,��%d��,��%d��)", MSG_LENGTH,leng,count);
	GetDlgItem(IDC_STATIC9)->SetWindowText(str);	
	// TODO: Add your control notification handler code here
	
}

void PhoneMsgSet::OnChangeEDITcontent10() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	UpdateData();
	m_msgcontent10.Replace ("'", "��");
	m_msgcontent10.Replace ("(", "��");
	m_msgcontent10.Replace (")", "��");
 	UpdateData(false);
	CString str;
	int count=0;
	int leng=GetLengthEx(m_msgcontent10);
 

		count+=(leng/MSG_LENGTH);
		if(leng%MSG_LENGTH)
			count+=1;

	str.Format ("%d��/��,��%d��,��%d��)", MSG_LENGTH,leng,count);
	GetDlgItem(IDC_STATIC10)->SetWindowText(str);	
	// TODO: Add your control notification handler code here
	
}