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

📄 cmainmenuwnd.cpp

📁 进行简单的窗体分组
💻 CPP
字号:
#include "stdafx.h"
#include "ccwn_con.h"
#include "coutput.h"
#include "cmainmenuwnd.h"
#include "cglobal.h"
#include "msgbox.h"
#include "keydef.h"
#include "clogin.h"
#include "Xhsywin.h"
#include "minipos.h"
#include "ckeyb.h"
#include "fkwin.h"
#include "cposreport.h"
#include "cdataprownd.h"
#include "cparamenuwnd.h"
#include "cdocmenuwnd.h"
#include "cdirectorwnd.h"
#include "ic4442card.h"
#include "cgetinwnd.h"
#include "msginput.h"
#include "printer.h"
#include "pzip.h"
#include "cicwnd.h"
#include "cicopenwnd.h"
#include "cicchangewnd.h"
#include "ciclistwnd.h"
#include "cicreturnwnd.h"



CMainMenuWnd::CMainMenuWnd():CCWN_CON()
{
	
}

CMainMenuWnd::~CMainMenuWnd()
{
	
}

void CMainMenuWnd::Show(void)
{
	CCWN_CON::Show();
	out0.Show();
	out1.Show();
	out2.Show();
	out3.Show();
	out4.Show();
	out5.Show();
	out6.Show();
	out7.Show();
	out9.Show();
}

void CMainMenuWnd::Init(CCWN_CON * parent)
{
	CCWN_CON::Init(parent);
	SetTitle("主菜单");
	out0.SetAttr(this,0,0,10);
	out0.SetText("1.销货收银");
	out1.SetAttr(this,0,10,10);
	out1.SetText("2.数据传送");
	out2.SetAttr(this,1,0,10);
	out2.SetText("3.主管作业");
	out3.SetAttr(this,1,10,10);
	out3.SetText("4.参数维护");
	out4.SetAttr(this,2,0,10);
	out4.SetText("5.报表打印");
    out5.SetAttr(this,2,10,10);
	out5.SetText("6.换班作业"); 
	out6.SetAttr(this,3,0,10);
	out6.SetText("7.资料维护");
    out7.SetAttr(this,3,10,10);
	out7.SetText("8.IC卡维护");
	
	out9.SetAttr(this,4,10,10);
	out9.SetText("0. 退 出");
	
}

int CMainMenuWnd::WndProcess(void)
{
	char tmpstr[2];
	int ret=0;
	char tmpbuf[21];
	char tmpbuf1[21];
	char tmpcarid[101];
	char tmpA[101];
	XHSYWIN * xhsy;
	CLogin * login;
	CPosReport *posreport;
	CDataproWnd * dataprownd;
	CParaMenuWnd * paramenu;
	CDocMenuWnd * docmenu;
	CDirectorWnd * director;
	MsgBox *msgbox;
	
	memset(tmpbuf,'\0',sizeof(tmpbuf));
	memset(tmpbuf1,'\0',sizeof(tmpbuf1));
	memset(tmpA,'\0',sizeof(tmpA));
	memset(tmpcarid,'\0',sizeof(tmpcarid));
	memset(tmpstr,'\0',2);

	
	
	while (true)
	{
	     ret=keyboard.GetChar();
	     if(ret == 0)
		     continue;
		 switch (ret)
		  { 
		  case ACT_ESC :
		  case ACT_0:	
				msgbox=new MsgBox(this,"主菜单 ","提示信息","真的要结束?","");
				if(msgbox->WndProcess())
				{ 
				   delete msgbox;
				   return 0;
				}
				delete msgbox;
				break;
		  case ACT_1:
				xhsy= new XHSYWIN();
		        xhsy->Init(this);
		        xhsy->Show();
		        xhsy->WndProcess();
				xhsy->CloseWn();
		        delete xhsy;
		        break;
		  case ACT_2:
				dataprownd=new CDataproWnd(" ");
				dataprownd->Init(this);
				dataprownd->Show();
				dataprownd->WndProcess();
                delete dataprownd;
				break;
		  case ACT_3:
				director=new CDirectorWnd(" ");
				director->Init(this);
				director->Show();
				director->WndProcess();
                delete director;
				break;	
	   	   case ACT_4:
				 paramenu=new CParaMenuWnd();
				 paramenu->Init(this);
				 paramenu->Show();
				 paramenu->WndProcess();
				 delete paramenu;
				 paramenu=NULL;
				 break; 
            case ACT_5:
			 	 posreport=new CPosReport();
				 posreport->Init(this);
				 posreport->Show();
				 posreport->WndProcess();
				 delete posreport;
				 break;				
			case ACT_6:
				msgbox=new MsgBox(this,"  ","提示信息","确定换班作业??"," ");
				if(msgbox->WndProcess()==0)
				{ 
				   delete msgbox;
				   break;
				}
				delete msgbox;
				 login=new CLogin();
				 login->SetLogInType(1);
				 login->Init(this);
				 login->Show();
				 if(login->WndProcess()!=1)
				 {
					delete login;
					return 0;
				 }
				 delete login;
				 break;
			  case ACT_7:
			   	   docmenu =new CDocMenuWnd();
				   docmenu->Init(this);
				   docmenu->Show();
				   docmenu->WndProcess();
				   delete docmenu;
			        break;
			   case ACT_8:
					 ICCardAction();
		            break;
			
			}
		 }
	return 1;
}

