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

📄 checkoutdlg.cpp

📁 系统将动态实时的住宿登记、客房调整、销售报表、追加押金等有机地联系在一起
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			if(var.vt != VT_NULL)
		     	checkintime = (LPCSTR)_bstr_t(var);
			
           // 准备获取住宿日期
            CString beginyear,beginmonth,beginday;
            beginyear=checkindate.Mid(0,4);//提取年份
			//提取月份
			beginmonth=checkindate.Mid(5,checkindate.Find('-',6)-5);
			//提取日
			beginday=checkindate.Mid(checkindate.ReverseFind('-')+1,checkindate.GetLength()-checkindate.ReverseFind('-'));
			
			CTime time=CTime::GetCurrentTime();//构造时间对象
            CTime tm(time);
    
	        CString endYear,endMonth,endDay;
        	endYear.Format("%d",tm.GetYear());//转换为字符串
	        endMonth.Format("%d",tm.GetMonth());//转换为字符串
	        endDay.Format("%d",tm.GetDay());//转换为字符串
	
			float realdays,realmoney;
			//计算天数
            realdays=(atof(endYear)*365+atof(endMonth)*30+atof(endDay))-(atof(beginyear)*365+atof(beginmonth)*30+atof(beginday));
	        m_realdays=realdays;
            
			char prediscount_money[50]; 
			//转换为字符串
	        _gcvt(atof(m_checkoutroommoney)*realdays, 4, prediscount_money );
			m_sum_roommoney=prediscount_money;
///////////////////////////////////////////////////////
		//	m_checkindate.SetDlgItemText(IDC_DATETIMEPICKER_checkindate,checkindate);
			m_checkindate.SetWindowText(checkindate);
///////////////////////////////////////////////////////
          // 读取数据表中结款方式字段
			var = m_pRecordset->GetCollect("结款方式");
			if(var.vt != VT_NULL)
		     	m_discountkind = (LPCSTR)_bstr_t(var);
              // 读取数据表中折扣字段
            var = m_pRecordset->GetCollect("折扣");
			if(var.vt != VT_NULL)
		     	m_discount = atof((LPCSTR)_bstr_t(var));

             //定义临时存储空间
			char realget_money[50]; 
	        _gcvt(atof(m_checkoutroommoney)*realdays*m_discount/100, 4, realget_money );
			m_realget_roommoney=realget_money;
         // 读取数据表中姓名字段
			var = m_pRecordset->GetCollect("预收金额");
			if(var.vt != VT_NULL)
		     	m_prehandinmoney = (LPCSTR)_bstr_t(var);
             else
                m_prehandinmoney ="0";
             //定义临时存储空间
			 char strback_money[50]; 
			 float back_money;
             back_money=atof(m_prehandinmoney)-atof(m_checkoutroommoney)*realdays;
	         if(back_money<=0)
			 {//如果应归还金额小于0,就设定此数为0
                back_money=0;
			 }
			 //格式转换
			 _gcvt(back_money, 4, strback_money );
			 m_reback_money=strback_money;
            // 读取数据表中备注字段
			 var = m_pRecordset->GetCollect("备注");
			if(var.vt != VT_NULL)
		     m_checkoutbeizhu = (LPCSTR)_bstr_t(var);
			// 更新显示
           UpdateData(false);
    
		// 
		
	}
	catch(_com_error *e)// 捕获异常
	{
		AfxMessageBox(e->ErrorMessage());
	}

		// 关闭记录集
	m_pRecordset->Close();
	m_pRecordset = NULL;
	
	UpdateData(false);// 更新显示截面输入框内容
/////////////////////////////////////////////////////////////////////
	
}

void CCheckoutdlg::OnChangeextramoney() 
{
	// 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.
	UpdateData(true);
	if(m_extramoney_kind=="电话费")
		m_tel_money=m_extramoney;// 实时计算显示电话费内容
	else if(m_extramoney_kind=="杂费")
		m_mix_money=m_extramoney;// 实时计算显示杂费内容
	else if(m_extramoney_kind=="会议费")
		m_meeting_money=m_extramoney;	// 实时计算显示会议费内容
	else if(m_extramoney_kind=="停车费")
	    m_park_money=m_extramoney;// 实时计算显示停车费内容
	else
		m_mend_money =m_extramoney;// 实时计算显示维修费用内容
	UpdateData(false);
	// TODO: Add your control notification handler code here
	
}

