123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- #include "stdafx.h"
- #include "LYFZSendMsg.h"
- #include "ReCharge.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- ReCharge::ReCharge(CWnd* pParent )
- : CDialog(ReCharge::IDD, pParent)
- {
-
- m_account = _T("");
- m_name = _T("");
- m_money = _T("");
- m_count = _T("");
- m_price = _T("");
-
- }
- void ReCharge::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
-
- DDX_Control(pDX, IDC_EDITcount, m_editnum2);
- DDX_Control(pDX, IDC_EDITmoney, m_editnum1);
- DDX_Text(pDX, IDC_EDITaccount, m_account);
- DDX_Text(pDX, IDC_EDITname, m_name);
- DDX_Text(pDX, IDC_EDITmoney, m_money);
- DDX_Text(pDX, IDC_EDITcount, m_count);
- DDX_Text(pDX, IDC_EDITprice, m_price);
-
- }
- BEGIN_MESSAGE_MAP(ReCharge, CDialog)
-
- ON_EN_CHANGE(IDC_EDITmoney, OnChangeEDITmoney)
- ON_EN_CHANGE(IDC_EDITcount, OnChangeEDITcount)
-
- END_MESSAGE_MAP()
- BOOL ReCharge::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
-
- return TRUE;
-
- }
- void ReCharge::OnChangeEDITmoney()
- {
-
-
-
-
- UpdateData();
- if(atof(m_count))
- {
- m_price.Format ("%0.4f", atof(m_money)/atof(m_count));
- }
- else
- m_price="0";
- UpdateData(false);
-
-
- }
- void ReCharge::OnChangeEDITcount()
- {
-
-
-
-
- OnChangeEDITmoney();
-
-
- }
- void ReCalAccount(CString account)
- {
- CString sql;
- if(1)
- {
-
- MyLock lock("xiaoaccessdbmsg");
- CRecordset myset(&g_db);
- CString count1,count2,count3;
-
- #ifdef SQLSERVER_VERSION
- sql="select sum(cast([count] as float)) as cot from recharge where account='"+account+"'";
- #else
- sql="select sum([count]) as cot from recharge where account='"+account+"'";
- #endif
- myset.Open (CRecordset::forwardOnly, sql);
- if(!myset.IsEOF())
- myset.GetFieldValue ("cot", count1);
- myset.Close();
-
-
- #ifdef SQLSERVER_VERSION
- sql="select sum(cast([msgcount] as float)) as cot from sendreg where account='"+account+"'";
- #else
- sql="select sum([msgcount]) as cot from sendreg where account='"+account+"'";
- #endif
- myset.Open (CRecordset::forwardOnly, sql);
- if(!myset.IsEOF())
- myset.GetFieldValue ("cot", count2);
- myset.Close();
-
- #ifdef SQLSERVER_VERSION
- sql="select sum(cast([msgcount2] as float)) as cot from sendreg where account='"+account+"'";
- #else
- sql="select sum([msgcount2]) as cot from sendreg where account='"+account+"'";
- #endif
- myset.Open (CRecordset::forwardOnly, sql);
- if(!myset.IsEOF())
- myset.GetFieldValue ("cot", count3);
- myset.Close();
- sql.Format ("update clientinfo set balance='%d' where account='%s'", atoi(count1)-atoi(count2), account);
- }
- MyExecuteSQL(&g_db, sql);
- }
- void ReCharge::OnOK()
- {
-
- UpdateData();
- m_count.TrimLeft ();
- m_count.TrimRight ();
- m_money.TrimLeft ();
- m_money.TrimRight ();
- if(atoi(m_count)==0)
- {
- AfxMessageBox("短信条数不能为0!", MB_ICONINFORMATION);
- return;
- }
- CString timestamp=CTime::GetCurrentTime ().Format ("%Y-%m-%d");
- CString sql;
- sql="insert into recharge([account],[money],[count],[timestamp]) values('"+m_account+"','"+m_money+"','"+m_count+"','"+timestamp+"')";
- MyExecuteSQL(&g_db, sql);
- ReCalAccount(m_account);
- AfxMessageBox("充值成功!", MB_ICONINFORMATION);
- sql="delete from nullbalance where [account]='"+m_account+"'";
- MyExecuteSQL(&g_db, sql);
- CDialog::OnOK();
- }
|