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

📄 possystem.c

📁 在linux平台下模拟超市的收银系统即POS机
💻 C
📖 第 1 页 / 共 3 页
字号:
			LeaveButtonWindow(YesButton,RED_BLACK);
			result=0;//选择yes的时候返回0
			goto exit;
		}
		
	}
	
NoButton:
	while(1)
	{
		IntoButtonWindow(NoButton,WHITE_RED);
		ch=wgetch(NoButton);
		switch(ch)
		{
		case KEY_LEFT:
		case KEY_UP:
			LeaveButtonWindow(NoButton,RED_BLACK);
			//IntoButtonWindow(okButton,WHITE_RED);
			goto YesButton;
			break;
		case '\n':
			LeaveButtonWindow(NoButton,RED_BLACK);
			result=1;//选择NO是选加1
			goto exit;
			break;
		}
		
	}
}
exit:
	
	//int ch=wgetch(win);
	DestroyWindow(win);
	DestroyWindow(Sell_Odd_NumbersWin);//删掉销售单号窗口
	DestroyWindow(BarCodeWin);//删掉条形码窗口
	DestroyWindow(YesButton);
	DestroyWindow(NoButton);
	scr_restore("save1.scr");
	refresh();
	return result;//返回选择的值,如确定就是0,返回就是1
}

//创建消息提示框只有 yes no
int DialogWindow(int hight,int width,int startY,int startX,char * message,enum Colore_Index coloreIndex)
{
	int result=0;//返回的值
	int ch;
	scr_dump("save1.scr");
	WINDOW * dialog=CreateWindow(hight,width,startY,startX,Yes,coloreIndex);
	StringCenterPrint(dialog,1,"提示");
	printhline(dialog,2,1,width-2);//画水平线
	StringCenterPrint(dialog,3,message);

	WINDOW * YesButton=CreateButtonWindow(startY+hight-2,startX+width/2-9,No,RED_BLACK,"是");
	WINDOW * NoButton=CreateButtonWindow(startY+hight-2,startX+width/2+2,No,RED_BLACK,"否");
	while(1)
	{
YesButton:
		while(1)
		{
			IntoButtonWindow(YesButton,WHITE_RED);
			ch=wgetch(YesButton);
			switch(ch)
			{
				case KEY_DOWN:
				case KEY_RIGHT:
					LeaveButtonWindow(YesButton,RED_BLACK);
					goto NoButton;
					break;
				case '\n':
					LeaveButtonWindow(YesButton,RED_BLACK);
					result=0;//选择yes的时候返回0
					goto exit;
			}
			
		}

NoButton:
		while(1)
		{
			IntoButtonWindow(NoButton,WHITE_RED);
			ch=wgetch(NoButton);
			switch(ch)
			{
				case KEY_LEFT:
				case KEY_UP:
					LeaveButtonWindow(NoButton,RED_BLACK);
					//IntoButtonWindow(okButton,WHITE_RED);
					goto YesButton;
					break;
				case '\n':
					LeaveButtonWindow(NoButton,RED_BLACK);
					result=1;//选择NO是选加1
					goto exit;
					break;
			}
			
		}
	}	//printhline(win,hight)
exit:
	DestroyWindow(dialog);
	DestroyWindow(YesButton);
	DestroyWindow(NoButton);
	scr_restore("save1.scr");
	//refresh();
	return result;//返回选择的值,如确定就是0,返回就是1
}


