📄 exes_balancedlg.cpp
字号:
// Exes_BalanceDlg.cpp : implementation file
//
#include "stdafx.h"
#include "双星台球厅计时收费系统.h"
#include "Exes_BalanceDlg.h"
#include "双星台球厅计时收费系统View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExes_BalanceDlg dialog
CExes_BalanceDlg::CExes_BalanceDlg(CWnd* pParent /*=NULL*/)
: CDialog(CExes_BalanceDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CExes_BalanceDlg)
//}}AFX_DATA_INIT
}
void CExes_BalanceDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExes_BalanceDlg)
DDX_Control(pDX, IDC_CHECK4, m_YouHuiMark_2);
DDX_Control(pDX, IDC_CHECK3, m_YouHuiMark_1);
DDX_Control(pDX, IDD_FEIYONGJIESUAN, m_JieSuan_1);
DDX_Control(pDX, IDC_EDIT4, m_FeiYong_2);
DDX_Control(pDX, IDC_EDIT3, m_FeiYong_1);
DDX_Control(pDX, IDC_EDIT2, m_YouHuiJingE);
DDX_Control(pDX, IDC_EDIT1, m_YouHuiTime);
DDX_Control(pDX, IDC_CHECK2, m_JingEYouHui);
DDX_Control(pDX, IDC_CHECK1, m_TimeYouHui);
DDX_Control(pDX, IDC_COMBO1, m_TaiQiuNumber);
DDX_Control(pDX, IDC_EDIT12, m_ShiYongRen);
DDX_Control(pDX, IDC_EDIT11, m_FeiYongJingE);
DDX_Control(pDX, IDC_EDIT10, m_ShiYongShiChong);
DDX_Control(pDX, IDC_EDIT9, m_JieShuTime);
DDX_Control(pDX, IDC_EDIT8, m_KaiShiTime);
DDX_Control(pDX, IDC_EDIT7, m_RiQi);
DDX_Control(pDX, IDC_EDIT6, m_JiaGe);
DDX_Control(pDX, IDC_EDIT5, m_WeiZhi);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CExes_BalanceDlg, CDialog)
//{{AFX_MSG_MAP(CExes_BalanceDlg)
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo_Number)
ON_BN_CLICKED(IDC_CHECK1, On_Check1)
ON_BN_CLICKED(IDC_CHECK2, On_Check2)
ON_BN_CLICKED(IDD_FEIYONGJIESUAN, On_FeiYongJieSuan)
ON_EN_UPDATE(IDC_EDIT2, OnUpdateEdit_2)
ON_BN_CLICKED(IDC_CHECK3, On_Check3)
ON_BN_CLICKED(IDC_CHECK4, On_Check4)
ON_EN_UPDATE(IDC_EDIT1, OnUpdateEdit_1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExes_BalanceDlg message handlers
BOOL CExes_BalanceDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
m_FeiYong_1.SetReadOnly(TRUE);
m_YouHuiJingE.SetReadOnly(TRUE);
m_YouHuiTime.SetReadOnly(TRUE);
m_JingEYouHui.EnableWindow(FALSE);
m_TimeYouHui.EnableWindow(FALSE);
m_YouHuiMark_2.EnableWindow(FALSE);
m_YouHuiMark_1.EnableWindow(FALSE);
m_JieSuan_1.EnableWindow(FALSE);
m_YouHuiJingE.SetWindowText("0");
m_YouHuiTime.SetWindowText("0");
CString str_1,str_2;
_variant_t var;
try
{
pFrame->f_MyApp->m_pRecordset->Open("SELECT *FROM TaiQiuZheUserInformationRecond",
pFrame->f_MyApp->m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
if(!pFrame->f_MyApp->m_pRecordset->BOF)
{
pFrame->f_MyApp->m_pRecordset->MoveFirst();
}
while(!pFrame->f_MyApp->m_pRecordset->adoEOF)
{
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserMark");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
if(str_1=="正在使用")
{
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserNumber");
if(var.vt!=VT_NULL)
{
str_2=(LPCSTR)_bstr_t(var);
m_TaiQiuNumber.AddString("第 "+str_2+" 台球桌");
}
}
}
pFrame->f_MyApp->m_pRecordset->MoveNext();
}
pFrame->f_MyApp->m_pRecordset->Close();
}
catch(_com_error &e)
{
AfxMessageBox(e.ErrorMessage());
return FALSE;
}
if(m_YouHuiMark_2.GetCheck()==1)
{
m_JingEYouHui.EnableWindow(FALSE);
m_TimeYouHui.EnableWindow(FALSE);
}
// char chrTemp[255] = {'\0'};
// m_UserInformation.GetItemText(i-1,3,chrTemp,sizeof(char[255]));
// CString str_20=chrTemp;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CExes_BalanceDlg::OnSelchangeCombo_Number()
{
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
m_JieSuan_1.EnableWindow(TRUE);
m_YouHuiMark_1.SetCheck(0);
m_YouHuiMark_2.SetCheck(1);
m_YouHuiJingE.SetWindowText("0");
m_YouHuiTime.SetWindowText("0");
m_FeiYong_1.SetWindowText("");
m_FeiYong_2.SetWindowText("");
m_JingEYouHui.EnableWindow(FALSE);
m_TimeYouHui.EnableWindow(FALSE);
m_JingEYouHui.SetCheck(0);
m_TimeYouHui.SetCheck(0);
m_YouHuiJingE.SetReadOnly(TRUE);
m_YouHuiTime.SetReadOnly(TRUE);
m_YouHuiMark_2.EnableWindow(TRUE);
m_YouHuiMark_1.EnableWindow(TRUE);
CString str_3;
m_TaiQiuNumber.GetWindowText(str_3);
m_UINTMarkNumber=m_TaiQiuNumber.GetCurSel();
str_3.Replace("第 ","");
str_3.Replace(" 台球桌","");
int m_MarkCount=atoi(str_3);
_variant_t RecordsAffected;
pFrame->f_MyApp->m_pRecordset=pFrame->f_MyApp->m_pConnection->Execute("SELECT COUNT(*) FROM TaiQiuZheUserInformationRecond",
&RecordsAffected,adCmdText);
_variant_t vIndex=(long)0;
_variant_t vCount=pFrame->f_MyApp->m_pRecordset->GetCollect(vIndex);
pFrame->f_MyApp->m_pRecordset->Close();
CString str_10=(LPCSTR)_bstr_t(vCount);
int m_RecordCount=atoi(str_10);
for(int i=1;i<=m_RecordCount;i++)
{
char chrTemp[255] = {'\0'};
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,0,chrTemp,sizeof(char[255]));
CString str_20=chrTemp;
if(str_20==str_3)
{
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,0,chrTemp,sizeof(char[255]));
CString str_1=chrTemp;
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,1,chrTemp,sizeof(char[255]));
str_1=chrTemp;
m_WeiZhi.SetWindowText(str_1);
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,2,chrTemp,sizeof(char[255]));
str_1=chrTemp;
m_JiaGe.SetWindowText(str_1);
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,4,chrTemp,sizeof(char[255]));
str_1=chrTemp;
m_ShiYongRen.SetWindowText(str_1);
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,5,chrTemp,sizeof(char[255]));
str_1=chrTemp;
m_RiQi.SetWindowText(str_1);
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,6,chrTemp,sizeof(char[255]));
str_1=chrTemp;
m_KaiShiTime.SetWindowText(str_1);
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,7,chrTemp,sizeof(char[255]));
str_1=chrTemp;
m_ShiYongShiChong.SetWindowText(str_1);
pFrame->f_MyView->m_UserInformation.GetItemText(i-1,8,chrTemp,sizeof(char[255]));
str_1=chrTemp;
m_FeiYongJingE.SetWindowText(str_1);
CTime m_Time_1;
CString str[4];
int m_1=m_Time_1.GetCurrentTime().GetHour();
int m_2=m_Time_1.GetCurrentTime().GetMinute();
int m_3=m_Time_1.GetCurrentTime().GetSecond();
str[0].Format("%d",m_1);
str[1].Format("%d",m_2);
str[2].Format("%d",m_3);
if(str[0].GetLength()==1)
{
str[0]="0"+str[0];
}
if(str[1].GetLength()==1)
{
str[1]="0"+str[1];
}
if(str[2].GetLength()==1)
{
str[2]="0"+str[2];
}
str[3]=str[0]+":"+str[1]+":"+str[2];
m_JieShuTime.SetWindowText(str[3]);
}
}
CString str_20;
m_FeiYongJingE.GetWindowText(str_20);
str_20.Replace(" 元","");
m_FeiYong_1.SetWindowText(str_20);
m_FeiYong_2.SetWindowText(str_20);
}
void CExes_BalanceDlg::On_Check1()
{
m_JingEYouHui.SetCheck(0);
m_TimeYouHui.SetCheck(1);
m_YouHuiJingE.SetReadOnly(TRUE);
m_YouHuiTime.SetReadOnly(FALSE);
m_YouHuiJingE.SetWindowText("0");
m_YouHuiTime.SetWindowText("0");
}
void CExes_BalanceDlg::On_Check2()
{
m_JingEYouHui.SetCheck(1);
m_TimeYouHui.SetCheck(0);
m_YouHuiJingE.SetReadOnly(FALSE);
m_YouHuiTime.SetReadOnly(TRUE);
m_YouHuiJingE.SetWindowText("0");
m_YouHuiTime.SetWindowText("0");
}
void CExes_BalanceDlg::On_FeiYongJieSuan()
{
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
CString str_4,str_3;
m_TaiQiuNumber.GetWindowText(str_3);
str_4=str_3;
str_3.Replace("第 ","");
str_3.Replace(" 台球桌","");
CString str_10,str_11,str_12;
CString str_1,str_2;
_variant_t var;
try
{
pFrame->f_MyApp->m_pRecordset->Open("SELECT *FROM TaiQiuZheUserInformationRecond",
pFrame->f_MyApp->m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
if(!pFrame->f_MyApp->m_pRecordset->BOF)
{
pFrame->f_MyApp->m_pRecordset->MoveFirst();
}
while(!pFrame->f_MyApp->m_pRecordset->adoEOF)
{
var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserNumber");
if(var.vt!=VT_NULL)
{
str_1=(LPCSTR)_bstr_t(var);
if(str_1==str_3)
{
pFrame->f_MyApp->m_pRecordset->PutCollect("UserMark",_variant_t("没有使用"));
pFrame->f_MyApp->m_pRecordset->PutCollect("UserData",_variant_t(""));
pFrame->f_MyApp->m_pRecordset->PutCollect("BeginTime",_variant_t(""));
pFrame->f_MyApp->m_pRecordset->PutCollect("UserPeople",_variant_t(""));
pFrame->f_MyApp->m_pRecordset->PutCollect("UserFeiYong",_variant_t(""));
pFrame->f_MyApp->m_pRecordset->PutCollect("UserTimeLength",_variant_t(""));
pFrame->f_MyApp->m_pRecordset->Update();
pFrame->f_MyView->m_MarkCount_1=FALSE;
break;
}
}
pFrame->f_MyApp->m_pRecordset->MoveNext();
}
pFrame->f_MyApp->m_pRecordset->Close();
}
catch(_com_error &e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
try
{
pFrame->f_MyApp->m_pRecordset->Open("SELECT *FROM UserInformationRecondList",
pFrame->f_MyApp->m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
pFrame->f_MyApp->m_pRecordset->AddNew();
m_TaiQiuNumber.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserNumer",_variant_t(str_1));
m_WeiZhi.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserWeiZhi",_variant_t(str_1));
m_JiaGe.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserJiaGe",_variant_t(str_1));
m_RiQi.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserData",_variant_t(str_1));
m_KaiShiTime.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserTime_1",_variant_t(str_1));
m_JieShuTime.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserTime_2",_variant_t(str_1));
m_ShiYongShiChong.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserTimeLength",_variant_t(str_1));
m_FeiYongJingE.GetWindowText(str_1);
str_10=str_1;
pFrame->f_MyApp->m_pRecordset->PutCollect("UserJiSuanFeiYong",_variant_t(str_1));
m_ShiYongRen.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserPeopel",_variant_t(str_1));
m_YouHuiJingE.GetWindowText(str_1);
if((str_1=="")||(str_1=="0"))
{
str_1="0.00";
}
str_11=str_1;
pFrame->f_MyApp->m_pRecordset->PutCollect("UserYouHuiFeiYong",_variant_t(str_1));
m_YouHuiTime.GetWindowText(str_1);
if((str_1=="")||(str_1=="0.00"))
{
str_1="0";
}
pFrame->f_MyApp->m_pRecordset->PutCollect("UserYouHuiTime",_variant_t(str_1));
m_FeiYong_2.GetWindowText(str_1);
pFrame->f_MyApp->m_pRecordset->PutCollect("UserShiJiFeiYong",_variant_t(str_1));
m_FeiYong_1.GetWindowText(str_1);
str_12=str_1;
pFrame->f_MyApp->m_pRecordset->PutCollect("UserYouHuiHouFeiYong",_variant_t(str_1));
pFrame->f_MyApp->m_pRecordset->Update();
pFrame->f_MyApp->m_pRecordset->Close();
}
catch(_com_error &e)
{
AfxMessageBox(e.ErrorMessage());
return;
}
m_YouHuiJingE.SetWindowText("0");
m_YouHuiTime.SetWindowText("0");
m_FeiYong_1.SetWindowText("0");
m_FeiYong_2.SetWindowText("0");
m_JieSuan_1.EnableWindow(FALSE);
pFrame->f_MyView->On_AddOldDataToListShow(0);
AfxMessageBox(str_4+"已经成功结算完毕!!!\n\n使用的实际费用为: "+str_10+" 元\n\n优惠的费用为: "+str_11+" 元\n\n应结算的费用为: "+str_12+" 元");
m_TaiQiuNumber.DeleteString(m_UINTMarkNumber);
CDialog::OnOK();
}
void CExes_BalanceDlg::OnUpdateEdit_2()
{
if(m_JingEYouHui.GetCheck()==1)
{
CString str,str_1,str_2,str_3,str_4;
m_YouHuiJingE.GetWindowText(str);
double m_1=atof(str);
m_FeiYongJingE.GetWindowText(str_2);
double m_3=atof(str_2);
double m_4=m_3-m_1;
str_1.Format("%0.2f",m_4);
m_FeiYong_1.SetWindowText(str_1);
m_FeiYong_2.SetWindowText(str_1);
m_JiaGe.GetWindowText(str_3);
str_3.Replace(" 元","");
double m_5=atof(str_3);
double m_6=m_5/60;
double m_7=m_1/m_6;
str_4.Format("%0.2f",m_7);
m_YouHuiTime.SetWindowText(str_4);
}
}
void CExes_BalanceDlg::On_Check3()
{
m_YouHuiMark_1.SetCheck(1);
m_YouHuiMark_2.SetCheck(0);
m_JingEYouHui.EnableWindow(TRUE);
m_TimeYouHui.EnableWindow(TRUE);
m_JingEYouHui.SetCheck(1);
m_TimeYouHui.SetCheck(0);
m_YouHuiJingE.SetReadOnly(FALSE);
m_YouHuiTime.SetReadOnly(TRUE);
m_YouHuiJingE.SetWindowText("0");
m_YouHuiTime.SetWindowText("0");
}
void CExes_BalanceDlg::On_Check4()
{
m_YouHuiMark_1.SetCheck(0);
m_YouHuiMark_2.SetCheck(1);
m_JingEYouHui.EnableWindow(FALSE);
m_TimeYouHui.EnableWindow(FALSE);
m_JingEYouHui.SetCheck(0);
m_TimeYouHui.SetCheck(0);
m_YouHuiJingE.SetReadOnly(TRUE);
m_YouHuiTime.SetReadOnly(TRUE);
m_YouHuiJingE.SetWindowText("0");
m_YouHuiTime.SetWindowText("0");
}
void CExes_BalanceDlg::OnUpdateEdit_1()
{
if(m_TimeYouHui.GetCheck()==1)
{
CString str_1,str_2,str_3,str_4;
m_JiaGe.GetWindowText(str_1);
m_YouHuiTime.GetWindowText(str_2);
str_1.Replace(" 元","");
double m_1=atof(str_1);
double m_2=m_1/60;
double m_3=atof(str_2);
double m_4=m_3*m_2;
str_3.Format("%0.2f",m_4);
m_YouHuiJingE.SetWindowText(str_3);
m_FeiYongJingE.GetWindowText(str_2);
double m_5=atof(str_2);
double m_6=m_5-m_4;
str_4.Format("%0.2f",m_6);
m_FeiYong_1.SetWindowText(str_4);
m_FeiYong_2.SetWindowText(str_4);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -