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

📄 billiards_user_rollcall.cpp

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

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CBilliards_User_RollCall dialog


CBilliards_User_RollCall::CBilliards_User_RollCall(int MARK)
	: CDialog(CBilliards_User_RollCall::IDD)
{
	//{{AFX_DATA_INIT(CBilliards_User_RollCall)
	//}}AFX_DATA_INIT
	m_TimeMark=MARK;
}


void CBilliards_User_RollCall::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CBilliards_User_RollCall)
	DDX_Control(pDX, IDC_BUTTON2, m_but_Mark);
	DDX_Control(pDX, IDC_STATIC_2, m_e_4);
	DDX_Control(pDX, IDC_STATIC_1, m_e_3);
	DDX_Control(pDX, IDC_EDIT8, m_e_2);
	DDX_Control(pDX, IDC_EDIT7, m_e_1);
	DDX_Control(pDX, IDC_EDIT5, m_Mark);
	DDX_Control(pDX, IDC_EDIT6, m_User);
	DDX_Control(pDX, IDOK, m_OK);
	DDX_Control(pDX, IDC_EDIT4, m_Time);
	DDX_Control(pDX, IDC_EDIT3, m_RiQi);
	DDX_Control(pDX, IDC_EDIT2, m_JiaGe);
	DDX_Control(pDX, IDC_EDIT1, m_WeiZhi);
	DDX_Control(pDX, IDC_COMBO1, m_NumberShow);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CBilliards_User_RollCall, CDialog)
	//{{AFX_MSG_MAP(CBilliards_User_RollCall)
	ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo_Number)
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON1, On_Button_Close)
	ON_BN_CLICKED(IDC_BUTTON2, On_Button_Mark)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBilliards_User_RollCall message handlers

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

	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	m_UserMark=FALSE;
	
	CString str_1,str_2,str_3;
	_variant_t var;

	m_OK.EnableWindow(FALSE);

	m_NumberShow.ResetContent();
	
	if(m_TimeMark==1)
	{
		str_3="没有使用";
		m_OK.SetWindowText("开始使用");
	}
	if(m_TimeMark==2)
	{
		str_3="正在使用";
		m_OK.SetWindowText("确定修改");
	}
	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==str_3)
				{
					var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserNumber");
					if(var.vt!=VT_NULL)
					{
						str_2=(LPCSTR)_bstr_t(var);

						m_NumberShow.AddString("第 "+str_2+" 台球桌");
					}
				}
			}
			pFrame->f_MyApp->m_pRecordset->MoveNext();
		}
		pFrame->f_MyApp->m_pRecordset->Close();		
	}
	catch(_com_error &e)
	{
		AfxMessageBox(e.ErrorMessage());
		return FALSE;
	}

	m_e_1.ShowWindow(SW_HIDE);
	m_e_2.ShowWindow(SW_HIDE);
	m_e_3.ShowWindow(SW_HIDE);
	m_e_4.ShowWindow(SW_HIDE);
	
	return TRUE;
}

void CBilliards_User_RollCall::OnSelchangeCombo_Number() 
{
	CString str_10;
	int m_Mark_1=m_NumberShow.GetCurSel();

	if(m_Mark_1>=0)
	{
		m_OK.EnableWindow(TRUE);
	}

	m_NumberShow.GetWindowText(str_10);

	str_10.Replace("第 ","");
	str_10.Replace(" 台球桌","");

	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	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_10)
				{
					var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserJiaGe");
					if(var.vt!=VT_NULL)
					{
						str_2=(LPCSTR)_bstr_t(var);

						m_JiaGe.SetWindowText(str_2);
					}

					var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserWeiZhi");
					if(var.vt!=VT_NULL)
					{
						str_2=(LPCSTR)_bstr_t(var);

						m_WeiZhi.SetWindowText(str_2);
					}

					var=pFrame->f_MyApp->m_pRecordset->GetCollect("Mark");
					if(var.vt!=VT_NULL)
					{
						str_2=(LPCSTR)_bstr_t(var);

						m_Mark.SetWindowText(str_2);
					}

					var=pFrame->f_MyApp->m_pRecordset->GetCollect("UserData");
					if(var.vt!=VT_NULL)
					{
						str_2=(LPCSTR)_bstr_t(var);

						m_RiQi.SetWindowText(str_2);
					}

					var=pFrame->f_MyApp->m_pRecordset->GetCollect("BeginTime");
					if(var.vt!=VT_NULL)
					{
						str_2=(LPCSTR)_bstr_t(var);

						m_Time.SetWindowText(str_2);

						if(m_TimeMark==2)
						{
							m_e_1.SetWindowText(str_2.Mid(0,2));
							m_e_2.SetWindowText(str_2.Mid(4,2));
						}
					}
				}
			}
			pFrame->f_MyApp->m_pRecordset->MoveNext();
		}
		pFrame->f_MyApp->m_pRecordset->Close();		
	}
	catch(_com_error &e)
	{
		AfxMessageBox(e.ErrorMessage());
		return;
	}

	if(m_TimeMark==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_Time.SetWindowText(str[3]);
		
		m_e_1.SetWindowText(str[0]);
		m_e_2.SetWindowText(str[1]);
		
		int m_4=m_Time_1.GetCurrentTime().GetYear();
		int m_5=m_Time_1.GetCurrentTime().GetMonth();
		int m_6=m_Time_1.GetCurrentTime().GetDay();
		
		str[0].Format("%d",m_4);
		str[1].Format("%d",m_5);
		str[2].Format("%d",m_6);
		
		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_RiQi.SetWindowText(str[3]);
	}
	if(m_TimeMark==2)
	{
	}
}

