⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 billiards_parameter_setup.cpp

📁 可以用于台球厅进行收费的程序代码,计算时间并进行费用计算
💻 CPP
字号:
// Billiards_Parameter_Setup.cpp : implementation file
//

#include "stdafx.h"
#include "双星台球厅计时收费系统.h"
#include "Billiards_Parameter_Setup.h"

#include "双星台球厅计时收费系统View.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBilliards_Parameter_Setup dialog


CBilliards_Parameter_Setup::CBilliards_Parameter_Setup(CWnd* pParent /*=NULL*/)
	: CDialog(CBilliards_Parameter_Setup::IDD, pParent)
{
	//{{AFX_DATA_INIT(CBilliards_Parameter_Setup)
	m_LeiXing = 0;
	//}}AFX_DATA_INIT
}


void CBilliards_Parameter_Setup::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBilliards_Parameter_Setup)
	DDX_Control(pDX, ID_OK, m_OK_1);
	DDX_Control(pDX, IDC_EDIT4, m_Mark);
	DDX_Control(pDX, IDC_EDIT3, m_WeiZhi);
	DDX_Control(pDX, IDC_EDIT2, m_JiaGe);
	DDX_Control(pDX, IDC_COMBO1, m_Number);
	DDX_Radio(pDX, IDC_RADIO1, m_LeiXing);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CBilliards_Parameter_Setup, CDialog)
	//{{AFX_MSG_MAP(CBilliards_Parameter_Setup)
	ON_BN_CLICKED(ID_OK, OnOk)
	ON_BN_CLICKED(IDC_RADIO1, OnRadio_1)
	ON_BN_CLICKED(IDC_RADIO2, OnRadio_2)
	ON_BN_CLICKED(IDC_RADIO3, OnRadio_3)
	ON_CBN_SELCHANGE(IDC_COMBO1, On_SelchangeCombo)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBilliards_Parameter_Setup message handlers

BOOL CBilliards_Parameter_Setup::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_MarkCount_1=1;
	
	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
	_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);
	m_RecordCount=m_RecordCount+1;
	str_10.Format("%d",m_RecordCount);

	if(str_10.GetLength()==1)
	{
		str_10="第 00"+str_10+" 台球桌";
	}
	if(str_10.GetLength()==2)
	{
		str_10="第 0"+str_10+" 台球桌";
	}

	m_Number.AddString(str_10);
	m_Number.SetCurSel(0);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CBilliards_Parameter_Setup::OnOk() 
{
	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	CString str;
	m_JiaGe.GetWindowText(str);
	if(str=="")
	{
		AfxMessageBox("对不起,价格不能为空,请从新输入价格!");
		return;
	}

	CString str_1,str_2,str_3;
	_variant_t var;
	if(m_MarkCount_1==1)
	{
		try
		{
			pFrame->f_MyApp->m_pRecordset->Open("SELECT *FROM TaiQiuZheUserInformationRecond",
				pFrame->f_MyApp->m_pConnection.GetInterfacePtr(),
				adOpenDynamic,
				adLockOptimistic,
				adCmdText);

			pFrame->f_MyApp->m_pRecordset->AddNew();

			m_Number.GetWindowText(str_1);
			str_1.Replace("第 ","");
			str_1.Replace(" 台球桌","");
			str_2=str_1;
			pFrame->f_MyApp->m_pRecordset->PutCollect("UserNumber",_variant_t(str_1));

			m_JiaGe.GetWindowText(str_1);
			pFrame->f_MyApp->m_pRecordset->PutCollect("UserJiaGe",_variant_t(str_1+" 元/小时"));

			m_WeiZhi.GetWindowText(str_1);
			pFrame->f_MyApp->m_pRecordset->PutCollect("UserWeiZhi",_variant_t(str_1));

			m_Mark.GetWindowText(str_1);
			pFrame->f_MyApp->m_pRecordset->PutCollect("Mark",_variant_t(str_1));

			pFrame->f_MyApp->m_pRecordset->PutCollect("UserMark",_variant_t("没有使用"));

			pFrame->f_MyApp->m_pRecordset->Update();
			pFrame->f_MyApp->m_pRecordset->Close();
		}
		
		catch(_com_error &e)
		{
			AfxMessageBox(e.ErrorMessage());
			return;
		}

		pFrame->f_MyView->m_MarkCount_1=FALSE;
		AfxMessageBox("增加的第 "+str_2+" 台球桌已成功输入到数据库中!!!");

		int m_K_1=atoi(str_2)+1;
		str_2.Format("第 %d 台球桌",m_K_1);
		m_Number.ResetContent();
		m_Number.AddString(str_2);
		m_Number.SetCurSel(0);
	}
	if(m_MarkCount_1==2)
	{
		m_Number.GetWindowText(str_2);
		str_2.Replace("第 ","");
		str_2.Replace(" 台球桌","");

		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_2)
					{
						m_JiaGe.GetWindowText(str_1);
						pFrame->f_MyApp->m_pRecordset->PutCollect("UserJiaGe",_variant_t(str_1+" 元/小时"));
						
						m_WeiZhi.GetWindowText(str_1);
						pFrame->f_MyApp->m_pRecordset->PutCollect("UserWeiZhi",_variant_t(str_1));
						
						m_Mark.GetWindowText(str_1);
						pFrame->f_MyApp->m_pRecordset->PutCollect("Mark",_variant_t(str_1));
					}
				}
				pFrame->f_MyApp->m_pRecordset->MoveNext();
			}
			pFrame->f_MyApp->m_pRecordset->Close();	
			
		}
		catch(_com_error &e)
		{
			AfxMessageBox(e.ErrorMessage());
			return;
		}

		m_OK_1.EnableWindow(FALSE);
		pFrame->f_MyView->m_MarkCount_1=FALSE;

		AfxMessageBox("修改的第 "+str_2+" 台球桌已成功输入到数据库中!!!");
	}

	if(m_MarkCount_1==3)
	{
		int m_Mark_D=m_Number.GetCurSel();
		m_Number.GetWindowText(str_2);
		str_2.Replace("第 ","");
		str_2.Replace(" 台球桌","");

		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_2)
					{
						var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserMark");
						if(var.vt!=VT_NULL)
						{
							str_3=(LPCSTR)_bstr_t(var);
							
							if(str_3=="正在使用")
							{
							}
							if(str_3=="没有使用")
							{
								pFrame->f_MyApp->m_pRecordset->Delete(adAffectCurrent);
								pFrame->f_MyApp->m_pRecordset->Update();
							}
						}
					}
				}
				pFrame->f_MyApp->m_pRecordset->MoveNext();
			}
			pFrame->f_MyApp->m_pRecordset->Close();		
		}
		catch(_com_error &e)
		{
			AfxMessageBox(e.ErrorMessage());
			return;
		}

		m_OK_1.EnableWindow(FALSE);
		m_Number.DeleteString(m_Mark_D);
		pFrame->f_MyView->m_MarkCount_1=FALSE;

		AfxMessageBox("第 "+str_2+" 台球桌已从数据库中成功删除!!!");
	}
}