void CMainMenuWnd::TestICCard(void)
{
   CGetInWnd * getinwnd;
   int retv;
   getinwnd =new CGetInWnd(this," ","1.读卡 2.写卡","3.读有效 4.写有效 ","5.消费  6.退款");
   retv=getinwnd->WndProcess();
   delete getinwnd;
   switch (retv)
   	{
   	  case 1:
	  	ReadCard();
	    break;
	  case 2:
	  	WriteCard();
		break;
	  case 3:
	  	ReadData1();
		break;
	  case 4:
	  	WriteData1();
		break;	
	 case 5:
	 	SaleAmt();
		break;
	 case 6:
	 	ReturnAmt();
	    break;	
		
   	}
   
}

void CMainMenuWnd::ICCardAction(void)
{
   CGetInWnd * getinwnd;
   int retv;
   CIcWnd* cic;
   CIcOpenWnd* cicopenwnd;
   CIcChangeWnd* cicchangewnd;
   CIcListWnd* ciclistwnd;
   CIcReturnWnd* cicreturnwnd;
	
   getinwnd =new CGetInWnd(this," ","1.IC卡换卡2.IC卡开卡","3.IC卡信息4.IC卡退卡","5.IC卡签卡");
   retv=getinwnd->WndProcess();
   delete getinwnd;
   switch (retv)
   	{
   	  case 1:
	  	cicchangewnd = new CIcChangeWnd();				
		cicchangewnd->Init(this);
		cicchangewnd->WndProcess();
		delete cicchangewnd;
	    break;
	  case 2:
	  	cicopenwnd = new CIcOpenWnd();
		cicopenwnd->Init(this);
		cicopenwnd->WndProcess();
		delete cicopenwnd;
		break;
	  case 3:
	  	ciclistwnd = new CIcListWnd();
		ciclistwnd->Init(this);
		ciclistwnd->WndProcess();
		delete ciclistwnd;
		break;
	  case 4:
	    cicreturnwnd = new CIcReturnWnd();
		cicreturnwnd->Init(this);
		cicreturnwnd->WndProcess();
		delete cicreturnwnd;
		break;	
	 case 5:
	 	cic = new CIcWnd();
		cic->Init(this);
		cic->WndProcess();
		delete cic;
		break;
		
   	}
   
}