void CBilliards_User_RollCall::OnOK() 
{
//	KillTimer(m_TimeMark);

	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;

	CString str_3;
	m_NumberShow.GetWindowText(str_3);
	
	str_3.Replace("第 ","");
	str_3.Replace(" 台球桌","");
	
	CString str_4,str_5,str_6;
	m_User.GetWindowText(str_6);
	m_Time.GetWindowText(str_5);
	m_RiQi.GetWindowText(str_4);
	
	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(str_4));
					pFrame->f_MyApp->m_pRecordset->PutCollect("BeginTime",_variant_t(str_5));
					pFrame->f_MyApp->m_pRecordset->PutCollect("UserPeople",_variant_t(str_6));

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

	pFrame->f_MyView->On_AddDataToListShow(str_3);
	
	CDialog::OnOK();
}

void CBilliards_User_RollCall::OnTimer(UINT nIDEvent) 
{
	CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
	if(m_UserMark==TRUE)
	{
		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_Time.SetWindowText(str[3]);

		int m_4=m_Time_1.GetCurrentTime().GetYear();
		int m_5=m_Time_1.GetCurrentTime().GetMonth();
		int m_6=m_Time_1.GetCurrentTime().GetDay();

		str[0].Format("%d",m_4);
		str[1].Format("%d",m_5);
		str[2].Format("%d",m_6);
		
		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_RiQi.SetWindowText(str[3]);

		m_OK.EnableWindow(TRUE);
	}
	
	CDialog::OnTimer(nIDEvent);
}

void CBilliards_User_RollCall::On_Button_Close() 
{
	CDialog::OnOK();
}

void CBilliards_User_RollCall::On_Button_Mark() 
{
	m_UserMark=!m_UserMark;

	if(m_UserMark==TRUE)
	{
		m_but_Mark.SetWindowText("确定");
		m_e_1.ShowWindow(SW_SHOW);
		m_e_2.ShowWindow(SW_SHOW);
		m_e_3.ShowWindow(SW_SHOW);
		m_e_4.ShowWindow(SW_SHOW);

		m_OK.EnableWindow(FALSE);
	}
	else
	{
		CString str_1,str_2,str_3;
		m_e_1.GetWindowText(str_1);
		m_e_2.GetWindowText(str_2);
		if(str_1.GetLength()==1)
		{
			str_1="0"+str_1;
		}
		if(str_2.GetLength()==1)
		{
			str_2="0"+str_2;
		}

		int m_1=atoi(str_1);
		int m_2=atoi(str_2);
		if((m_1>=24)||(m_2>=60))
		{
			m_UserMark=TRUE;
			AfxMessageBox("对不起,输入的时间不正确,请从新输入时间!");
			return;
		}
		m_Time.SetWindowText(str_1+":"+str_2+":"+"00");


		m_but_Mark.SetWindowText("修改");
		m_e_1.ShowWindow(SW_HIDE);
		m_e_2.ShowWindow(SW_HIDE);
		m_e_3.ShowWindow(SW_HIDE);
		m_e_4.ShowWindow(SW_HIDE);

		m_OK.EnableWindow(TRUE);
	}
}

⌨️ 快捷键说明

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