int main()
{
	initscr();
	cbreak();//关闭预处理
	noecho();//关掉回显
	//nocbreak();//开启预处理机制
	start_color();//启动color机制
	init_pair(WHITE_BLACK,COLOR_BLACK,COLOR_WHITE);//白底黑字
	init_pair(BLACK_WHITE,COLOR_WHITE,COLOR_BLACK);//黑底白字
	init_pair(BLUE_WHITE,COLOR_WHITE,COLOR_BLUE);//蓝底白字
	init_pair(RED_WHITE,COLOR_WHITE,COLOR_RED);//红底白字
	init_pair(WHITE_RED,COLOR_RED,COLOR_WHITE);//白底红字
	init_pair(RED_BLACK,COLOR_BLACK,COLOR_RED);//红底黑字

	refresh();
	int result;
	int seque;//存放序列
	/*//测试获最系统时间函数
	{
		char * p=(char *)malloc(15);
		GetSystemTime(p);
		mvwprintw(login_win,1,1,p);
		wrefresh(login_win);
		free(p);
	}
	*/
	
	
	//测试接收配制文件
	int size=10,alreadyRead;
	struct configInfo * config=(struct configInfo *)malloc(sizeof(struct configInfo)*size);
	
	//WINDOW * login_win=CreateWindow(10,50,0,0,Yes,WHITE_BLACK);

	//取出配制信息
	ReadConfigInfo(config,size,&alreadyRead);

	
	result=db_connection(config[0].value,config[1].value);
	if(result!=0)
	{
		Message_Box(8,30,5,20,RED_BLACK,"提示","连接数据失败");
		endwin();
		return 0;
	}
	
	char id[20]={'\0'}; //存放登入用户的id
	//生成序列
	/*
	seque=Get_Data_Seque();//生成序列
	printw("%d",seque);
	*/

	//测试插入语句
//插入到销售明细表
// 	char * name=(char *)malloc(100);
// 	//char name[100]={'\0'};
// 	Get_Staff_Name("000001",name);
// 	printw(name);
// 	refresh();
// 	//Insert_To_Sale_Detail("200801010101010001","200710071809340397","CN000001",10,1.5,1);
// 	getch();

	while(1)
	{	//登入窗口
  		result=CreateLoginWindow(25,80,0,0);
 		//当result为1的时候进入后台管理界面,为2时进入结帐窗口

  		if(result==1)
  		{
 			BackgroundManager();
  		}
 		else if(result==2)
 		{
			CreatePosReckoningWindow();
 		}
		else if(result==0)
		{
			break;
		}
	}
	//测试结帐窗口
	//CreatePosReckoningWindow();
	//GetBill(10,10);


	//滚屏
	//GetRollBill(10,10);

	//CommoditySearchWin();

	//后台管理窗口
	//BackgroundManager();
	//商口管理窗口
	//CommodityManager();
	//BackgroundManagerWin();
	//CommodityManagerWin();
	//AddCommodityManagerWin();
	//ModifyCommodityWin();

	//添加帐户窗口
	//AccountManager();
 	//AccountManagerWin();
 	//AddAccountWin();
 	//ModifyAccountWin();

	//销售窗口
	//VenditionManagerWin();

	//VenditionManager();
	//销售日期查询窗口
	//SearchVenditionByAccountIDWin();
	//SearchVenditionByDateWin();
	//printw("asdfasdfa");
	//getch();

	endwin();
	

	return 0;
}




