void CMainMenuWnd::ReadCard(void)
{
   IC4442Card  * iccard;
   MsgBox * msgbox;
   unsigned char buffer[101];
   char tmpbuf[101];
   int offset=100;
   iccard=new IC4442Card();
   
   if (iccard!=NULL)
   {   
     iccard->Init( );
	 if ( iccard->ReadICCard0(offset,20,buffer)==0)
	 {
	   memset(tmpbuf,'\0',sizeof(tmpbuf));
	   memcpy(tmpbuf,buffer,20);
	   msgbox=new MsgBox(this,"  ","readICCard","",tmpbuf," ");
	   msgbox->WndProcess();
	  delete msgbox;
	 }
   }
}
void CMainMenuWnd::WriteCard(void)
{
   IC4442Card  * iccard;
   MsgBox * msgbox;
   unsigned char buffer[101];
   char tmpbuf[101];
   int offset=100;
   memset(tmpbuf,'\0',sizeof(buffer));
   sprintf(tmpbuf,"%s","12345678909876543210");

   iccard=new IC4442Card();
   //int ret;
   if (iccard!=NULL)
   {   
     iccard->Init();
	  memset(buffer,'\0',sizeof(buffer));
	  memcpy(buffer,tmpbuf,20);
	 if (iccard->WriteICCard1(this,offset,20,buffer)!=0)
	 {
	     msgbox=new MsgBox(this,"  ","WriteCard","失败 ");
	   msgbox->WndProcess();
	  delete msgbox;
	 }
	delete iccard;
   	}
   	
}

void CMainMenuWnd::ReadData1(void)
{
   IC4442Card  * iccard;
   MsgBox * msgbox;
   MsgInput * msginput;
   char tmpstr[101];
   int  tmpoffset;
   int  tmpLen;
   int i;
   //char tmpAA[2];
   int tmpr=0;
   unsigned char databuf[101];
   
   memset(tmpstr,'\0',sizeof(tmpstr));
   msginput=new MsgInput(this,"","偏移量"," ","最大220"," ",tmpstr);
   tmpr=msginput->WndProcess();
   delete msginput;
   if (tmpr==0)
	 return ;
   if (tmpstr==NULL || tmpstr[0]=='\0' || strlen(tmpstr)==0)
	 return ;
   

   tmpoffset=atoi(tmpstr);

   memset(tmpstr,'\0',sizeof(tmpstr));
   msginput=new MsgInput(this,"","读取字符"," ","最大220"," ",tmpstr);
   tmpr=msginput->WndProcess();
   delete msginput;
   if (tmpr==0)
	 return ;
   if (tmpstr==NULL || tmpstr[0]=='\0' || strlen(tmpstr)==0)
	 return ;

   tmpLen=atoi(tmpstr);
   memset(databuf,'\0',sizeof(databuf));
   iccard=new IC4442Card();
   //int ret;
   if (iccard!=NULL)
   {   
     iccard->Init( );
	if ( iccard->ReadICCard1(this,tmpoffset,tmpLen,databuf)==0)
	{

      memset(tmpstr,'\0',sizeof(tmpstr));
	  for (i=0;i<tmpLen;i++)
	  {
	    // CGlobal::UnChar2Chars(databuf[i],tmpAA);
		// tmpstr[i*2]=tmpAA[0];
		// tmpstr[i*2+1]=tmpAA[1];
		sprintf(tmpstr,"%s",(unsigned char *)databuf);
         		 
	  }
	  
	  msgbox=new MsgBox(this,"  ","ReadIC ","",tmpstr," ");
	  msgbox->WndProcess();
	 delete msgbox;
	}
	delete iccard;
   	}
     	
}

