コード例 #1
0
ファイル: Sale1.c プロジェクト: dongmengyuan/linuxc
inline int Sale_UI_SellTicket(ticket_list_t tickList, seat_list_t seatList){
	
	int id;
	ticket_list_t head;
	schedule_t sch;
	
	
    printf("\n		|     请输入演出计划ID:");
			
	while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin();printf("\n		                        **您的输入有误!请重新输入**     ");}
	}
	
	if(!Schedule_Srv_FetchByID(id, &sch)){
			printf("\n		                        **未找到ID『%d』!按任意键返回**     ",id);
			getchar();
			return 0;
	}
	
	Ticket_Srv_FetchBySchID(tickList, sch.id);
			
	Seat_Srv_FetchValidByRoomID(seatList, sch.studio_id);
	
	
	Ticket_UI_ListBySch(&sch,tickList,seatList);
	
	
    return 1;
}
コード例 #2
0
ファイル: Sale_UI.c プロジェクト: Jungzhang/-C-
//根据计划ID,显示演出票
void Sale_UI_ShowTicket(int schID){
	char choice;int i;
	ticket_list_t list;
	ticket_list_t pTemp;
	char status[10];
	play_t play;
	schedule_t sch;
	studio_t stu;
	seat_list_t seat_l;
	seat_t seat;
	Pagination_t paging;

	List_Init(seat_l,seat_node_t);
	List_Init(list,ticket_node_t);
	
	Schedule_Srv_FetchByID(schID, &sch);
	Play_Srv_FetchByID(sch.play_id, &play);
	Studio_Srv_FetchByID(sch.studio_id, &stu);
	Seat_Srv_FetchByRoomID(seat_l,sch.studio_id);
	paging.offset = 0;
	paging.pageSize = 10;
	paging.totalRecords = Ticket_Srv_FetchBySchID(list,schID);
	Paging_Locate_FirstPage(list, paging);
	do{
		system("clear");
	printf("|=============================================================================================================================|\n");
	printf("|-------------------------------------------------------票 信 息 输 出--------------------------------------------------------|\n");
	printf("|-----------------------------------------------------------------------------------------------------------------------------|\n");
                printf("%10s%20s%20s%20s%20s%20s%20s%20s\n","票ID","演出计划ID","剧目名称","演出厅名称","座位ID","座位行列号","票价","座位状态");
	printf("|-----------------------------------------------------------------------------------------------------------------------------|\n");
	Paging_ViewPage_ForEach(list, paging, ticket_node_t, pTemp, i)
	{
		Seat_Srv_FetchByID(pTemp->data.seat_id,&seat);
		if (pTemp->data.status == (ticket_status_t)0)
      			strcpy(status,"待售");
		else if (pTemp->data.status == (ticket_status_t)1)
       			strcpy(status,"已售");
		else if (pTemp->data.status == (ticket_status_t)9)
              		strcpy(status,"预留");
		printf("%9d%12d%18s%15s%18d          (%d,%d) %18d%16s\n",pTemp->data.id,pTemp->data.schedule_id,play.name,stu.name,pTemp->data.seat_id,seat.row,seat.column,pTemp->data.price,status);
	}
		printf("|------------------------ 总条数:%2d ------------------------------------------------------ 页码 %2d/%2d ------------------------|\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("|-----------------------------[P]上一页   |  [N]下一页   |   [r]返回上一级 | [b]售票---------------------------------------|\n");
		printf("|=============================================================================================================================|\n");
		printf("请选择:");
	        scanf("%c",&choice);	flu();
		switch(choice)
		{
			case 'b':
			case 'B':
				if(Sale_UI_SellTicket(list,seat_l))
				{
					printf("正在重载票....\n");
					if (Ticket_Srv_FetchBySchID(list,schID))
						printf("票信息重载成功!\n");
				}
				printf("输入Enter返回...");	flu();
				break;
			case 'p':
			case 'P':
				if (!Pageing_IsFirstPage(paging)) {
					Paging_Locate_OffsetPage(list, paging, -1, ticket_node_t);
				}
				break;
			case 'N':
			case 'n':
				if (!Pageing_IsLastPage(paging)) {
					Paging_Locate_OffsetPage(list, paging, 1, ticket_node_t);
				}
				break;
			//case 'r':
			//case 'R':
			//	return;
		}
	}while(choice != 'R' && choice != 'r');
コード例 #3
0
ファイル: Sale_UI.c プロジェクト: dreamer2018/TTMS
//根据计划ID,显示演出票
void Sale_UI_ShowTicket(int schID)
{
		int pageSize=10, i;
		int listSize;
		int ticket_id;
		char choice;
		ticket_list_t list,s;
		seat_t buf;
		Pagination_t paging;
		List_Init(list,ticket_node_t);
		listSize=Ticket_Srv_FetchBySchID(list, schID);
		system("clear");
		paging.pageSize = pageSize;
		paging.totalRecords = listSize;
		Paging_Locate_FirstPage(list, paging);
		do
		{
			system("clear");
			printf("\n\t\t\033[34m=====================影票列表======================\n");
			printf("\t\t%6s %17s%10s%8s%8s%8s\n","id","演出计划id","座位id","行","列","状态");
			printf("\t\t---------------------------------------------------\n");
			for (i = 0, s= (ticket_node_t *) (paging.curPos);s != list && i < paging.pageSize; i++, s=s->next) 
			{
					Seat_Srv_FetchByID(s->data.seat_id,&buf);
					if(buf.status==1)
						printf("\033[31m\t\t%6d%10d%11d%7d%7d    %12s\n\033[0m",s->data.id,s->data.schedule_id, s->data.seat_id,buf.row+1, buf.column+1,Status(s->data.status));
			}
			printf("\t\t\033[34m---------------------------------------------------\n");
			printf("\t\t------总行数 :%2d --------------页码: %2d/%2d -------\n",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
			printf("\t\t===================================================\n");
			printf("\t\t**    【R】返回上一级     【B】订票       **\n");
			printf("\t\t**    【P】上一页        【N】下一页        **\n");
			printf("\t\t**    【T】 退票                            **\n");
			printf("\t\t===================================================\033[0m\n");
			printf("\t\tYour Choice:");
			scanf("\t\t%c", &choice);
			getchar();
			switch (choice)
			{
				case 'B': 	;
				case 'b':
									printf("请输入你要订购的票的id:");
									scanf("%d",&ticket_id);
									getchar();
									Sale_UI_SellTicket(ticket_id);
									paging.totalRecords=Ticket_Srv_FetchBySchID(list, schID);
									List_Paging(list,paging,ticket_node_t);
									break;
				case 'r':
				case 'R':
									break;
				case 't':
				case 'T':
									printf("请输入你要退的票的id:");
									scanf("%d",&ticket_id);
									getchar();
									Sale_UI_ReturnTicket(ticket_id);
									paging.totalRecords=Ticket_Srv_FetchBySchID(list, schID);
									List_Paging(list,paging,ticket_node_t);
									break;
				case 'p':
				case 'P':	
									if (1 < Pageing_CurPage(paging)) 
									{
											Paging_Locate_OffsetPage(list, paging, -1, ticket_node_t);
									}	
									break;
				case 'n':
				case 'N':	
									if (Pageing_TotalPages(paging) > Pageing_CurPage(paging))
									{
											Paging_Locate_OffsetPage(list, paging, 1, ticket_node_t);
									}
									break;
			}
		} while (choice != 'r' && choice != 'R');
}
コード例 #4
0
ファイル: Ticket_UI.c プロジェクト: Oscer2016/project
//根据计划ID显示所有票
void Ticket_UI_ListBySch(const schedule_t *sch,	ticket_list_t tickList, seat_list_t seatList) {
	
	int i,id;
	char choice;
	
	ticket_node_t *pos;
	Pagination_t paging;

	paging.offset = 0;
	paging.pageSize = TICKET_PAGE_SIZE;
	
	//演出计划schedule_id
	paging.totalRecords=Ticket_Srv_FetchBySchID(tickList, sch->id);
	Paging_Locate_FirstPage(tickList, paging);
	do {
		system("clear");
		printf("\t\t\t\033[32m=====================================================================================\n\n");
		printf("\t\t\t***************************************\033[0m\033[34m 票 \033[0m\033[32m******************************************\033[0m\n\n");
		printf("\t\t\t\033[33m%s\t\t%s\t\t%s\033[0m\t\t\033[36m%s\033[0m\t\t\033[31m%s\033[0m","票ID","演出计划ID","座位ID","票价","票状态");

		printf("\n\t\t\t\033[32m-------------------------------------------------------------------------------------\033[0m\n");
		Paging_ViewPage_ForEach(tickList, paging, ticket_node_t, pos, i){
			printf("\t\t\t\033[33m%2d\t\t%5d\t\t %11d\033[0m\t\033[36m%10d\033[0m\t\t", pos->data.id,
					pos->data.schedule_id, pos->data.seat_id, pos->data.price);
					
			switch(pos->data.status){
				case TICKET_AVL:  	printf("\033[31m%5s\033[0m\n","待售"); 	break;
				case TICKET_SOLD:	printf("\033[31m%5s\033[0m\n","已售");	break;
				case TICKET_RESV:   printf("\033[31m%5s\033[0m\n","预留"); 	break;
			}
		}
		
		printf("\n\t\t\t\033[32m----------------- 共 \033[0m\033[33m%d\033[0m\033[32m 条数据 -------------------------- 页码: %d\033[0m/\033[33m%d\033[0m\033[32m -----------------\033[0m\n\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("\t\t\t\033[32m======================================================================================\033[0m\n\n");
		printf("\n\t\t\t\033[33m------------------------ [A]售票 -------------- [B]预留票 ----------------------------\033[0m\n\n");
		printf("\t\t\t\033[32m---------------\033[0m[\033[32mP\033[0m]\033[32m上页---------------\033[0m[\033[33mR\033[0m]\033[33m返回\033[0m\033[32m---------------\033[0m[\033[36mN\033[0m]\033[36m下页\033[0m\033[32m--------------------\033[0m\n\n");
		printf("\t\t\t\033[32m======================================================================================\033[0m\n\n");
		printf("\t\t\t\033[33m请选择: \033[0m");
		choice=l_getc();
		switch(choice)
		{
		case 'p':
		case 'P':
			if (!Pageing_IsFirstPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, -1, ticket_node_t);

			}
			break;
		case 'n':
		case 'N':
			if (!Pageing_IsLastPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, 1, ticket_node_t);
			}
			break;
		case 'a':
		case 'A':
			{
				seat_node_t *p;
				int row,column,t=0;
				printf("\n\t\t\t\033[33m请输入座位的行号: \033[0m");

				while(1){
					if(scanf("%d", &(row))==1){ cl_stdin(); break;}
					else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
				}
					
				printf("\n\t\t\t\033[33m请输入座位的列号: \033[0m");

				while(1){
					if(scanf("%d", &(column))==1){ cl_stdin(); break;}
					else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
				}

				List_ForEach(seatList, p){

					if(row==p->data.row && column==p->data.column){

						ticket_node_t *td;
						td= Ticket_Srv_FindBySeatID(tickList, p->data.id);
					
						if(QueryTicket(td->data.id)==1){
							if(UpdateTicket(td->data.id) ){
								
								sale_t sdata;
								sdata.id=EntKey_Srv_CompNewKey("sale");
								sdata.user_id=gl_CurUser.id;
								sdata.ticket_id=td->data.id;
								sdata.date=DateNow();
								sdata.time=TimeNow();
								sdata.value=td->data.price;
								sdata.type=SALE_SELL;

								Sale_Srv_Add(&sdata);
								system("echo '\n\t\t\t\033[36m售票成功!\t系统正在出票, 请稍候....\033[0m\n' | pv -qL 15");
								sleep(1);
								Ticket_UI_Print(td->data.id);
								printf("\n\n\t\t\t\033[33m按任意键继续....\033[0m\n");
								getchar();
								t=1;
								break;
							}else{
								printf("\n\t\t\t\033[31m售票失败! 请稍候重试! \033[0m\n\t\t\t\033[33m按任意键返回....\033[0m\n");
								getchar();
								t=0;
								break;
							}

						}else{
							printf("\n\t\t\t\033[31m该票已预留或售出!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
							getchar();
							t=1;
							break;
						}
					}
				}

				if(!t){
					printf("\n\t\t\t\033[31m未找到该座位!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
					getchar();
				}
				
				paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
				List_Paging(tickList, paging, ticket_node_t);
			}
			break;
			
		case 'b':
		case 'B':
				{
					seat_node_t *p;
					int row,column,t=0;
		        	
					printf("\n\t\t\t\033[33m请输入座位的行号: \033[0m");
				    	
					while(1){
						if(scanf("%d", &(row))==1){ cl_stdin(); break;}
						else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
					}
				    	
					printf("\n\t\t\t\033[33m请输入座位的列号: \033[0m");

					while(1){
						if(scanf("%d", &(column))==1){ cl_stdin(); break;}
						else {cl_stdin(); printf("\n\t\t\t\033[31m输入有误,请重新输入: \033[0m");}
					}
					
					List_ForEach(seatList, p){
					
						if(row==p->data.row && column==p->data.column){

							ticket_node_t *td;
							td= Ticket_Srv_FindBySeatID(tickList, p->data.id);

							if(QueryTicket(td->data.id)==1){
							
								ticket_t  data;
								data=td->data;
								data.status=TICKET_RESV;
								
								if(Ticket_Srv_Modify(&data) ){
									printf("\n\t\t\t\033[33m预留票成功!\033[0m\n");
									printf("\n\t\t\t\033[34m按任意键继续....\033[0m\n");
									getchar();
									t=1;
									break;
								}else{
									printf("\n\t\t\t\033[31m预留票失败! 请稍候重试! \033[0m\n\t\t\t\033[33m按任意键返回....\033[0m\n");
									getchar();
									t=0;
									break;
								}
							}else{
								printf("\n\t\t\t\033[31m该票已预留或售出!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
								getchar();
								t=1;
								break;
							}
						}
					}
					if(!t){	
						printf("\n\t\t\t\033[31m未找到该座位!\033[0m\033[33m\n\t\t\t按任意键继续....\033[0m\n");
						getchar();
					}
						
					paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
					List_Paging(tickList, paging, ticket_node_t);
				}
				break;
			}
	} while (choice != 'r' && choice != 'R');
コード例 #5
0
ファイル: Ticket_UI.c プロジェクト: dongmengyuan/linuxc
//根据计划ID显示所有票
void Ticket_UI_ListBySch(const schedule_t *sch,	ticket_list_t tickList, seat_list_t seatList) {
	
	int i,id;
	char choice;
	
	
	
	ticket_node_t *pos;
	Pagination_t paging;
	
	
	paging.offset = 0;
	paging.pageSize = TICKET_PAGE_SIZE;
	
	//演出计划schedule_id
	paging.totalRecords=Ticket_Srv_FetchBySchID(tickList, sch->id);
	Paging_Locate_FirstPage(tickList, paging);
	do {
		system("clear");
	        printf("\t\t\t=====================================================================================\n\n");
	        printf(
				"\t\t\t*************************************票******************************************\n\n");
		printf("\t\t\t%s\t\t%s\t\t%s\t\t%s\t\t%s","票ID","演出计划ID","座位ID","票价","票状态");

		printf("\n\t\t\t---------------------------------------------------------------------------------------\n");
		Paging_ViewPage_ForEach(tickList, paging, ticket_node_t, pos, i){
			printf("\t\t\t%2d\t\t%5d\t\t %8d\t%10d\t\t", pos->data.id,
					pos->data.schedule_id, pos->data.seat_id, pos->data.price);
					
			switch(pos->data.status){
				case TICKET_AVL:  	printf("%5s\n","待售"); 	break;
				case TICKET_SOLD:	printf("%5s\n","已售");  	break;
				case TICKET_RESV:   	printf("%5s\n","预留"); 	break;
			}
		}
		
		printf("\n\t\t\t------- 总数:%2d ---------------------------------------------------- 页数 %2d/%2d ----\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("\t\t\t***************************************************************************************\n");
		printf("\n\t\t\t===================================================================================\n\n");
		
		printf("\n\t\t\t=========[P]上一页====================================[N]下一页=====================\n");
		printf("\n\t\t\t=========[A]售票==============[B]预留票===============[R]返回=====================\n");
		
		printf("\n\t\t\t===================================================================================\n");
		printf("\t\t\t请选择:");
		choice=l_getc();
		switch(choice)
		{
		case 'p':
		case 'P':
			if (!Pageing_IsFirstPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, -1, ticket_node_t);

			}
			break;
		case 'n':
		case 'N':
			if (!Pageing_IsLastPage(paging)) {
				Paging_Locate_OffsetPage(tickList, paging, 1, ticket_node_t);
			}
			break;
		case 'a':
		case 'A':
				{
					seat_node_t *p;
					int row,column,t=0;
		        	
				    	printf("\t\t\t请输入座位的行号:");
				    	
				    	while(1){
							if(scanf("%d", &(row))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
				    	
				    	printf("\t\t\t请输入座位的列号:");
				    	
				    	while(1){
							if(scanf("%d", &(column))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
					
					List_ForEach(seatList, p){
					
							if(row==p->data.row && column==p->data.column){
								
								ticket_node_t *td;
								
								td= Ticket_Srv_FindBySeatID(tickList, p->data.id);
								
								
								
								if(QueryTicket(td->data.id)==1){
									if(UpdateTicket(td->data.id) ){
										sale_t sdata;
	       					
							       			sdata.id=EntKey_Srv_CompNewKey("sale");
							       			sdata.user_id=gl_CurUser.id;
							       			sdata.ticket_id=td->data.id;
							       			sdata.date=DateNow();
							       			sdata.time=TimeNow();
							       			sdata.value=td->data.price;
							       			sdata.type=SALE_SELL;
							       					
							       			Sale_Srv_Add(&sdata);
											printf("\n\t\t\t售票成功!\t系统正在出票,请稍候。。。\n");
											sleep(1);
											Ticket_UI_Print(td->data.id);
											printf("\n\n\t\t\t按任意键继续!。。。\n");
											getchar();
											t=1;
											break;
									}else{
											printf("\n\t\t\t售票失败!\t请稍候重试。\n\t\t\t按任意键返回。。。\n");
											getchar();
											t=1;
											break;
									}
									
									
								}else{
								
									printf("\n\t\t\t该票已预留或售出!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
									break;
								}
							}
					}
						
						
					if(!t){
								
									printf("\n\t\t\t未找到该座位!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
									
								
								
					}
				
				paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
				List_Paging(tickList, paging, ticket_node_t);	
			
				}
				break;
		case 'b':
		case 'B':
				{
					seat_node_t *p;
					int row,column,t=0;
		        	
				    	printf("\t\t\t请输入座位的行号:");
				    	
				    	while(1){
							if(scanf("%d", &(row))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
				    	
				    	printf("\t\t\t请输入座位的列号:");
				    	
				    	while(1){
							if(scanf("%d", &(column))==1){ cl_stdin(); break;}
							else {cl_stdin(); printf("\t\t\t输入有误,请重新输入:");}
						}
					
					List_ForEach(seatList, p){
					
							if(row==p->data.row && column==p->data.column){
							
								ticket_node_t *td;
								
								td= Ticket_Srv_FindBySeatID(tickList, p->data.id);
								
								
								
								if(QueryTicket(td->data.id)==1){
								
									ticket_t  data;
									data=td->data;
									data.status=TICKET_RESV;
									
									if(Ticket_Srv_Modify(&data) ){
											printf("\n\t\t\t预留票成功!\n");
											
											printf("\n\n\t\t\t按任意键继续!。。。\n");
											getchar();
											t=1;
											break;
									}else{
											printf("\n\t\t\t预留票失败!\t请稍候重试。\n\t\t\t按任意键返回。。。\n");
											getchar();
											t=1;
											break;
									}
								}else{
								
									printf("\n\t\t\t该票已预留或售出!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
									break;
								}
							}
								
					
					}
						
						
						
					if(!t){	
									printf("\n\t\t\t未找到该座位!\t请重新输入。\n\t\t\t按任意键继续!。。。\n");
									getchar();
							
					}
						
				paging.totalRecords = Ticket_Srv_FetchBySchID(tickList, sch->id);
				List_Paging(tickList, paging, ticket_node_t);		
					
			
				}
				break;
			
		
		
		}
	} while (choice != 'r' && choice != 'R');