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

📄 checkout.cpp

📁 (VC)又一个酒店管理系统, (VC)又一个酒店管理系统,(VC)又一个酒店管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		/*
			//更新找钱窗口的数据
		*/
			OnChangeCheckoutPaid();
			break;
		}
		else
		{
             StartTime.SetWindowText("");
             Times.SetWindowText("0");
			 Sum.SetWindowText("0");
		}
		m_BillCheckoutInfoSet.MoveNext();//移动到下一条记录
	}
	m_BillCheckoutInfoSet.Close();//关闭数据库
/*######################    END    ############################*/

}


void CCheckOut::OnEditchangeCheckoutHandcode() 
{
	// TODO: Add your control notification handler code here
	//清除前面的记录,重新进行计算

	CString strHandCode="";
	HandCode.GetWindowText(strHandCode);//得到当前的手牌号码
	//到数据库中查找是否存在这个记录
				int Startyear=0;  //得到年份
				int Startmonth=0; 
				int Startday=0;
				int Starthour=0;
				int Startmini=0;
				int Startsecond=0;
				float nRoomPrice=0.00f;//房间的价格(total)
//////////////////////////////////////////////////////////////////////////
/*############### 显示开始入住时间的查询过程 ##################*/
	if(!m_BillCheckoutInfoSet.Open())
	{
		MessageBox("打开数据库失败!","数据库错误",MB_OK);
		return;
	}
	m_BillCheckoutInfoSet.MoveFirst();//移动到第一条记录
	while (!m_BillCheckoutInfoSet.IsEOF())
	{
		if(strHandCode==m_BillCheckoutInfoSet.m_HandCode)
		{//找到了这个手牌号码,将这个记录中的开始时间写道对话框中
			CTime strTime=m_BillCheckoutInfoSet.m_StartTime;
            CString strTimeShow,strYear,strMonth,strDay,strHour,strMinute,strSecond;
			Startyear=strTime.GetYear();  //得到年份
		    Startmonth=strTime.GetMonth();
			Startday=strTime.GetDay();
			Starthour=strTime.GetHour();
			Startmini=strTime.GetMinute();
			Startsecond=strTime.GetSecond();
			strYear.Format("%d",Startyear);//格式化年份
			strMonth.Format("%d",Startmonth);
			strDay.Format("%d",Startday);
			strHour.Format("%d",Starthour);
			strMinute.Format("%d",Startmini);
			strSecond.Format("%d",Startsecond);//格式化秒
			strTimeShow=strYear+"-"+strMonth+"-"+strDay+" "+strHour
				+":"+strMinute+":"+strSecond;
			StartTime.SetWindowText(strTimeShow);
/////////////////////////////////////////////////////////////////
	        //计算入住的总时间
	        CString strStartTime,strEndTime;
	        long nHours=0,nMinutes=0;
	        StartTime.GetWindowText(strStartTime); //得到开始入住的时间
	        CurTime.GetWindowText(strEndTime);//得到当前的时间
	        if(strStartTime=="")
			{
                 Times.SetWindowText("");
			}
            int dYears=0,dMonths=0,dDays=0,dMinutes=0,dHours=0,dSeconds=0;
	        dYears=year-Startyear;//得到年份的差值
	        dMonths=month-Startmonth;
	        dDays=day-Startday;
	        dHours=hour-Starthour;
	        dMinutes=minute-Startmini;
	        dSeconds=second-Startsecond;
	        //计算总的时间差
			nHours=dYears*365*24+dMonths*30*24+dDays*24+dHours;
	        nMinutes=dMinutes+(int)dSeconds/60;
	        if(nMinutes<0)
			{
		        nHours=nHours-1;
		        nMinutes=nMinutes+60;
			}
	        CString strHours,strMinutes;
	        strHours.Format("%d",nHours);
	        strMinutes.Format("%d",nMinutes);
	        CString strTimes;
	        strTimes=strHours+":"+strMinutes;
	        Times.SetWindowText(strTimes);
            /*      通过手牌号码查找房间的号码      */
			
			if(!m_GuestInfoSet.Open())
			{
				MessageBox("打开数据库失败!","数据库错误",MB_OK);
				return;
			}
			m_GuestInfoSet.MoveFirst();//移动到第一条记录
			while (!m_GuestInfoSet.IsEOF())
			{
				if(strHandCode==m_GuestInfoSet.m_HandCode)
				{//查找到相应的手牌号码
                    CString strRoomCode;
					strRoomCode=m_GuestInfoSet.m_RoomCode;//得到房间号码
					char* s=strRoomCode.GetBuffer(strRoomCode.GetLength());
					char* strTokText=strtok(s,",");
                    
					/*   通过查找得到的房间号码查看房间的价格   */
					while(strTokText!=NULL)
					{
					    CString strRoomCodeTok=strTokText;//得到房间号码
						if(!m_RoomInfoSet.Open())
						{//打开房间表
							MessageBox("打开数据库失败!","数据库错误",MB_OK);
							return;
						}
						m_RoomInfoSet.MoveFirst();//移动第一条记录
						while(!m_RoomInfoSet.IsEOF())
						{
							if(m_RoomInfoSet.m_RoomCode==strRoomCode)
							{//找到了房间查看房间的价格
								//将当前查找到的房间价格加入到总和中
								nRoomPrice=nRoomPrice+m_RoomInfoSet.m_Price;
							}
							m_RoomInfoSet.MoveNext();//移动到下一条记录
						}
						m_RoomInfoSet.Close();//查询完毕关闭数据库
						//得到下一个房间号码
						strTokText=strtok(NULL,",");
					}
				}
				m_GuestInfoSet.MoveNext();//移动到客人的下一条记录
			}
			m_GuestInfoSet.Close();//关闭客人信息表
			/////////计算住房间的费用
			////计算方法为:房间费用=房间的价格*住的时间
			float nRoomTotalPrice=0.00f;
			/*        
			          计算客人住房所用的总费用
			*/
			nRoomTotalPrice=(float)(nHours+(float)nMinutes/60)*nRoomPrice;

			/* @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ */

 /*
                   开始计算客人在酒店期间各种消费总数目
 */
             /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
			             通过查找帐单来计算总的消费费用
			   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
			long nSumInCast=0;//消费的总费用
            if(!m_BillInfoSet.Open())
			{
				MessageBox("打开数据库失败!","数据库错误",MB_OK);
				return;
			}
			m_BillInfoSet.MoveFirst();//first
			while (!m_BillInfoSet.IsEOF())
			{
				if(strHandCode==m_BillInfoSet.m_HandCode)
				{
					nSumInCast=nSumInCast+m_BillInfoSet.m_Sum-m_BillInfoSet.m_Paid;
				}
				m_BillInfoSet.MoveNext();//移动到下一条记录
			}
			m_BillInfoSet.Close();//关闭数据库
	  /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
			  计算客人总的费用包括房间的钱和消费的钱
	  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
            CString strSum;
			strSum.Format("%6.00f",nSumInCast+nRoomTotalPrice);
			Sum.SetWindowText(strSum);
		/*
			//更新找钱窗口的数据
		*/
			OnChangeCheckoutPaid();
			break;
		}
		else
		{
             StartTime.SetWindowText("");
             Times.SetWindowText("0");
			 Sum.SetWindowText("0");
		}
		m_BillCheckoutInfoSet.MoveNext();//移动到下一条记录
	}
	m_BillCheckoutInfoSet.Close();//关闭数据库
/*######################    END    ############################*/
}