void CMainMenuWnd::WriteData1(void)
{
   IC4442Card  * iccard;
 //  MsgBox * msgbox;
   MsgInput * msginput;
   char tmpstr[101];
   int  tmpoffset;
   char tmpbuf[101];
   int  tmpLen;
   unsigned char databuf[101];
   int tmpr=0;
   memset(tmpstr,'\0',sizeof(tmpstr));
   msginput=new MsgInput(this,"","偏移量"," ","最大220"," ",tmpstr);
   tmpr=msginput->WndProcess();
   delete msginput;
   if (tmpr==0)
	 return ;
   if (tmpstr==NULL || tmpstr[0]=='\0' || strlen(tmpstr)==0)
	 return ;
   

   tmpoffset=atoi(tmpstr);

   memset(tmpstr,'\0',sizeof(tmpstr));
   msginput=new MsgInput(this,"","写入字符"," ","最大220"," ",tmpstr);
   tmpr=msginput->WndProcess();
   delete msginput;
   if (tmpr==0)
	 return ;
   if (tmpstr==NULL || tmpstr[0]=='\0' || strlen(tmpstr)==0)
	 return ;

   memset(tmpbuf,'\0',sizeof(tmpbuf));
   sprintf(tmpbuf,"%s",tmpstr);
   tmpLen=strlen(tmpbuf);
   memset(databuf,'\0',sizeof(databuf));
   memcpy(databuf,tmpbuf,tmpLen);
   	
   iccard=new IC4442Card();
   
   if (iccard!=NULL)
   {   
     iccard->Init( );
	 iccard->WriteICCard1(this,tmpoffset,tmpLen,databuf);
	
	delete iccard;
   	}
   	
}

void CMainMenuWnd::SaleAmt(void)
{
  /*
  MsgBox * msgbox;
  IC4442Card  * iccard;
   char tmpstr[101];
   char tmpIC[21];
   char tmpAmt[21];
   memset(tmpstr,'\0',sizeof(tmpstr));
   memset(tmpIC,'\0',sizeof(tmpIC));
   memset(tmpAmt,'\0',sizeof(tmpAmt));
   
 
   iccard=new IC4442Card();
   
   if (iccard!=NULL)
   {   
     iccard->Init( );
	 for (int i=0;i<20;i++)
	{
	 if ( iccard->ICSaleAmt(this,100,tmpIC,tmpstr,tmpAmt)==false)
	 {
	     msgbox=new MsgBox(this,"  ","ReadIC ","",tmpstr," ");
	     msgbox->WndProcess();
	     delete msgbox;
		 break;
	 } 
	 else
	 {
	     sprintf(tmpstr,"剩余:%.2f",atof(tmpAmt));
	     printer.FormatedPrint( tmpstr, 2 );
		 delay(100);
	 }
	 }	
	delete iccard;
   	}
   	*/
}

void CMainMenuWnd::ReturnAmt(void)
{
/*
    Pzip * pzip;
	char tmpstr0[101];
	char tmpstr1[101];
	ffms_disk_create("POSTMP",100000);
	if (ffms_mount("POSTMP")<=0)
	{
	   msgbox=new MsgBox(this,"  ","创建磁盘失败","POSTMP",," ");
	   msgbox->WndProcess();
	   delete msgbox;
	   return ;
	}

	memset(tmpstr0,'\0',sizeof(tmpstr0));
	memset(tmpstr1,'\0',sizeof(tmpstr1));
	
	pzip=new Pzip();
	if (pzip!=NULL)
	{ 
	   pzip->Compress()
	}
	*/
/*
	   IC4442Card	* iccard;
	   MsgBox * msgbox;
	   char tmpstr[101];
	   char tmpIC[21];
	   char tmpAmt[21];
	//   unsigned char databuf[101];
//	   int tmpr=0;
	   memset(tmpstr,'\0',sizeof(tmpstr));
	   memset(tmpIC,'\0',sizeof(tmpIC));
	   memset(tmpAmt,'\0',sizeof(tmpAmt));
	   
	 
	   iccard=new IC4442Card();
	   
	   if (iccard!=NULL)
	   {   
		 iccard->Init( );
		 for (int i=0;i<20;i++)
		{
		 if ( iccard->ICReturnAmt(this,100,tmpIC,tmpstr,tmpAmt)==false)
		 {
			 msgbox=new MsgBox(this,"  ","ReadIC ","",tmpstr," ");
			 msgbox->WndProcess();
			 delete msgbox;
			 break;
		 } 
		 else
		 {
			 sprintf(tmpstr,"剩余:%.2f",atof(tmpAmt));
			 printer.FormatedPrint( tmpstr, 2 );
			 delay(100);
		 }
		 }	
		delete iccard;
		}
	*/	

}




⌨️ 快捷键说明

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