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

📄 frmmain.cpp

📁 AutoNetFidelio酒店管理系统增加智能门锁进行入住发卡及退房收卡。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		break;

	case -5:
		MessageBox(Translate(m_InfoFilePath,"对不起,读写卡错误!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	case -6:
		MessageBox(Translate(m_InfoFilePath,"对不起,没有检测到卡!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	case -7:
		MessageBox(Translate(m_InfoFilePath,"对不起,数据读取完成!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	case -8:
		MessageBox(Translate(m_InfoFilePath,"对不起,输入参数错误!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	case -9:
		MessageBox(Translate(m_InfoFilePath,"对不起,操作失败!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	case -10:
		MessageBox(Translate(m_InfoFilePath,"对不起,其他错误!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	case -11:
		MessageBox(Translate(m_InfoFilePath,"对不起,端口正在使用!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	case -12:
		MessageBox(Translate(m_InfoFilePath,"对不起,通信出错!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		break;
		
	default :
		MessageBox(Translate(m_InfoFilePath,"对不起,未知错误码!"),
				   Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
	}
}

/************************************************************
//      启动信息
*************************************************************/
void  __fastcall CFrmMain::StarSys()
{

	CString  Str;
	CString TimeStr,DateStr;
	CTime tCurrentTime;
	tCurrentTime=CTime::GetCurrentTime();
    DateStr=tCurrentTime.Format("%y%m%d");
	TimeStr=tCurrentTime.Format("%H%M%S");

	if(!m_IsSecondLS)//接收到服务器端第1次发送过来的启动命令
	{
		m_IsSecondLS=true;//标志已接收到一次启动命令

		Str="";
		Str="LS|DA"+DateStr+"|";
		Str+="TI"+ TimeStr+ "|";
		if(SendData(Str))
		return;
	}
	else			//接收到服务器端第2次发送过来的启动命令
	{
		m_IsSecondLS=false;//恢复标志接收端从来没有收到服务器端的启动命令

		Str="";
		Str="LD|DA"+DateStr+"|";
		Str+="TI"+ TimeStr+ "|";
		Str+="V#LvLock1.01|IFDL|";  //版本编号及类别
		if(!SendData(Str))
		return;
		::Sleep(100);

		Str="";                                              
		Str="LR|RIKR|FLK#KCKTRNWSDADTG#GAGDGGTI|";
		if(!SendData(Str))
		   return;
		::Sleep(100);

		Str="";
		Str="LR|RIKD|FLKCRNWSDAG#TI|";
		if(!SendData(Str))
		   return;
		::Sleep(100);
		
		Str="";
		Str="LR|RIKA|FLASKCWSDATI|";
		if(!SendData(Str))
		   return;
		::Sleep(100);

		Str="";
		Str="LA|DA"+DateStr+"|";
		Str+="TI"  +TimeStr+"|";
		if(SendData(Str))
		  return;
	}
}

/************************************************************
//      制作宾卡
*************************************************************/
void  __fastcall CFrmMain::KRCard()//发宾客卡
{
	UpdateData();
	
	short int bufT1[5]={0,0,0,0,0};   //开始时间
	short int bufT2[5]={0,0,0,0,0};   //结束时间
	short int buf6[6]={0,0,0,0,0,0};  //客房号
	
	CString Str,StrIn,StrOut,StrBa,StrWs,StrOk;
	int i;
	
	Str=m_ReceiveData;
    if(Str.GetLength()==0)
       return;
    if((i=Str.Find("|KC"))<0)
       return;
	Str=Str.Mid(i+3,Str.GetLength());  //去除|KC
	if((i=Str.Find("|"))<0)            //取下一|
        return;
	Str=Str.Mid(0,i);		           //取KC编码	
	
	CString szFKC;
	szFKC.Format("%d",FKC);
	if(Str!=szFKC)	                   //判断是否为本工作站的KC
	  return;

	i=0;
    Str=m_ReceiveData;    
	if(Str.GetLength()==0) 
        return;	
	if((i=Str.Find("|WS"))<0)
        return;
	Str=Str.Mid(i+3,Str.GetLength());//去除|WS
    if((i=Str.Find("|"))<0)          //取下一|
        return;
	StrWs=Str.Mid(0,i);              //取WS编码
	
	i=0;
    Str=m_ReceiveData;    
	if(Str.GetLength()==0) 
        return;	
	if((i=Str.Find("|RN"))<0)
        return;
	Str=Str.Mid(i+3,Str.GetLength());//去除|RN
	if((i=Str.Find("|"))<0)          //取下一|
        return;
	Str=Str.Mid(0,i);				 //取RN编码

	i=0;
    StrIn=m_ReceiveData;     //入住日期
	if((i=StrIn.Find("|GA"))<0)
        return;
	StrIn=StrIn.Mid(i+3,StrIn.GetLength());//去除|GA
	if((i=StrIn.Find("|"))<0)              //取下一|
        return;
	StrIn=StrIn.Mid(0,i);	//取GA编码
    if(StrIn.GetLength()==0)
           return;	

	i=0;
	StrOut=m_ReceiveData;   //入住日期
	if((i=StrOut.Find("|GD"))<0)
        return;
	StrOut=StrOut.Mid(i+3,StrOut.GetLength());  //去除|GD
	if((i=StrOut.Find("|"))<0)                  //取下一|
        return;
	StrOut=StrOut.Mid(0,i);//取GD编码
	if(StrOut.GetLength()==0)
           return;	
	
    int roomlen=Str.GetLength();
	buf6[5]=48;
    for(i=0;i<roomlen;i++)
    {
		buf6[5-roomlen+i]=Str[i];
	}
	for(i=0;i<5-roomlen;i++)
    {
		buf6[i]=48;
	} 
	
	CString Hour,Minute;
    CTime tCurrentTime;
    tCurrentTime=CTime::GetCurrentTime();
    Hour=tCurrentTime.Format("%H");
    Minute=tCurrentTime.Format("%M");
	 
	bufT1[0]=StringToInt("20"+StrIn.Mid(0,2));   //年
    bufT1[1]=StringToInt(StrIn.Mid(2,2));        //月
    bufT1[2]=StringToInt(StrIn.Mid(4,2));        //日
    bufT1[3]=StringToInt(Hour);                  //时
    bufT1[4]=StringToInt(Minute);                //分
    if(bufT1[4]>2)
         bufT1[4]=bufT1[4]-3;

     bufT2[0]=StringToInt("20"+StrOut.Mid(0,2)); //年
     bufT2[1]=StringToInt(StrOut.Mid(2,2));      //月
     bufT2[2]=StringToInt(StrOut.Mid(4,2));      //日
     bufT2[3]=StringToInt(Hour);                 //时
     bufT2[4]=StringToInt(Minute);               //分
     if((bufT2[4]+3)<60)
         bufT2[4]=bufT2[4]+3;
	 
	CString l_FKC;
	l_FKC.Format("%d",FKC);
    StrOk="KA|WS"+StrWs+"|KC"+l_FKC+"|ASOK|"; //返回一个响应贞数据
		
    if(!SendData(StrOk))
		return;

	CString   l_str1;
	CString   l_str2;
	l_str1 = Translate(m_InfoFilePath, "是否要制作'");
	l_str2 = Translate(m_InfoFilePath, "'号房间宾客卡?");
	Str = l_str1 + Str + l_str2;
	//发卡
	 for(i=0; i<3; i++)
     {	
		CMyBox  dlg;
		dlg.m_Caption.Format("%s",Str);
		dlg.m_IsTongxing = m_LastTongxingFlag;
		if (dlg.DoModal()==IDOK) //发卡
		{
			//初始化卡为宾客卡
			typedef short  (__stdcall *pNewCardInit)(short *,short);
			pNewCardInit pFuncNewCardInit= (pNewCardInit)GetProcAddress (hInstCard, "NewCardInit");
			m_StValue = pFuncNewCardInit(Rom, 1);          //初始化卡为宾客卡
			if(m_StValue==1)
			{
				//制宾客卡
				typedef short  (__stdcall *pMakeGuestCard)(short *, short, short *, short *, short *);
				pMakeGuestCard pFuncpMakeGuestCard= (pMakeGuestCard)GetProcAddress (hInstCard,"MakeGuestCard");

				if (dlg.m_IsTongxing)//制同行宾客卡
				{
					m_StValue = pFuncpMakeGuestCard(Rom, 1, buf6, m_bufT1,m_bufT2);
				}
				else//制普通宾客卡
				{
					m_StValue = pFuncpMakeGuestCard(Rom, 1, buf6, bufT1, bufT2);
					
					//保存此次制卡的时间,则下次可制作同行宾客卡
					 for (int j=0; j<5; j++)
					 {
						 m_bufT1[j] = bufT1[j];
						 m_bufT2[j] = bufT2[j];
					 }
				}
				
				m_LastTongxingFlag = dlg.m_IsTongxing;
				
				if(m_StValue==1)          
				   break;
			}
		
			if(m_StValue!=1)
				CheckError(m_StValue);
		}
	}
}

/************************************************************
//      删除宾客卡
*************************************************************/
void  __fastcall CFrmMain::KDCard() 
{
	short int bufT1[5]={0,0,0,0,0};      //开始时间
	short int bufT2[5]={0,0,0,0,0};      //结束时间
	short int buf6[6]={0,0,0,0,0,0};	 //客房号
	CString Str,StrWs,StrOk;
	int i;
	
	Str=m_ReceiveData;
	if(Str.GetLength()==0)
        return;
	if((i=Str.Find("|KC"))<0)
        return;
	Str=Str.Mid(i+3,Str.GetLength());  //去除|KC
	if((i=Str.Find("|"))<0)            //取下一|
        return;
	Str=Str.Mid(0,i);                  //取KC编码
	
	CString szFKC;
	szFKC.Format("%d",FKC);
	if(Str!=szFKC) //判断是否为本工作站的KC
	  return;
    
	i=0;
    Str=m_ReceiveData;    //取房间号
	if(Str.GetLength()==0) 
        return;	
    if((i=Str.Find("|WS"))<0)
        return;
	Str=Str.Mid(i+3,Str.GetLength());//去除|WS
    if((i=Str.Find("|"))<0)          //取下一|
        return;
	StrWs=Str.Mid(0,i);              //取WS编码

	Str="请把要退房的卡片放到读卡器上!";
	for(i=0;i<3;i++)
    {
		CString l_FKC;
		l_FKC.Format("%d",FKC);
		StrOk = "KA|WS"+StrWs+"|KC"+l_FKC+"|ASOK|";
        SendData(StrOk);

		int Response = MessageBox(Translate(m_InfoFilePath,Str),
								  Translate(m_InfoFilePath,"提示信息!"),MB_ICONASTERISK);
		
		if (Response == IDYES)
		{
			//初始化卡为宾客卡
			typedef short  (__stdcall *pNewCardInit)(short *,short);
			pNewCardInit pFuncNewCardInit= (pNewCardInit)GetProcAddress(hInstCard,"NewCardInit");
			m_StValue = pFuncNewCardInit(Rom, 1);//初始化卡为宾客卡
			if(m_StValue==1)
			{
				//制宾客卡
			   typedef short  (__stdcall *pMakeGuestCard)(short *, short, short *, short *, short *);
			   pMakeGuestCard pFuncpMakeGuestCard= (pMakeGuestCard)GetProcAddress (hInstCard,"MakeGuestCard");
			   m_StValue = pFuncpMakeGuestCard(Rom, 0, buf6, bufT1, bufT2);//制宾客卡
			   if(m_StValue==1)
					 break;
			 }
			if(m_StValue!=1)
				CheckError(m_StValue);	
		}
	}
}

//给服务器发送暂停命令暂停
void  __fastcall CFrmMain::CStop() 
{
   CString Str;
   CString TimeStr,DateStr;
   CTime tCurrentTime;
   tCurrentTime=CTime::GetCurrentTime();
   DateStr=tCurrentTime.Format("%y%m%d");
   TimeStr=tCurrentTime.Format("%H%M%S");

   Str="";
   Str="LE|DA"+DateStr+"|";
   Str+="TI"  +TimeStr+"|";
   SendData(Str); //暂停
}

void   __fastcall CFrmMain::CheckRunStat()//处理LA命令
{
   CString Str;
   CString TimeStr,DateStr;
   CTime tCurrentTime;
   tCurrentTime=CTime::GetCurrentTime();
   DateStr=tCurrentTime.Format("%y%m%d");
   TimeStr=tCurrentTime.Format("%H%M%S");

   Str="";
   Str="LA|DA"+DateStr+"|";
   Str+="TI"  +TimeStr+"|";
   SendData(Str); //发送给服务器全面检查运行状态命令
}

//分析处理接受到的数据
void   __fastcall CFrmMain::AnalyseRecData(CString StrData)
{
	m_ReceiveData=StrData;//接收数据缓冲区

	if(StrData.Find("LS")>=0)
	{	 
		StarSys();  //重启系统

⌨️ 快捷键说明

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