void CCheckoutdlg::OnOK() 
{
	// TODO: Add extra validation here
	//store the record into the checkoutregtable
	UpdateData(true);

	m_pRecordsetout.CreateInstance(__uuidof(Recordset));
//INSERT INTO checkinregtable (凭证号码)VALUES('%s')
	CString strsqlstore;


   try// 打开数据库
	{
		m_pRecordsetout->Open("SELECT * FROM checkoutregtable",                // 查询 表中所有字段
							theApp.m_pConnection.GetInterfacePtr(),	 // 获取库接库的IDispatch指针
							adOpenDynamic,
							adLockOptimistic,
							adCmdText);
	}
	catch(_com_error *e)// 捕获异常
	{
		AfxMessageBox(e->ErrorMessage());
	}

	try
	{       // 设置数据库操作类型
	    	m_pRecordsetout->AddNew();
	        // // 往数据表中写入凭证号码字段数据
			m_pRecordsetout->PutCollect("凭证号码", _variant_t(m_checkoutnumber));
            // 往数据表中写入姓名字段数据
			m_pRecordsetout->PutCollect("姓名", _variant_t(m_name));
            // 往数据表中写入证件名称字段数据
			m_pRecordsetout->PutCollect("证件名称", _variant_t(m_zhengjiankind));
            // 往数据表中写入证件号码字段数据
			m_pRecordsetout->PutCollect("证件号码", _variant_t(m_checkoutzhenjian_number));
              // 往数据表中写入详细地址字段数据
			m_pRecordsetout->PutCollect("详细地址", _variant_t(m_addr));
               // 往数据表中写入房间号字段数据
			m_pRecordsetout->PutCollect("房间号", _variant_t(m_roomnumber));
            // 往数据表中写入客房类型字段数据
			m_pRecordsetout->PutCollect("客房类型", _variant_t(m_roomlevel));
              // 往数据表中写入客房价格字段数据
			m_pRecordsetout->PutCollect("客房价格", _variant_t(m_checkoutroommoney));
              // 往数据表中写入住宿日期字段数据
			m_pRecordsetout->PutCollect("住宿日期", _variant_t(checkindate));
               // 往数据表中写入住宿时间字段数据
			m_pRecordsetout->PutCollect("住宿时间", _variant_t(checkintime));
              // 往数据表中写入住宿天数字段数据
			m_pRecordsetout->PutCollect("住宿天数", _variant_t(m_realdays));
               // 往数据表中写入宿费字段数据
			m_pRecordsetout->PutCollect("宿费", _variant_t(m_sum_roommoney));
               // 往数据表中写入折扣或招待字段数据
			m_pRecordsetout->PutCollect("折扣或招待", _variant_t(m_discountkind));
               // 往数据表中写入折扣字段数据
			m_pRecordsetout->PutCollect("折扣", _variant_t(m_discount));
               // 往数据表中写入应收宿费字段数据
			m_pRecordsetout->PutCollect("应收宿费", _variant_t(m_realget_roommoney));
               // 往数据表中写入杂费字段数据
			m_pRecordsetout->PutCollect("杂费", _variant_t(m_mix_money));//m_mix_money
                // 往数据表中写入电话费字段数据
			m_pRecordsetout->PutCollect("电话费", _variant_t(m_tel_money));
                // 往数据表中写入会议费字段数据
			m_pRecordsetout->PutCollect("会议费", _variant_t(m_meeting_money));
              // 往数据表中写入存车费字段数据
			m_pRecordsetout->PutCollect("存车费", _variant_t(m_park_money));//m_park_money
               // 往数据表中写入赔偿费字段数据
			m_pRecordsetout->PutCollect("赔偿费", _variant_t(m_mend_money));
       
                // 往数据表中写入金额总计字段数据
			m_pRecordsetout->PutCollect("金额总计", _variant_t(m_realget_roommoney));
            // 往数据表中写入预收宿费字段数据
			m_pRecordsetout->PutCollect("预收宿费", _variant_t(m_prehandinmoney));
               // 往数据表中写入退还宿费字段数据
			m_pRecordsetout->PutCollect("退还宿费", _variant_t(m_reback_money));
               
		    CString outdate,outtime;
			int nYear,nDay,nMonth;
	        CString sYear,sDay,sMonth;
			int nhour,nmin,nsecond;
	        CString shour,smin,ssecond;
		    CTime tTime;
 	        tTime=tTime.GetCurrentTime(); // 获取当前系统时间
	        nYear=tTime.GetYear();//提取年份
	        nDay=tTime.GetDay();//提取日
	        nMonth=tTime.GetMonth();//提取月份
	        sYear.Format("%d",nYear);//转换为字符串
	        sDay.Format("%d",nDay);//转换为字符串
	        sMonth.Format("%d",nMonth);//转换为字符串
	        outdate.Format("%s-%s-%s",sYear,sMonth,sDay);// 格式化时间
            CString nowdate,nowtime;nowdate=outdate;
	        nhour=tTime.GetHour();//提取小时
	        nmin=tTime.GetMinute();//提取分钟
	        nsecond=tTime.GetSecond();//提取秒
    	    shour.Format("%d",nhour);//转换为字符串
	        smin.Format("%d",nmin);//转换为字符串
	        ssecond.Format("%d",nsecond);//转换为字符串
	        outtime.Format("%s:%s:%s",shour,smin,ssecond);// 格式化时间
            nowtime=outtime;
			// 往数据表中写入退房日期字段数据
			m_pRecordsetout->PutCollect("退房日期", _variant_t(outdate));
           // 往数据表中写入退房时间字段数据
			m_pRecordsetout->PutCollect("退房时间", _variant_t(outtime));
          // 往数据表中写入日期字段数据
			m_pRecordsetout->PutCollect("日期", _variant_t(nowdate));
           // 往数据表中写入时间字段数据
			m_pRecordsetout->PutCollect("时间", _variant_t(nowtime));
           // 往数据表中写入备注字段数据
			m_pRecordsetout->PutCollect("备注", _variant_t(m_checkoutbeizhu));
       
		
            // 更新数据库

        	m_pRecordsetout->Update();

		MessageBox("退宿完毕!","客房管理系统");
		
	}
	catch(_com_error *e)
	{//捕获异常
		AfxMessageBox(e->ErrorMessage());
	}
	m_pRecordsetout->Close();// 关闭记录集
	m_pRecordsetout = NULL;
///////////////////////////////////////////////////////////////
//update the roomsetting table
	CString SQLstr;
	SQLstr="SELECT * FROM roomsetting where 房间号='" ;
    SQLstr+=m_roomnumber;
    SQLstr+="'";
	if(!mymendroominfoset.Open(AFX_DB_USE_DEFAULT_TYPE,SQLstr))
	{//查询数据库得到数据集合
		MessageBox("打开roomsetting 表失败,更改房间状态失败!","客房管理系统");
			if(mymendroominfoset.IsOpen())
			{
	         mymendroominfoset.Close();
			}
		return ;
	}
	
	mymendroominfoset.Edit();//设置数据库操作类型
	
	mymendroominfoset.m_column4="空房";
	mymendroominfoset.Update();// 更新数据库
	mymendroominfoset.Requery();
///////////////////////////////////
	if(mymendroominfoset.IsOpen())
	{
	   mymendroominfoset.Close();// 关闭数据集
	}

}