void CCheckOut::OnChangeCheckoutPaid() 
{
	// 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.
	
	// TODO: Add your control notification handler code here
	CString strSum,strPaid;
	Sum.GetWindowText(strSum);
	Paid.GetWindowText(strPaid);
    long nSum=0,nPaid=0,nSub=0;
	char* sSum,*sPaid;
	sSum=strSum.GetBuffer(strSum.GetLength());
	sPaid=strPaid.GetBuffer(strPaid.GetLength());
	nSum=atol(sSum);
	nPaid=atol(sPaid);
	nSub=nPaid-nSum;
	CString strSub;
 	strSub.Format("%ld",nSub);
    SubMoney.SetWindowText(strSub);
}

void CCheckOut::OnOK() 
{
	// TODO: Add extra validation here
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                      保存数据到数据库中
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
	
	CString strEndTime,strSum,strHandCode;
	HandCode.GetWindowText(strHandCode);//手牌号码
    CurTime.GetWindowText(strEndTime);//得到当前时间,也就是结束时间
	Sum.GetWindowText(strSum);
    
    ///////将结束实际写到数据库中
	if(!m_BillCheckoutInfoSet.Open())
	{
		MessageBox("打开数据库失败!","数据库错误",MB_OK);
		return;
	}
	m_BillCheckoutInfoSet.MoveFirst();
	while (!m_BillCheckoutInfoSet.IsEOF())
	{
		if(strHandCode==m_BillCheckoutInfoSet.m_HandCode)
		{
			if(!m_BillCheckoutInfoSet.m_Sum.IsEmpty())
			{//已经写了这个记录
				MessageBox("该客户已经结帐了!","结帐错误",MB_OK);
				m_BillCheckoutInfoSet.Close();//关闭数据库停止查找
				return;
			}
			else
			{
				CTime tm(year,month,day,hour,minute,second);
				m_BillCheckoutInfoSet.Edit();
				m_BillCheckoutInfoSet.m_EndTime=tm;
				m_BillCheckoutInfoSet.m_Sum=strSum;
			    m_BillCheckoutInfoSet.Update();
			}
		}
		m_BillCheckoutInfoSet.MoveNext();
	}
	m_BillCheckoutInfoSet.Close();
	InitDate();//初始化数组
	CDialog::OnOK();
}

void CCheckOut::InitDate()
{
	for(int i=0;i<100;i++)
	{
		STRINGS[i]="";
	}
}



void CCheckOut::OnCancel() 
{
	// TODO: Add extra cleanup here
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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