// UseMemberCard.cpp : implementation file
//

#include "stdafx.h"
#include "ylgl.h"
#include "UseMemberCard.h"

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

/////////////////////////////////////////////////////////////////////////////
// UseMemberCard dialog
UseMemberCard::UseMemberCard(CWnd* pParent /*=NULL*/)
	: CDialog(UseMemberCard::IDD, pParent)
{
	//{{AFX_DATA_INIT(UseMemberCard)
	m_money1 = _T("");
	m_money2 = _T("");
	m_point1 = _T("");
	m_point2 = _T("");
	//}}AFX_DATA_INIT
}


void UseMemberCard::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(UseMemberCard)
	DDX_Control(pDX, IDC_EDIT2, m_editctrl2);
	DDX_Control(pDX, IDC_EDIT1, m_editctrl1);
	DDX_Text(pDX, IDC_EDIT1, m_money1);
	DDX_Text(pDX, IDC_EDIT3, m_money2);
	DDX_Text(pDX, IDC_EDIT2, m_point1);
	DDX_Text(pDX, IDC_EDIT4, m_point2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(UseMemberCard, CDialog)
	//{{AFX_MSG_MAP(UseMemberCard)
	ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
	ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit2)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// UseMemberCard message handlers

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

void UseMemberCard::OnChangeEdit1() 
{
	// 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();
	float rate=atof(g_cominfoarray.ElementAt (0).ElementAt (38))/100.0;
	m_point1.Format ("%0.2f", atof(m_money1)/rate);
	UpdateData(false);
	// TODO: Add your control notification handler code here
	
}

void UseMemberCard::OnChangeEdit2() 
{
	// 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();
	float rate=atof(g_cominfoarray.ElementAt (0).ElementAt (38))/100.0;
	m_money1.Format ("%0.2f", atof(m_point1)*rate);
	UpdateData(false);
	// TODO: Add your control notification handler code here
	
}

void UseMemberCard::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData();
	if(atof(m_money1)<=0)
	{
		AfxMessageBox("�������!");
		return;
	}
	if(atof(m_money1)>atof(m_money2))
	{
		AfxMessageBox("���ֲ���!");
		return;
	}
	CString sql;
 
	CString date=g_date;
    sql="insert into [memberreg2]([memberno],[dindanid],[money],[point],[date])values('"+m_memberno+"','"+m_id+"','"+m_money1+"','"+m_point1+"','"+date+"')";
sql+="***refresh balance memberreg2";
sql+=m_memberno;
sql+=";";
sql+=m_id;
g_sendhead.bsql=1; 
g_pMainWnd->ProcessChatMessageRequest2(sql);
if(g_bSendOK==0)
{
	CDialog::OnOK();
return;
}
AfxMessageBox("����ɹ�!", MB_ICONINFORMATION);

	CDialog::OnOK();
}