/*

//退货窗口
int ReturningAProductWin(int startY,int startX)
{
	scr_dump("save.scr");
	int ReckoningWindowHight=11;
	int ReckoningWindowWidth=52;
	int ch,result;
	char sellNumber[20]={'\0'};//销售单号
	char barcode[10]="CN";//条形码
	char amounts[5]={'\0'};//数量
	WINDOW *win=CreateWindow(ReckoningWindowHight,ReckoningWindowWidth,startY,startX,Yes,RED_BLACK);	
	StringCenterPrint(win,1,"退货");

	printhline(win,2,1,ReckoningWindowWidth-2);//画水平线
	mvwprintw(win,3,2,"销售单号:");
	// 销售单号窗口
	WINDOW * Sell_Odd_NumbersWin=CreateWindow(1,30,startY+3,startX+11,No,WHITE_BLACK);
	printhline(win,4,1,ReckoningWindowWidth-2);//画水平线
	mvwprintw(win,5,4,"条形码:");
	//条形码窗口
	WINDOW * BarCodeWin=CreateWindow(1,30,startY+5,startX+11,No,WHITE_BLACK);
	mvwprintw(BarCodeWin,0,0,barcode);
	wrefresh(BarCodeWin);
	printhline(win,6,1,ReckoningWindowWidth-2);//画水平线
	mvwprintw(win,7,6,"数量:");
	//数量窗口
	WINDOW * AmountWin=CreateWindow(1,10,startY+7,startX+11,No,WHITE_BLACK);
	//StringCenterPrint(win,9,"请按任意键继续收银...");
	wrefresh(win);

	WINDOW * YesButton=CreateButtonWindow(startY+ReckoningWindowHight-2,startX+ReckoningWindowWidth/2-9,No,RED_BLACK,"是");
	WINDOW * NoButton=CreateButtonWindow(startY+ReckoningWindowHight-2,startX+ReckoningWindowWidth/2+2,No,RED_BLACK,"否");
while(1)
{
Sell_Odd_NumbersWin:
	while(1)
	{
		ch=GetString(Sell_Odd_NumbersWin,0,0,sellNumber,19);
		switch (ch)
		{
		case KEY_DOWN:
		case '\n':
			goto BarCodeWin;
			break;
		}
	}
BarCodeWin:
	while(1)
	{
		ch=GetString(BarCodeWin,0,2,&barcode[2],6);
		switch (ch)
		{
		case KEY_UP:
			goto Sell_Odd_NumbersWin;
			break;
		case KEY_DOWN:
		case '\n':
			goto AmountWin;
			break;
		}
	}
AmountWin:
	while(1)
	{
		ch=GetString(AmountWin,0,0,amounts,4);
		switch (ch)
		{
		case KEY_UP:
			goto BarCodeWin;
			break;
		case KEY_DOWN:
		case '\n':
			goto YesButton;
			break;
		}
	}
YesButton:
	while(1)
	{
		IntoButtonWindow(YesButton,WHITE_RED);
		ch=wgetch(YesButton);
		switch(ch)
		{
		case KEY_UP:
			LeaveButtonWindow(YesButton,RED_BLACK);
			goto AmountWin;
			break;
		case KEY_DOWN:
		case KEY_RIGHT:
			LeaveButtonWindow(YesButton,RED_BLACK);
			goto NoButton;
			break;
		case '\n':
			{
				int amount;//用户输入的数量
				int count;
				float sale_price;
				int returnResult;
				amount=atoi(amounts);
				returnResult=Get_Sale_Detail(sellNumber,barcode,&count,&sale_price);
// 				mvwprintw(win,1,5,"count:%d sale_price:%f",count,sale_price);
// 				wrefresh(win);
// 				wgetch(win);
				if(returnResult!=0) //没有查找到相关的退货信息
				{
					Message_Box(10,30,10,10,RED_BLACK,"提示","没有查找到相关的信息");
					break;
				}
				else //查找到相关的退货信息
				{
					if(amount<=count && amount>=1)//退货数量要大于等于1并且小于等于结帐数量
					{
						Modify_Sale_Detail_State(sellNumber,barcode);//修改商品状态

						Modify_Sale_Money(sellNumber,count*sale_price);//修改商品总金额
						ReduceStock(barcode,-amount);//修改库存
					}
					else
					{
						Message_Box(10,50,10,10,RED_BLACK,"提示","退货数量必须小于等于购买数量");
						break;
					}
				}
			}
			LeaveButtonWindow(YesButton,RED_BLACK);
			result=0;//选择yes的时候返回0
			goto exit;
		}
		
	}
	
NoButton:
	while(1)
	{
		IntoButtonWindow(NoButton,WHITE_RED);
		ch=wgetch(NoButton);
		switch(ch)
		{
		case KEY_LEFT:
		case KEY_UP:
			LeaveButtonWindow(NoButton,RED_BLACK);
			//IntoButtonWindow(okButton,WHITE_RED);
			goto YesButton;
			break;
		case '\n':
			LeaveButtonWindow(NoButton,RED_BLACK);
			result=1;//选择NO是选加1
			goto exit;
			break;
		}
		
	}
}
exit:

	//int ch=wgetch(win);
	DestroyWindow(win);
	DestroyWindow(Sell_Odd_NumbersWin);//删掉销售单号窗口
	DestroyWindow(BarCodeWin);//删掉条形码窗口
	DestroyWindow(AmountWin);//删掉数量窗口
	DestroyWindow(YesButton);
	DestroyWindow(NoButton);
	scr_restore("save.scr");
	refresh();
	return result;//返回选择的值,如确定就是0,返回就是1
}
*/

⌨️ 快捷键说明

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