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

📄 functionlib.c

📁 linux环境下结合ncurse库
💻 C
📖 第 1 页 / 共 5 页
字号:
	{
		return 1; // 不匹配
	}
}


/********************************************
	Function:挂单模块
	param:
	return:
void List_Up(C_CLASS LINKLIST * pplink)
*********************************************/
void List_Up(C_CLASS LINKLIST ** pplink,char * str)
{
	
		if (listarr[0]==NULL)
		{
			listarr[0]=*pplink;
			//savesaleid_arr[3][19]
			strcpy(savesaleid_arr[0],str);
		}else if (listarr[1]==NULL)
		{
			listarr[1]=*pplink;
			strcpy(savesaleid_arr[1],str);
		}else
		{
			listarr[2]=*pplink;
			strcpy(savesaleid_arr[2],str);
		}
		*pplink=(C_CLASS LINKLIST *)malloc(sizeof(C_CLASS LINKLIST));
		link_init(*pplink);
}


/**********************************************************
 Function:挂单模块
  Param:无
  return :无
***********************************************************/
void List_Del()
{
	scr_dump("SaveScr.scr");
	// 主窗口
	MyWindow * pListDel=NULL;
	pListDel=MakeMyWindow(pListDel);
	pListDel->m_color=WHITE_BLUE;
	pListDel->m_sizex=32; // 30
	pListDel->m_sizey=15; // 12
	pListDel->m_px=25;
	pListDel->m_py=7;
	ChangeMyWindow(&pListDel);
	int sizex=pListDel->m_sizex;
	int sizey=pListDel->m_sizey;
	DrawWords(pListDel,1,(sizex-strlen("撤单"))/2,"撤单");
	// 画画
	DrawHline(pListDel,2,1);
	//返回按扭
	Button * pButton2=NULL;
	pButton2=MakeButton(pButton2);
	strcpy(pButton2->m_name,"返回");
	pButton2->m_buttonid=BUTTONID+10;
	pButton2->m_kind=NOBUTTON;
	pButton2->m_color_foot=WHITE_BLUE;
	pButton2->m_sizey=3;
	pButton2->ChangeButton(&pButton2);

	int i=0;
	while (listarr[i]!=NULL &&i<3)
	{
		Button * pButton=NULL;
		pButton=MakeButton(pButton);
		strcpy(pButton->m_name,savesaleid_arr[i]);
		pButton->m_buttonid=BUTTONID+1+i;
		pButton->m_kind=NOBUTTON;
		pButton->m_isbox=FALSE;
		pButton->m_color_foot=WHITE_BLUE;
		pButton->m_sizey=1;
		pButton->m_sizex=20;
		pButton->ChangeButton(&pButton);
		pListDel->AddActiveElement(pListDel,pButton,ISBUTTON,3+2*i,5);
		i++;
	}

	pListDel->AddActiveElement(pListDel,pButton2,ISBUTTON,10,10);
	ShowMyWindow(pListDel);
	int res=RunMyWindow(pListDel);
	if (BUTTONID+1==res) // 撤0 单
	{
		link_del(listarr[0]);
		listarr[0]=listarr[1];
		listarr[1]=listarr[2];
		listarr[2]=NULL;
	}else if (BUTTONID+2==res) // 撤1单
	{
		link_del(listarr[1]);
		listarr[1]=listarr[2];
		listarr[2]=NULL;
	}
	else  if (BUTTONID+3==res)// 撤2单
	{
		link_del(listarr[2]);
		listarr[2]=NULL;
	}
	DelMyWindow(pListDel);
	scr_restore("SaveScr.scr");
}
/**********************************************************
Function:取单模块
Param:无
return :无
***********************************************************/
void List_Down(C_CLASS LINKLIST ** pplink)
{
	scr_dump("SaveScr.scr");
	// 主窗口
	MyWindow * pListdown=NULL;
	pListdown=MakeMyWindow(pListdown);
	pListdown->m_color=WHITE_BLUE;
	pListdown->m_sizex=32; // 30
	pListdown->m_sizey=15; // 12
	pListdown->m_px=25;
	pListdown->m_py=7;
	ChangeMyWindow(&pListdown);
	int sizex=pListdown->m_sizex;
	int sizey=pListdown->m_sizey;
	DrawWords(pListdown,1,(sizex-strlen("取单"))/2,"取单");

	// 画画
	DrawHline(pListdown,2,1);

	//返回按扭
	Button * pButton2=NULL;
	pButton2=MakeButton(pButton2);
	strcpy(pButton2->m_name,"返回");
	pButton2->m_buttonid=BUTTONID+10;
	pButton2->m_kind=NOBUTTON;
	pButton2->m_color_foot=WHITE_BLUE;
	pButton2->m_sizey=3;
	pButton2->ChangeButton(&pButton2);
	int i=0;
	while (listarr[i]!=NULL &&i<3)
	{
		Button * pButton=NULL;
		pButton=MakeButton(pButton);
		strcpy(pButton->m_name,savesaleid_arr[i]);
		pButton->m_buttonid=BUTTONID+1+i;
		pButton->m_kind=NOBUTTON;
		pButton->m_isbox=FALSE;
		pButton->m_color_foot=WHITE_BLUE;
		pButton->m_sizey=1;
		pButton->m_sizex=20;
		pButton->ChangeButton(&pButton);
		pListdown->AddActiveElement(pListdown,pButton,ISBUTTON,3+2*i,5);
		i++;
	}

	pListdown->AddActiveElement(pListdown,pButton2,ISBUTTON,10,10);
	ShowMyWindow(pListdown);
	int res=RunMyWindow(pListdown);
	if (BUTTONID+1==res)
	{
		*pplink=listarr[0];
		listarr[0]=listarr[1];
		listarr[1]=listarr[2];
		listarr[2]=NULL;
	}else if (BUTTONID+2==res)
	{
		*pplink=listarr[1];
		listarr[1]=listarr[2];
		listarr[2]=NULL;
	}
	else if(BUTTONID+3==res)
	{
		*pplink=listarr[2];
		listarr[2]=NULL;
	}
	DelMyWindow(pListdown);
	scr_restore("SaveScr.scr");
}

/**********************************************************
 Function:退货模块
  Param:无
  return :无
***********************************************************/
void ReturnWindow()
{
	scr_dump("SaveScr3.scr");
	MyWindow * pReturnWindow=NULL;
	pReturnWindow=MakeMyWindow(pReturnWindow);
	pReturnWindow->m_px=24;
	pReturnWindow->m_py=7;
	pReturnWindow->m_sizex=40;
	pReturnWindow->m_sizey=11;
	pReturnWindow->m_color=WHITE_BLUE;
	pReturnWindow->ChangeMyWindow(&pReturnWindow);

	// 下列函数均测试成功
	pReturnWindow->DrawWords(pReturnWindow,0,18,"退货");
	pReturnWindow->DrawWords(pReturnWindow,2,1,"销售单号:");
	pReturnWindow->DrawWords(pReturnWindow,4,3,"条形码:");
	pReturnWindow->ShowMyWindow(pReturnWindow);
	
	// 销售ID
	TextBox * pUserText=NULL;
	pUserText=MakeTextBox(pUserText);
	pUserText->m_strmaxlen=18;
	pUserText->m_spc.s_sizex=20;
	//pUserText->m_strminlen=18;
	pUserText->m_isInteger=TRUE;
	pUserText->m_isPasswd=FALSE;
	pUserText->m_isFn2_9=FALSE;
	ChangeTextBox(&pUserText);

	// 条形码
	TextBox * pPasswdText=NULL;
	pPasswdText=MakeTextBox(pPasswdText);
	pPasswdText->m_strmaxlen=6;
	strcpy(pPasswdText->m_title,"CN");
	pPasswdText->m_isInteger=TRUE;
	pPasswdText->m_isPasswd=FALSE;
	pPasswdText->m_isFn2_9=FALSE;
	ChangeTextBox(&pPasswdText);

	
	//确定按妞
	Button * pButton1=NULL;
	pButton1=MakeButton(pButton1);
	strcpy(pButton1->m_name,"确定");
	pButton1->m_color_foot=WHITE_BLUE;
	pButton1->m_kind=YESBUTTON;
	pButton1->m_buttonid=BUTTONID+1;
	pButton1->ChangeButton(&pButton1);
	
	// 取消按妞
	Button * pButton2=NULL;
	pButton2=MakeButton(pButton2);
	strcpy(pButton2->m_name,"取消");
	pButton2->m_color_foot=WHITE_BLUE;
	pButton2->m_buttonid=BUTTONID+2;
	pButton2->m_kind=NOBUTTON;
	pButton2->ChangeButton(&pButton2);

	pReturnWindow->AddActiveElement(pReturnWindow,pUserText,ISTEXT,2,12);
	pReturnWindow->AddActiveElement(pReturnWindow,pPasswdText,ISTEXT,4,12);
	pReturnWindow->AddActiveElement(pReturnWindow,pButton1,ISBUTTON,6,4);
	pReturnWindow->AddActiveElement(pReturnWindow,pButton2,ISBUTTON,6,18);
	ShowMyWindow(pReturnWindow);
	
	do
	{
		int res=RunMyWindow(pReturnWindow);
		if (res==BUTTONID+1)
		{
			// 按了确定
			// 相关数据库操作
			// 和条形码
			// 相关提示
			char codestr[9];
			codestr[0]='C';
			codestr[1]='N';
			strncpy(&codestr[2],pPasswdText->m_str,6);
			codestr[8]='\0';
			float how=0;

			int res=SelectSaleDetail(pUserText->m_str,codestr,&how);
			
			if (1==res)
			{
				char temp1[10];memset(temp1,0,10);
				sprintf(temp1,"退钱:%f",how);
				MessageBox(temp1,"请按任意键返回",NOBTN);
				break;
			}
			else
			{
				MessageBox("没有找到相关的信息","请按任意键返回",NOBTN);

			}
		}
		else
		{
			// 按了取消
			// 不做任何处理 
			break;
		}
}while (1);
	DelMyWindow(pReturnWindow);
	scr_restore("SaveScr3.scr");

	
}

/*退货函数*/
void ReturnGoods()
{
	StaffInfo staffinfo;
	int res=MgrLoginWin(&staffinfo);
	if (1==res)
	{
		ReturnWindow();
	}
	else
	{
	}

}

/************************************************************
	Function:总述模块
	Param: 无
	return : 无
*************************************************************/
void MainView(StaffInfo staff)
{
	box(stdscr,0,0);
	//***** 表示要从数据库中提起数据
	mvwprintw(stdscr,0,32,"欢迎光临XXX超市");
	mvprintw(1,1,"收银员:");
	mvprintw(1,8,"%s",staff.staff_name);
	mvprintw(1,18,"等级:普通收银员");
	//mvprintw(1,24,"%d",staff.staff_type);


		char tranid[6];
		char TimeStr[15];

		GetTradeID(tranid);
		MoveRightSpace(tranid);
		mvprintw(1,34,"交易号:****");
		mvprintw(1,41,"%s",tranid);
		refresh();

	mvhline(2,1,ACS_S3,78);
	mvprintw(3,1,"序号");
	mvprintw(3,7,"条形码");
	mvprintw(3,17,"商品名称");
	mvprintw(3,43,"规格");
	mvprintw(3,49,"单位");
	mvprintw(3,56,"单价");
	mvprintw(3,65,"数量");
	mvprintw(3,73,"金额");
	mvhline(4,1,ACS_S3,78);
	
	mvhline(20,1,ACS_S3,78);
	mvprintw(21,1,"条形码:");
	mvprintw(21,48,"销售状态:正常");
	mvhline(22,1,ACS_S3,78);

	mvprintw(23,1,"F2:新增明细");
	mvprintw(23,13,"F3:删除明细");
	mvprintw(23,25,"F4:收银");
	mvprintw(23,33,"F5:挂单");
	mvprintw(23,42,"F6:取单");
	mvprintw(23,51,"F7:撤单");
	mvprintw(23,60,"F8:退货");
	mvprintw(23,69,"F9:退出");
	refresh();
	WINDOW * pNewWin=newwin(15,78,5,1);
	wrefresh(pNewWin);
	
	TextBox * pBarCodeText=NULL;
	pBarCodeText=MakeTextBox(pBarCodeText);
	pBarCodeText->m_spc.s_py=21;
	pBarCodeText->m_spc.s_px=9;
	strcpy(pBarCodeText->m_title,"CN");
	pBarCodeText->m_strmaxlen=6;
	pBarCodeText->m_isInteger=TRUE;
	pBarCodeText->m_isPasswd=FALSE;
	pBarCodeText->m_isFn2_9=TRUE;
	ChangeTextBox(&pBarCodeText);

	int keyres=0;
	int flag=0;
	char Bar_Code[9];
	memset(Bar_Code,0,9);
	Bar_Code[0]='C';
	Bar_Code[1]='N';
	
	
	C_CLASS LINKLIST * plink=(C_CLASS LINKLIST *)malloc(sizeof(C_CLASS LINKLIST));
	link_init(plink);
	int current=0;
	int beginsub=0;
	do
	{
		// 时间一直变化着
		mvprintw(1,49,"时间:**************");
		GetTime(TimeStr);
		mvprintw(1,54,"%s",TimeStr);
		refresh();

		flag=0;
		keyres=pBarCodeText->InputString(pBarCodeText);
		switch(keyres)
		{	
			case 10:
			{
				//ShowDetail(pNewWin,&link,keyres);
				int searchres=-1;
				Goods goods;
				SellGoods sellgoods;
				strncpy(&Bar_Code[2],pBarCodeText->m_str,6);
				// 在数据库中查找此商品信息
				searchres=GetGoodsByBarCode(&goods,Bar_Code);
				if(0==searchres)
				{// 没有找到
					MessageBox("输入的条形码商品不存在","任意键返回",NOBTN);
					
				}else if(-1==searchres)
				{   // 错误
					MessageBox("在数据库中查找错误","任意键返回",NOBTN);
				}else // 找到
				{	
					// 找到相关信息格式处理
					MoveGoodsSpace(&goods);
					
					DUNODE * pnode=NULL;
					// 在已购的链表中查找信息
					pnode=link_get_node_by_key(plink,goods.bar_code,CmpBarCode);
					
					// 没有找到 加一个插入链表,称为此次购买的新商品
					if(NULL==pnode)
					{
						strcpy(sellgoods.bar_code,goods.bar_code);
						strcpy(sellgoods.product_name,goods.product_name);
						strcpy(sellgoods.spec,goods.spec);
						strcpy(sellgoods.unit,goods.unit);
						sellgoods.sale_price=(goods.sale_price)*(goods.discount);
						sellgoods.product_count=1;
						sellgoods.sum_money=(goods.sale_price)*(goods.discount);
						sellgoods.discount=goods.discount;

						link_insert_rear(plink,&sellgoods,sizeof(Goods));
						current=plink->count;
						if(plink->count>15)
						{
							beginsub=plink->count-14;
							PrintLinkInfo(plink,pNewWin,beginsub,current);
						}
						else
						{
							beginsub=1;
							PrintLinkInfo(plink,pNewWin,1,current);
						}
					}
					else
					{
						//  如果找到在此商品数量 和金额相继加上去
						int j=0;
						((SellGoods *)(pnode->data))->product_count++;
						j=((SellGoods *)(pnode->data))->product_count;
						((SellGoods *)(pnode->data))->sum_money
							=j*( ( (  (SellGoods *)(pnode->data)  )->sale_price) );
						current=link_get_index_by_key(plink,goods.bar_code,CmpBarCode);
						if(plink->count>15)
						{
							if (current<=15)
							{
								beginsub=1;
								PrintLinkInfo(plink,pNewWin,beginsub,current);
							}
							else
							{
								beginsub=current-14;
								PrintLinkInfo(plink,pNewWin,beginsub,current);
							}
						}	
						else
						{
							beginsub=1;
							PrintLinkInfo(plink,pNewWin,beginsub,current);
						}
					}	
				}		
			}	
			break;
			case KEY_UP:
			{
				if(current>1)
				{
					current--;
					if(current<beginsub)
					{
						beginsub--;
					}
					PrintLinkInfo(plink,pNewWin,beginsub,current);
					mvprintw(24,3,"[b=%d  v=%d]",beginsub,current);
					refresh();
				}

			}break;
			case KEY_DOWN:
			{
				if(current<plink->count)
				{
					current++;
					if(current>beginsub+14)
					{
						beginsub++;
					}
					PrintLinkInfo(plink,pNewWin,beginsub,current);
					//mvprintw(24,3,"[b=%d  v=%d]",beginsub,current);
					refresh();
				}
			}break;
			case KEY_F(2):

⌨️ 快捷键说明

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