void CCheckoutdlg::Onoutreg() 
{
	// TODO: Add your control notification handler code here
	m_checkoutnumber = _T("");// 初始化输入框对应变量
	m_addr = _T("");
	m_checkoutbeizhu = _T("");
	m_discountkind = _T("");
	m_extramoney_kind = _T("");
	m_regnumber = _T("");
	m_discount = 0.0f;
	m_extramoney = _T("");
	m_name = _T("");
	m_prehandinmoney = _T("");
	m_realdays = 0.0f;
	m_realget_roommoney = _T("");
	m_reback_money = _T("");
	m_roomlevel = _T("");
	m_roomnumber = _T("");
	m_sum_roommoney = _T("");
	m_tel_money = _T("");
	m_park_money = _T("");
	m_mix_money = _T("");
	m_mend_money = _T("");
	m_meeting_money = _T("");
	m_checkout_zhenjiannumber = _T("");
	m_checkoutzhenjian_number = _T("");
	m_zhengjiankind = _T("");
	m_checkoutroommoney = _T("");
    // 初始化输入框对应变量完毕
	// 更新显示
	UpdateData(false);
}

BOOL CCheckoutdlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==VK_RETURN)
	{

          pMsg->wParam=VK_TAB;//重载回车键盘消息为table键盘消息,ok!2006.4.18
		        
	}

	return CDialog::PreTranslateMessage(pMsg);
}

⌨️ 快捷键说明

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