void CBilliards_Parameter_Setup::OnRadio_1() 
{
	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	m_MarkCount_1=1;

	m_OK_1.EnableWindow(TRUE);

	m_Mark.SetReadOnly(FALSE);
	m_WeiZhi.SetReadOnly(FALSE);
	m_JiaGe.SetReadOnly(FALSE);

	m_Mark.SetWindowText("");
	m_WeiZhi.SetWindowText("");
	m_JiaGe.SetWindowText("");

	_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);
	m_RecordCount=m_RecordCount+1;
	str_10.Format("%d",m_RecordCount);

	if(str_10.GetLength()==1)
	{
		str_10="第 00"+str_10+" 台球桌";
	}
	if(str_10.GetLength()==2)
	{
		str_10="第 0"+str_10+" 台球桌";
	}

	m_Number.ResetContent();
	m_Number.AddString(str_10);
	m_Number.SetCurSel(0);
}

void CBilliards_Parameter_Setup::OnRadio_2() 
{
	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	m_MarkCount_1=2;

	m_OK_1.EnableWindow(FALSE);

	m_Mark.SetReadOnly(FALSE);
	m_WeiZhi.SetReadOnly(FALSE);
	m_JiaGe.SetReadOnly(FALSE);

	m_Mark.SetWindowText("");
	m_WeiZhi.SetWindowText("");
	m_JiaGe.SetWindowText("");
	
	CString str_1,str_2;
	_variant_t var;
	
	m_Number.ResetContent();
	
	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);
				
				m_Number.AddString("第 "+str_1+" 台球桌");			
			}
			
			pFrame->f_MyApp->m_pRecordset->MoveNext();
		}
		pFrame->f_MyApp->m_pRecordset->Close();		
	}
	catch(_com_error &e)
	{
		AfxMessageBox(e.ErrorMessage());
		return;
	}
}

void CBilliards_Parameter_Setup::OnRadio_3() 
{
	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	m_MarkCount_1=3;

	m_OK_1.EnableWindow(FALSE);

	m_Mark.SetReadOnly(TRUE);
	m_WeiZhi.SetReadOnly(TRUE);
	m_JiaGe.SetReadOnly(TRUE);

	m_Mark.SetWindowText("");
	m_WeiZhi.SetWindowText("");
	m_JiaGe.SetWindowText("");
	
	CString str_1,str_2;
	_variant_t var;
	
	m_Number.ResetContent();
	
	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);

				var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserMark");
				if(var.vt!=VT_NULL)
				{
					str_2=(LPCSTR)_bstr_t(var);
					
					if(str_2=="没有使用")
					{
						m_Number.AddString("第 "+str_1+" 台球桌");	
					}
				}					
			}
			
			pFrame->f_MyApp->m_pRecordset->MoveNext();
		}
		pFrame->f_MyApp->m_pRecordset->Close();		
	}
	catch(_com_error &e)
	{
		AfxMessageBox(e.ErrorMessage());
		return;
	}
}

void CBilliards_Parameter_Setup::On_SelchangeCombo() 
{
	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	m_OK_1.EnableWindow(TRUE);

	CString str;
	m_Number.GetWindowText(str);
	str.Replace("第 ","");
	str.Replace(" 台球桌","");

	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)
				{
					var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserJiaGe");
					if(var.vt!=VT_NULL)
					{
						str_1=(LPCSTR)_bstr_t(var);
						str_1.Replace(" 元/小时","");
						m_JiaGe.SetWindowText(str_1);
					}

					var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserWeiZhi");
					if(var.vt!=VT_NULL)
					{
						str_1=(LPCSTR)_bstr_t(var);
						m_WeiZhi.SetWindowText(str_1);
					}
					else
					{
						m_WeiZhi.SetWindowText("");
					}

					var=pFrame->f_MyApp->m_pRecordset->GetCollect("Mark");
					if(var.vt!=VT_NULL)
					{
						str_1=(LPCSTR)_bstr_t(var);
						m_Mark.SetWindowText(str_1);
					}
					else
					{
						m_Mark.SetWindowText("");
					}
				}
			}
			
			pFrame->f_MyApp->m_pRecordset->MoveNext();
		}
		pFrame->f_MyApp->m_pRecordset->Close();		
	}
	catch(_com_error &e)
	{
		AfxMessageBox(e.ErrorMessage());
		return;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -