Esempio n. 1
0
//链表分页输出
static void Example_List_PgShow(student_list_t list, int listSize) {
	int pageSize, i;
	Pagination_t paging;
	student_node_t *p;
	char choice;

	printf("Input page size:");
	scanf("%d", &pageSize);

	paging.pageSize = pageSize;

	paging.totalRecords = listSize;
	Paging_Locate_FirstPage(list, paging);

	do {
		printf("============= Student List =================\n");
		printf("%5s%20s%8s\n", "ID", "Name", "Score");
		printf("--------------------------------------------\n");
		for (i = 0, p = (student_node_t *) (paging.curPos);
				p != list && i < paging.pageSize; i++) {
			printf("%5d%20s%8d\n", p->data.ID, p->data.name, p->data.score);
			p=p->next;
		}
		printf("--Total Records:%2d --------- Page %2d/%2d --\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("[P]revPage | [N]extPage | [R]eturn\n");
		printf("============================================\n");
		printf("Your Choice:");
		fflush(stdin);
		scanf("%c", &choice);

		switch (choice) {
		case 'p':
		case 'P':
			if (1 < Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(list, paging, -1, student_node_t);
			}
			break;
		case 'n':
		case 'N':
			if (Pageing_TotalPages(paging) > Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(list, paging, 1, student_node_t);
			}
			break;
		}
	} while (choice != 'r' && choice != 'R');

}
Esempio n. 2
0
//根据剧目ID显示演出计划
void Sale_UI_ShowScheduler(int playID) {
	int i, id;
	char choice;
	
	play_t pdata;
	ticket_list_t tickList;
	seat_list_t   seatList;
	
	schedule_list_t head;
	schedule_node_t *p;
	Pagination_t paging;
	
	Play_Srv_FetchByID(playID, &pdata);
	
	List_Init(head, schedule_node_t);
	
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Schedule_Srv_FetchByPlay(head,playID);
	
	Paging_Locate_FirstPage(head, paging);

	do {
		system("clear");
		printf("\n		=================================================================");
        	printf("\n		**************************剧目%s的演出计划*************************");
          	printf("\n		=================================================================");
		printf("\t\t%5s\t%5s\t%8s\t%10s\t%10s\t%10s\n", "ID", "剧目编号", "演出厅编号",
		 "上映日期","上映时间","票价");
		printf("\n		-----------------------------------------------------------------");
		
		if(!List_IsEmpty(head)){
			//显示数据
			for (i = 0, p = (schedule_node_t *) (paging.curPos);p != head && i < paging.pageSize; i++){
				printf("%5d  『%d』%20s  『%d』%2s ", p->data.id, p->data.play_id, p->data.play_name,p->data.studio_id, p->data.studio_name);
				printf("  %4d-%02d-%02d",p->data.date.year, p->data.date.month, p->data.date.day);
				printf("\t%2d:%02d:%02d ", p->data.time.hour, p->data.time.minute, p->data.time.second);
				printf("\t%5d\n", p->data.price);
			}
		}else{
		
			printf("\n		                    **没有演出厅信息!**");
			printf("\n		==================================================================");
		}
		printf("\n		==================================================================");
        	printf("\n		|----------总数%2d------------------------------%2d/%2d页---------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
		printf("\n		******************************************************************");
        	printf("\n		|       [P]revPage          |              [N]extPage          |");
		printf("\n		-----------------------------------------------------------------");
		printf("\n		|         [S]ale       	  |             [R]eturn              |");
		printf("\n		******************************************************************");
		printf("\n		==================================================================");
		printf("\n		Iput Your choice:");
		choice=l_getc();
	

		switch (choice) {
			
		case 's':
		case 'S':
			{
				
				
				
				List_Init(tickList, ticket_node_t);
				List_Init(seatList,   seat_node_t);
				
				
			
			
				Sale_UI_SellTicket(tickList,seatList);
				
				List_Destroy(tickList, ticket_node_t);
				List_Destroy(seatList,   seat_node_t);
			}
			break;
		case 'p':
        case 'P':
			system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,schedule_node_t);
            }
			break;
		case 'n':
        case 'N':
			 system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,schedule_node_t);
            }
			break;
		}
	} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}
Esempio n. 3
0
void Sale_UI_MgtEntry() {
	int i, id;
	char choice;

	schedule_list_t head;
	//schedule_node_t *p;
	schedule_node_t *p;
	Pagination_t paging;

	List_Init(head, schedule_node_t);
	//List_Init(head,schedule_node_t);
	
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Schedule_Srv_FetchAll(head);
	
	Paging_Locate_FirstPage(head, paging);

	do {
		system("clear");
		printf("\n		=================================================================");
        	printf("\n		**************************剧目%s的演出计划*************************");
          	printf("\n		=================================================================");
		printf("\t\t%5s\t%5s\t%8s\t%10s\t%10s\t%10s\n", "ID", "剧目编号", "演出厅编号",
		 "上映日期","上映时间","票价");
		printf("\n		-----------------------------------------------------------------");
		
		//显示数据
		
			for (i = 0, p = (schedule_node_t *) (paging.curPos);p != head && i < paging.pageSize; i++){
				printf("%5d  『%d』%20s  『%d』%2s ", p->data.id, p->data.play_id, p->data.play_name,p->data.studio_id, p->data.studio_name);
				printf("  %4d-%02d-%02d",p->data.date.year, p->data.date.month, p->data.date.day);
				printf("\t%2d:%02d:%02d ", p->data.time.hour, p->data.time.minute, p->data.time.second);
				printf("\t%5d\n", p->data.price);
				p=p->next;
		}

		printf("\n		==================================================================");
        	printf("\n		|----------总数%2d------------------------------%2d/%2d页---------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
		printf("\n		******************************************************************");
        	printf("\n		|        [P]revPage          |              [N]extPage          |");
		printf("\n		-----------------------------------------------------------------");
		printf("\n		|         [I]D List    	  |             [R]eturn              |");
		printf("\n		******************************************************************");
		printf("\n		==================================================================");
		printf("\n		Iput Your choice:");
		choice=l_getc();
	

		switch (choice) {
		case 'i':
		case 'D':
				
				printf("\n		|     请输入演出计划ID:");
				while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin(); printf("\n		                    **您的输入有误!**");}
				}
				Sale_UI_ShowScheduler(id);
			
				break;
		case 'p':
        case 'P':
			system("clear");
	        if(1<Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,-1,schedule_node_t);
            }
			break;
		case 'n':
        case 'N':
		system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,schedule_node_t);
            }
		}

	
} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}
Esempio n. 4
0
//管理系统用户功能入口函数,显示用户账号管理菜单
void Account_UI_MgtEntry() 
{
		int listSize,usr_id,i;
		char choice,userName[21];
		Pagination_t paging;
		account_list_t p;
		List_Init(p,account_node_t);
		account_list_t list,pos;
		account_t buf;
		List_Init(list,account_node_t);
		listSize=Account_Srv_FetchAll(list);
		paging.pageSize =PAGESIZE;
		paging.totalRecords = listSize;
		Paging_Locate_FirstPage(list, paging);
		do {
					system("clear");
					printf("\n\t\t\033[32m****************** 计划表 *******************\n");
					printf("\t\t     %2s%20s%20s\n", "ID", "用户名", "用户类型");
					printf("\t\t*********************************************\n");
					Paging_ViewPage_ForEach(list,paging,account_node_t,pos,i)
					{
						printf("\033[34m\t\t    %2d%17s%20s\n",pos->data.id,pos->data.username,usrtype(pos->data.type));
					}
					printf("\t\t\033[32m---------------------------------------------\n");
					printf("\t\t----总记录数:%2d ----------- 页数: %2d/%2d ----\n",paging.totalRecords, Pageing_CurPage(paging),	Pageing_TotalPages(paging));
					printf("\t\t---------------------------------------------\n");
					printf("\t\t** 【P】上一页   【N】下一页  【R】返回    **\n");
					printf("\t\t** 【A】添加用户 【M】修改用户信息         **\n");
					printf("\t\t** 【Q】查询(By name) 【D】删除用户        **\n");
					printf("\t\t=============================================\033[0m\n");
					printf("\t\tYour Choice:");
					scanf("\t\t%c", &choice);
					getchar();
					switch (choice)
					{
							case 'Q': ;
							case 'q':
												printf("请输入你要查询的用户名:");
												scanf("%s",userName);
												getchar();
												if(Account_UI_Query(userName,p))
												{
													Print_Acc_Info(p);
												}
												else
												{
													printf("Not Found!\n");
													printf("Press Any  Key To Continue......");
													getchar();
												}
												paging.totalRecords=Account_Srv_FetchAll(list);
												List_Paging(list, paging, account_node_t);
											  	break;
							case 'A': ;
							case 'a':
												if(Account_UI_Add())
												{
													printf("添加成功!\n");
													printf("Press Any  Key To Continue......");
													getchar();
												}
												else
												{
													printf("添加失败!\n");
													printf("Press Any  Key To Continue......");
													getchar();
												}
												paging.totalRecords=Account_Srv_FetchAll(list);
												List_Paging(list, paging, account_node_t);
											  	break;
							case 'M': ;
							case 'm':
												printf("请输入id :");
												scanf("%d",&usr_id);
												getchar();
												if(!Account_Srv_FetchByID(usr_id,&buf ))
												{
													printf("你输入的id不存在!\n");
													printf("Press Any  Key To Continue......");
													getchar();
												}
												else
												{
													if(Account_UI_Modify(usr_id))
													{
														printf("修改成功!\n");
														printf("Press Any  Key To Continue......");
														getchar();
													}
													else
													{
														printf("修改失败!\n");
														printf("Press Any  Key To Continue......");
														getchar();
													}
												}
												paging.totalRecords=Account_Srv_FetchAll(list);
												List_Paging(list, paging, account_node_t);
											  	break;
							case 'D': ;
							case 'd':
												printf("请输入id :");
												scanf("%d",&usr_id);
												getchar();
												if(!Account_Srv_FetchByID(usr_id,&buf ))
												{
													printf("你输入的id不存在!\n");
													printf("Press Any  Key To Continue......");
													getchar();
												}
												else
												{
													if(Account_UI_Delete(usr_id))
													{
														printf("删除成功!\n");
														printf("Press Any  Key To Continue......");
														getchar();													
													}
													else
													{
														printf("删除失败!\n");
														printf("Press Any  Key To Continue......");
														getchar();
													}
												}
												paging.totalRecords=Account_Srv_FetchAll(list);
												List_Paging(list, paging, account_node_t);
												break;
							case 'r':
							case 'R':break;
							case 'p':
							case 'P':
												if (1 < Pageing_CurPage(paging))
												{
													Paging_Locate_OffsetPage(list, paging, -1, studio_node_t);
												}
												choice='r';
												break;
							case 'n':
							case 'N':
												if (Pageing_TotalPages(paging) > Pageing_CurPage(paging))
												{
													Paging_Locate_OffsetPage(list, paging, 1, studio_node_t);
												}
												choice='r';
												break;
					}
		} while (choice != 'r' && choice != 'R');
Esempio n. 5
0
/*//销售分析模块入口函数,显示分析好的销售数据
void SalesAanalysis_UI_BoxOffice() {
	// 请补充完整
	
}


void SalesAanalysis_UI_StatSale(int usrID, user_date_t stDate, user_date_t endDate){
	// 请补充完整
}
*/
void SalesAanalysis_UI_MgtEntry() {
	// 请补充完整
	
	
	int i;
	char choice;
	
	schedule_list_t head;
	salesanalysis_node_t *p;
	salesanalysis_list_t list;
	
	Pagination_t paging;
	
	List_Init(head, schedule_node_t);
	List_Init(list,salesanalysis_node_t);
	
	paging.offset = 0;
	paging.pageSize = SALESANALYSIS_PAGE_SIZE;
	
	paging.totalRecords = Schedule_Perst_SelectAll(head);
	//printf("%d",SalesAnalysis_Srv_FetchAll(list));
	SalesAnalysis_Srv_FetchAll(list);
	
	Paging_Locate_FirstPage(list, paging);
	
	do {
		system("clear");
		//SalesAnalysis_Srv_FetchAll(list);
	
		//Paging_Locate_FirstPage(list, paging);
	
		system("clear");
		printf("\t\t=====================================================================================\n\n");
		printf(
				"\t\t***********************************销售数据分析*************************************\n\n");
		printf("\t%15s%15s%15s%15s%10s%17s%16s%8s%15s\n", "剧目ID", "剧目名称", "剧目地区",
				"剧目时长", "上座数","上映日期","下线日期","票价","票房收入");
		printf(
				"\t\t------------------------------------------------------------------------------------------\n");
		Paging_ViewPage_ForEach(list, paging,salesanalysis_node_t, p, i){
		printf("\t\t%d%12s%13s%8d%8ld", p->data.play_id, p->data.name,p->data.area, p->data.duration,p->data.totaltickets);
		printf("\t%4d-%02d-%02d ", p->data.start_date.year, p->data.start_date.month, p->data.start_date.day);
		printf(" %4d-%02d-%02d ",p->data.end_date.year, p->data.end_date.month, p->data.end_date.day);
		printf("%5d\t%5ld\n",p->data.price,p->data.sales);
		}
		
		printf("\t\t------- 总数:%2d ---------------------------------------------------- 页数 %2d/%2d ----\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("\t\t***************************************************************************************\n");
		printf("\t\t[P]上一页 |   [N]下一页  |   [R]返回");
		
		printf("\n\t\t===================================================================================\n");
		printf("\t\t请选择:");

		choice=l_getc();

		switch (choice) {
		
				case 'p':
				case 'P':
					if (!Pageing_IsFirstPage(paging)) {
						Paging_Locate_OffsetPage(list, paging, -1, salesanalysis_node_t);
					}
					break;
				case 'n':
				case 'N':
					if (!Pageing_IsLastPage(paging)) {
						Paging_Locate_OffsetPage(list, paging, 1, salesanalysis_node_t);
					}
					break;
				}
	} while (choice != 'r' && choice != 'R');
Esempio n. 6
0
//根据计划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');
Esempio n. 7
0
//管理系统用户功能入口函数,显示用户账号管理菜单
void Account_UI_MgtEntry(void) {
	int i=0;
	char choice;
	char username[30];
	account_list_t head;
	account_node_t *pos;
	Pagination_t paging;    
	List_Init(head,account_node_t);
	paging.offset = 0;       //初始化  记录 
	paging.pageSize = ACCOUNT_PAGE_SIZE;
	
	paging.totalRecords = Account_Srv_FetchAll(head);
	Paging_Locate_FirstPage(head, paging);
	
	do {
		system("cls");
		printf("\n==================================================================\n");
		printf("********************** 系统用户信息 **********************\n");
		printf("%5s  %10s  %20s  %20s\n", "用户id", "用户类型", "用户名","用户密码");
		printf("------------------------------------------------------------------\n");
		//显示数据
		
		for (i = 0, pos = (account_node_t *) (paging.curPos);
				pos != head && i < paging.pageSize; i++) {
			printf("%5d  %10d  %20s  %20s\n", pos->data.id,pos->data.type, pos->data.username, pos->data.password);
			pos = pos->next;
		}
		printf("------- 全部记录:%2d ----------------------- 页数 %2d/%2d ----\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf(
				"******************************************************************\n");
		printf("[P]上一页|[N]下一页 | [A]添加 | [D]删除 | [U]修改 | [R]返回 |[Q]查询");
		printf(
				"\n==================================================================\n");
		printf("请选择:");
		fflush(stdin);
		scanf("%c", &choice);
		fflush(stdin);
		switch(choice)
		{
			case 'A':
			case 'a':
				if(	Account_UI_Add(head) )
				{
					paging.totalRecords = Account_Srv_FetchAll(head);
					Paging_Locate_LastPage(head, paging, account_node_t);
				}
				break;
			//添加函数
			case 'D':
			case 'd':
				if(Account_UI_Delete(head,username))
				{
					paging.totalRecords = Account_Srv_FetchAll(head);
					Paging_Locate_LastPage(head, paging, account_node_t);
				}
				break;
			case 'U':
			case 'u':
				if(Account_UI_Modify(head,username)) 
					{
					paging.totalRecords = Account_Srv_FetchAll(head);
					Paging_Locate_LastPage(head, paging, account_node_t);
					}
				break;
			case 'p':
			case 'P':
				if (1 < Pageing_CurPage(paging)) {
					Paging_Locate_OffsetPage(head, paging, -1, account_node_t);
				}
				break;
			case 'n':
			case 'N':
				if (Pageing_TotalPages(paging) > Pageing_CurPage(paging)) {
					Paging_Locate_OffsetPage(head, paging, 1, account_node_t);
				}
				break;	 
			case 'q':
			case 'Q':
				Account_UI_Query(head,username);
			/*if(Account_UI_Query(head,username));
				{
					paging.totalRecords = Account_Srv_FetchAll(head);
					Paging_Locate_LastPage(head, paging, account_node_t);
				} */
				break;
		}

	}while(choice!='r'&&choice!='R');


}
Esempio n. 8
0
//显示所有演出计划
void Schedule_UI_MgtEntry(int play_id)
{
	int i,id;
	char choice;
	schedule_t buf;
	schedule_list_t head;
	schedule_node_t *pos;
	Pagination_t paging;
	List_Init(head,schedule_node_t);//初始化链表
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;
	paging.totalRecords =Schedule_Srv_FetchByPlay(head,play_id);
	Paging_Locate_FirstPage(head,paging);
	do {
				system("clear");
				printf("\n\t\t\033[31m****************************** 计划表 ***************************\n");
				printf("\t%12s %13s%14s %16s %16s%14s\n", "ID", "剧目ID", "演出厅ID","放映日期","放映时间","座位数");
				printf("\t\t=================================================================\033[0m\n");
				Paging_ViewPage_ForEach(head,paging,schedule_node_t,pos,i)
				{
					printf("\t\t\033[32m  %2d%10d%12d    %4d-%2d-%2d    %2d:%2d:%2d%10d\n",pos->data.id,pos->data.play_id,pos->data.studio_id,pos->data.date.year,pos->data.date.month,pos->data.date.day,pos->data.time.hour,pos->data.time.minute,pos->data.time.second,pos->data.seat_count);
				}
				printf("\t\t\033[31m=================================================================\n");
				printf("\t\t---------总记录数:%2d ------------------------ 页数: %2d/%2d ------\n",paging.totalRecords, Pageing_CurPage(paging),	Pageing_TotalPages(paging));
				printf("\t\t*****************************************************************\n");
				printf("\t\t=================================================================\n");
				printf("\t\t**     [N]:下一页          [P]:上一页         [U]:  修改       **\n");       
				printf("\t\t**     [A]:  添加          [D]:  删除         [R]:  返回       **\n");  
				printf("\t\t=================================================================\033[0m\n");
		 		printf("\t\t Please Input :");
				fflush(stdin);
				scanf(" %c",&choice);
				fflush(stdin);
				switch(choice){
				case 'a':
				case 'A':
								 	if(Schedule_UI_Add(play_id))	
								 	{
										paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
										Paging_Locate_LastPage(head, paging, schedule_node_t);
								   }
									break;
			 	case 'd':
				case 'D': 
									printf("\t\t请输入ID:");
									scanf("%d",&id);
									getchar();
									if(Schedule_Srv_FetchByID(id,&buf))
									{
										Schedule_UI_Delete(id);
									}
									else
									{
										printf("未找到!回车继续");
										getchar();
									}
									paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
									List_Paging(head, paging, schedule_node_t);
									break;
				 case 'u':
				 case 'U':
									printf("\t\t请输入ID:");
									scanf("%d",&id);
									getchar();
										if(Schedule_UI_Modify(id))
										{
											paging.totalRecords =Schedule_Srv_FetchByPlay(head,play_id);
											List_Paging(head, paging, schedule_node_t);
										}
									break;
				case 'P':
				case 'p':
						  			 if (!Pageing_IsFirstPage(paging)) 
						  			 {
										Paging_Locate_OffsetPage(head, paging, -1, schedule_node_t);
									}
									break;
				case 'n':
				case 'N':
									if (!Pageing_IsLastPage(paging)) 
									{
										Paging_Locate_OffsetPage(head, paging, 1, schedule_node_t);
									}
									break;
									}		
		}while(choice !='r'&&choice !='R');
Esempio n. 9
0
//根据计划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');
Esempio n. 10
0
void Schedule_UI_MgtEntry(int play_id){
     int i, id;
	char choice;
	play_t pdata;
	schedule_list_t head;
	schedule_node_t *p;
	Pagination_t paging;
	Play_Srv_FetchByID(play_id, &pdata);
	List_Init(head, schedule_node_t);
	paging.offset = 0;
	paging.pageSize = SCHEDULE_PAGE_SIZE;
	//载入数据
	paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
	Paging_Locate_FirstPage(head, paging);
	do {
		system("clear");
		printf("\n\n\n\t		=================================================================");
        	printf("\n\t		**************************剧目%d的演出计划*************************",play_id);
          	printf("\n\t		=================================================================");
		printf("\n\t\t\t    %-5s%-10s   %-12s   %-12s      %-12s   %-5s", "ID", "剧目", "演出厅",
		 "上映日期","上映时间","票价");
		    printf("\n\t		-----------------------------------------------------------------");
		//显示数据
		for (i = 0, p = (schedule_node_t *) (paging.curPos);p != head && i < paging.pageSize; i++){
			printf("\n\t\t\t    %-3d 『%d』 \t   『%d』 ", p->data.id, p->data.play_id,p->data.studio_id);
			printf("\t%4d-%02d-%02d\t",p->data.date.year, p->data.date.month, p->data.date.day);
			printf("%2d:%02d:00", p->data.time.hour, p->data.time.minute);
			printf("    %-5d\n", p->data.price);
			p=p->next;
		}
		printf("\n\t		==================================================================");
        printf("\n\t		|-------------总数%2d----------------------------%2d/%2d页-----------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
		printf("\n\t		******************************************************************");
        printf("\n\t		|       [P]revPage            |              [N]extPage           |");
		printf("\n\t		|     [A]dd   |   [D]elete    |     [U]udate      |   [V]iew All  |");         
		printf("\n\t		------------------------[R]eturn----------------------------------");	
  		printf("\n\t		==================================================================");
        	printf("\n\t		Iput Your choice:");
		
		choice=l_getc();
	

		switch (choice) {
		case 'a':
		case 'A':
			{
				studio_list_t slist;
				List_Init(slist, studio_node_t);
				Studio_Srv_FetchAll(slist);
				if(!List_IsEmpty(slist) ){
					if (Schedule_UI_Add(pdata.id)) //新添加成功,跳到最后一页显示
					{
						paging.totalRecords =Schedule_Srv_FetchByPlay(head,play_id);
						Paging_Locate_LastPage(head, paging, schedule_node_t);
					}
				}else{
					if(List_IsEmpty(slist)){
						printf("\n		               **没有演出厅信息,无法添加计划!**  /n");
					}
					printf("\n		-------------------------------按任意键返回-------------------------");
					getchar();
				}
			}
			break;
		case 'd':
		case 'D':
			printf("\n\t		|     请输入计划ID:");
			while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin();printf("\n\t		                        **您的输入有误!请重新输入**     ");}
				}
			
			if (Schedule_UI_Delete(id)) {	//从新载入数据
					paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
					List_Paging(head, paging, schedule_node_t);
			}
			break;
		case 'u':
		case 'U':
				printf("\n		|     请输入计划ID:");
				while(1){
					if(scanf("%d",&id)==1){ cl_stdin(); break;}
					else{ cl_stdin();printf("\n\t		                        **您的输入有误!请重新输入**     "); }
				}
			
				if (Schedule_UI_Modify(id)) {	//从新载入数据
					paging.totalRecords = Schedule_Srv_FetchByPlay(head,play_id);
					List_Paging(head, paging, schedule_node_t);
				}
			break;
		case 'v':
		case 'V':
			Schedule_UI_ListAll();
			break;
		case 't':
		case 'T':
			//();
			break;
		case 24 :
	     if (1 < Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, -1, schedule_node_t);
			}
			break;
		case 25 :
			if (Pageing_TotalPages(paging) > Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, 1, schedule_node_t);
			}
			break;
		}
	} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}
Esempio n. 11
0
void Schedule_UI_ListAll(void) {
	int i, id;
	char choice;

	schedule_list_t head;
	schedule_node_t *p;
	Pagination_t paging;

	List_Init(head, schedule_node_t);
	
	paging.offset = 0;
    paging.pageSize = SCHEDULE_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Schedule_Srv_FetchAll(head);
	
	Paging_Locate_FirstPage(head, paging);

	do {
		system("clear");
		printf("\n\n\n\t		==================================================================");
        	printf("\n\t		**************************放映计划表********************************");
          	printf("\n\t		==================================================================");
		printf("\n\t\t\t%5s\t%5s\t%8s\t%10s\t%10s\t%10s", "ID", "剧目编号","演出厅编号" , "上映日期","上映时间","票价");
		printf("\n\t		-----------------------------------------------------------------");
		
		
		//显示数据
		for (i = 0, p= (schedule_node_t *) (paging.curPos);
				p != head && i < paging.pageSize; i++){
			printf("\n\t\t\t%5d『%d』『%d』", p->data.id, p->data.play_id,p->data.studio_id);
			printf("%d-%d-%d",p->data.date.year, p->data.date.month, p->data.date.day);
			printf("\t%d:%d:00 ", p->data.time.hour, p->data.time.minute);
			printf("\t%d", p->data.price);
			p=p->next;
		}
		

		printf("\n\t		==================================================================");
        	printf("\n\t		|----------总数%2d------------------------------%2d/%2d页---------|\n",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
        	printf("\n\t		==================================================================");
		printf("\n\t		******************************************************************");
        	printf("\n\t		|      [P]revPage             |             [N]extPage          |");
       		printf("\n\t		-----------------------------------------------------------------");
		printf("\n\t		                         [R]eturn    ");
		printf("\n\t		******************************************************************");
		printf("\n\t		==================================================================");
		printf("\n\t		Iput Your choice:");	
		choice=l_getc();
		switch (choice) {
		
		
		case 'p' :
        case 'P':
	     if (1 < Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, -1, schedule_node_t);
			}
			break;
		case 'n' :
        case 'N':
			if (Pageing_TotalPages(paging) > Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, 1, schedule_node_t);
			}
			break;

		}
	} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, schedule_node_t);
}
Esempio n. 12
0
void Studio_UI_MgtEntry(void) {
	int i, id;
	char choice;

	studio_list_t head;
	studio_node_t *pos;
	Pagination_t paging;

	List_Init(head, studio_node_t);
	paging.offset = 0;
	paging.pageSize = STUDIO_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Studio_Srv_FetchAll(head);
	Paging_Locate_FirstPage(head, paging);

	do {
		/*system("cls");*/
		printf("\n==================================================================\n");
		printf(
				"********************** Projection Room List **********************\n");
		printf("%5s  %18s  %10s  %10s  %10s\n", "ID", "Name", "Rows Count",
				"Columns Count", "Seats Count");
		printf(
				"------------------------------------------------------------------\n");
		//显示数据
		Paging_ViewPage_ForEach(head, paging, studio_node_t, pos, i){
			printf("%5d  %18s  %10d  %10d  %10d\n", pos->data.id,
					pos->data.name, pos->data.rowsCount, pos->data.colsCount,
					pos->data.seatsCount);
		}

		printf("------- Total Records:%2d ----------------------- Page %2d/%2d ----\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf("******************************************************************\n");
		printf("[P]revPage|[N]extPage  | [A]dd|[D]elete|[U]pdate | [S]eat | [R]eturn");
		printf("\n==================================================================\n");
		printf("Your Choice:");
		scanf ("%*c");
		scanf("%c", &choice);
		scanf ("%*c");

		switch (choice) {
		case 'a':
		case 'A':
			if (Studio_UI_Add()) //新添加成功,跳到最后一页显示
			{
				paging.totalRecords = Studio_Srv_FetchAll(head);
				Paging_Locate_LastPage(head, paging, studio_node_t);
			}
			break;
		case 'd':
		case 'D':
			printf("Input the ID:");
			scanf("%d", &id);
			if (Studio_UI_Delete(id)) {	//从新载入数据
				paging.totalRecords = Studio_Srv_FetchAll(head);
				List_Paging(head, paging, studio_node_t);
			}
			break;
		case 'u':
		case 'U':
			printf("Input the ID:");
			scanf("%d", &id);
			if (Studio_UI_Modify(id)) {	//从新载入数据
				paging.totalRecords = Studio_Srv_FetchAll(head);
				List_Paging(head, paging, studio_node_t);
			}
			break;
		case 's':
		case 'S':
			printf("Input the room ID:");
			scanf("%d", &id);
			Seat_UI_MgtEntry(id);
			paging.totalRecords = Studio_Srv_FetchAll(head);
			List_Paging(head, paging, studio_node_t);
			break;
		case 'p':
		case 'P':
			if (!Pageing_IsFirstPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, -1, studio_node_t);
			}
			break;
		case 'n':
		case 'N':
			if (!Pageing_IsLastPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, 1, studio_node_t);
			}
			break;
		}
	} while (choice != 'r' && choice != 'R');
Esempio n. 13
0
//管理系统用户功能入口函数,显示用户账号管理菜单
void  Account_UI_MgtEntry(void) {
	
	int i,id;
	char choice,uname[30];
	account_list_t head;
	Pagination_t paging;
	List_Init(head, account_node_t);
	account_node_t *p;
	paging.offset = 0;
	paging.pageSize = ACCOUNT_PAGE_SIZE;

	//载入数据
	paging.totalRecords = Account_Srv_FetchAll(head);
	
	Paging_Locate_FirstPage(head, paging);

	do {
		system("clear");
		printf("\n\t\t==================================================================");
        printf("\n\t\t***************************用户管理********************************");
        printf("\n\t\t==================================================================");
		printf("\n\t\t\t%s\t\t%s\t\t%s", "ID", "用户类型", "用户名");
		printf("\n\t\t------------------------------------------------------------------");
		
		
		//显示数据
		for (i = 0, p = (account_node_t *) (paging.curPos);
						p != head && i < paging.pageSize; i++){
			printf("\n\t\t\t%d\t\t", p->data.id);
			
			switch(p->data.type){
				case USR_CLERK:  printf("%s\t\t\t","CLERK"); 	break;
				case USR_MANG:	 printf("%s\t\t\t","MANG");  	break;
				case USR_ADMIN:  printf("%s\t\t\t","ADMIN"); 	break;
			
			
			}
			//CLERK  MANG  ADMIN 

			printf("%s\n", p->data.username);
            p=p->next;
		}

		
        printf("\n		==================================================================");
        printf("\n		|---------总数%2d------------------------------%2d/%2d页----------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
        printf("\n		==================================================================");;
		printf("\n		******************************************************************");
        printf("\n\t\t[P]revPage|[N]extPage |[A]dd |[D]elete |[U]pdate |[Q]uery |[R]eturn");
        printf("\n		******************************************************************");
        printf("\n\t\tYour choice:");
		choice=l_getc();
		switch (choice) {
		
		case 'a':
		case 'A':
			if (Account_UI_Add()) //新添加成功,跳到最后一页显示
			{
				paging.totalRecords = Account_Srv_FetchAll(head);
				Paging_Locate_LastPage(head, paging, account_node_t);
			}
			break;
		
		case 'd':
		case 'D':
			
			printf("\n\t\t|	用户名:");
			scanf("%s",&uname);
			if (Account_UI_Delete(head,uname)) {	//从新载入数据
					paging.totalRecords = Account_Srv_FetchAll(head);
					List_Paging(head, paging, account_node_t);
			}
			
			break;
		
		case 'u':
		case 'U':
			
			printf("\n\t\t|	用户名:");
			scanf("%s",&uname);
			
			
			if (Account_UI_Modify(head,uname)) {	//从新载入数据
					paging.totalRecords = Account_Srv_FetchAll(head);
					List_Paging(head, paging, account_node_t);
			}
			
			break;
			
		case 'q':
		case 'Q':
			Account_UI_Query(head,uname);
			break;
			
		
		case 'p':
		case 'P':
			system("clear");
	        if(1<Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,-1,account_node_t);
            }
			break;
		case 'n':
		case 'N':
			system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,account_node_t);
			break;
		
		}

	}} while (choice != 'r' && choice != 'R');
	//释放链表空间
	List_Destroy(head, account_node_t);
	
	
}
Esempio n. 14
0
//根据剧目ID显示演出计划
void Sale_UI_ShowScheduler(int playID)
{
	play_t buf;
	if(Play_Srv_FetchByID(playID,&buf))
	{
		int listSize,sal_id,i;
		char choice;
		Pagination_t paging;
		schedule_list_t list,pos;
		schedule_t buf;
		List_Init(list,schedule_node_t);
		listSize=Schedule_Srv_FetchByPlay(list,playID);
		paging.pageSize =PAGESIZE;
		paging.totalRecords = listSize;
		Paging_Locate_FirstPage(list, paging);
		do {
				system("clear");
				printf("\n\t\t\033[32m************************* 计划表 **************************\n");
				printf("\t\t    %2s  %10s  %8s  %10s  %10s   %10s\n", "ID", "剧目ID", "演出厅ID","放映日期","放映时间","座位数");
				printf("\t\t***********************************************************\n");
				Paging_ViewPage_ForEach(list,paging,schedule_node_t,pos,i)
				{
					printf("\033[34m\t\t    %2d%10d%8d%6d-%2d-%2d%4d:%2d:%2d%10d\n",pos->data.id,pos->data.play_id,pos->data.studio_id,pos->data.date.year,pos->data.date.month,pos->data.date.day,pos->data.time.hour,pos->data.time.minute,pos->data.time.second,pos->data.seat_count);
				}
				printf("\t\t\033[32m-----------------------------------------------------------\n");
				printf("\t\t-------总记录数:%2d ------------------- 页数: %2d/%2d -------\n",paging.totalRecords, Pageing_CurPage(paging),	Pageing_TotalPages(paging));
				printf("\t\t-----------------------------------------------------------\n");
				printf("\t\t** 【P】上一页 【[N】下一页 【R】返回 【S】进入售票系统  **\n");
				printf("\t\t===========================================================\033[0m\n");
				printf("\t\tYour Choice:");
				fflush(stdin);
				scanf("\t\t%c", &choice);
				getchar();
				switch (choice)
				{
					case 'S': ;
					case 's':
									printf("请输入演出计划id :");
									scanf("%d",&sal_id);
									getchar();
									if(!Schedule_Srv_FetchByID(sal_id,&buf ))
									{
										printf("你输入的演出计划不存在!回车继续");
										getchar();
									}
									else
									{
										Sale_UI_ShowTicket(sal_id);
									}
									paging.totalRecords=Schedule_Srv_FetchByPlay(list,playID);
									List_Paging(list, paging, schedule_node_t);
							      	break;
					case 'r':
					case 'R':break;
					case 'p':
					case 'P':
							if (1 < Pageing_CurPage(paging))
							{
								Paging_Locate_OffsetPage(list, paging, -1, studio_node_t);
							}
							choice='r';
							break;
					case 'n':
					case 'N':
							if (Pageing_TotalPages(paging) > Pageing_CurPage(paging))
							{
								Paging_Locate_OffsetPage(list, paging, 1, studio_node_t);
							}
							choice='r';
							break;
			}
		} while (choice != 'r' && choice != 'R');
Esempio n. 15
0
//根据计划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');
}
Esempio n. 16
0
void Studio_UI_MgtEntry(void) {
	int i, id;
	char choice;

	studio_list_t head;
	studio_node_t *pos;
	Pagination_t paging;

	List_Init(head, studio_node_t);
	paging.offset = 0;
	paging.pageSize = STUDIO_PAGE_SIZE;

	//��������
	paging.totalRecords = Studio_Srv_FetchAll(head);
	Paging_Locate_FirstPage(head, paging);

	do {
		/*system("cls");*/
		printf("\n==================================================================\n");
		printf("********************** Projection Room List **********************\n");
		printf("%5s  %18s  %10s  %10s  %10s\n", "ID", "Name", "Rows Count",
				"Columns Count", "Seats Count");
		printf("------------------------------------------------------------------\n");
		//��ʾ����
		for (i = 0, pos = (studio_node_t *) (paging.curPos);
				pos != head && i < paging.pageSize; i++) {
			printf("%5d  %18s  %10d  %10d  %10d\n", pos->data.id,
					pos->data.name, pos->data.rowsCount, pos->data.colsCount,
					pos->data.seatsCount);
			pos = pos->next;
		}
		printf("------- Total Records:%2d ----------------------- Page %2d/%2d ----\n",
				paging.totalRecords, Pageing_CurPage(paging),
				Pageing_TotalPages(paging));
		printf(
				"******************************************************************\n");
		printf(
				"[P]revPage|[N]extPage | [A]dd|[D]elete|[U]pdate | [S]eat | [R]eturn");
		printf(
				"\n==================================================================\n");
		printf("Your Choice:");
		fflush(stdin);
		scanf("%c", &choice);
		fflush(stdin);

		switch (choice) {
		case 'a':
		case 'A':
			if (Studio_UI_Add()) //����ӳɹ����������һҳ��ʾ
			{
				paging.totalRecords = Studio_Srv_FetchAll(head);
				Paging_Locate_LastPage(head, paging, studio_node_t);
			}
			break;
		case 'd':
		case 'D':
			printf("Input the ID:");
			scanf("%d", &id);
			if (Studio_UI_Delete(id)) {	//������������
				paging.totalRecords = Studio_Srv_FetchAll(head);
				List_Paging(head, paging, studio_node_t);
			}
			break;
		case 'u':
		case 'U':
			printf("Input the ID:");
			scanf("%d", &id);
			if (Studio_UI_Modify(id)) {	//������������
				paging.totalRecords = Studio_Srv_FetchAll(head);
				List_Paging(head, paging, studio_node_t);
			}
			break;
		case 's':
		case 'S':
			printf("Input the ID:");
			scanf("%d", &id);
			Seat_UI_MgtEntry(id);
			paging.totalRecords = Studio_Srv_FetchAll(head);
			List_Paging(head, paging, studio_node_t);
			break;
		case 'p':
		case 'P':
			if (1 < Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, -1, studio_node_t);
			}
			break;
		case 'n':
		case 'N':
			if (Pageing_TotalPages(paging) > Pageing_CurPage(paging)) {
				Paging_Locate_OffsetPage(head, paging, 1, studio_node_t);
			}
			break;
		}
	} while (choice != 'r' && choice != 'R');
	//�ͷ�����ռ�
	List_Destroy(head, studio_node_t);
}
Esempio n. 17
0
void Studio_UI_MgtEntry(int flag){
    int i,id;
    char choice;
    studio_list_t head;
    head = (studio_list_t)malloc(sizeof(studio_node_t));
    head->prev = head->next = head;
    studio_node_t *pos;
    Pagination_t paging;
    paging.offset=0;
    paging.pageSize=STUDIO_PAGE_SIZE;
    paging.totalRecords=Studio_Srv_FetchAll(head);
    Paging_Locate_FirstPage(head,paging);
    do{
        system("clear");
        printf("\n\n\n\t\t\t==================================================================");
        printf("\n\t\t\t*************************演出厅列表*******************************");
        printf("\n\t\t\t==================================================================");
        printf("\n\t\t\t%s\t%s\t\t%s\t\t%s\t\t%s","ID","ROOM","SIZE","MODE","SEAT");
        printf("\n\t\t\t-----------------------------------------------------------------");
        //改变了数据类型,注意!汉字的输入会导致格式问题
		for (i = 0, pos = (studio_node_t *) (paging.curPos);pos != head && i < paging.pageSize; i++){
           // printf("\n%d--%d\n",strlen(pos->data.MOD),strlen(pos->data.SEAT));
            printf("\n\t\t\t%-8d%-16s%-16s%-16s%-10s\n",pos->data.id,pos->data.ROOM,pos->data.SIZE,pos->data.MOD,pos->data.SEAT);
            pos= pos->next;
        		}
   
        printf("\n		\t==================================================================");
        printf("\n		\t|----------总数%2d------------------------------%2d/%2d页-----------|",paging.totalRecords, Pageing_CurPage(paging),Pageing_TotalPages(paging));
        printf("\n		\t==================================================================");
        printf("\n		\t******************************************************************");
        printf("\n\t\t\t[P]revPage|[N]extPage |[A]dd |[D]elete |[U]pdate |[S]eat |[R]eturn");
        printf("\n		\t******************************************************************");
        printf("\n\t\t\tYour choice:");
        scanf("%c",&choice);
        switch(choice){            
	        case 'p':
            case 'P':
            system("clear");
	        if(1<Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,-1,studio_node_t);
            }
            break;
            case 'n':
            case 'N':
            system("clear");
            if(Pageing_TotalPages(paging)>Pageing_CurPage(paging)){
                Paging_Locate_OffsetPage(head,paging,1,studio_node_t);
            }
            break;
            case 'A':
            case 'a':
            system("clear");
            if(Studio_UI_Add()){
                paging.totalRecords=Studio_Srv_FetchAll(head);
                Paging_Locate_LastPage(head,paging,studio_node_t);
            }
            break;
            case 'd':
            case 'D':
            getchar();
            printf("\t\t\tInput the Room ID:");
            
        scanf("%d",&id);
            if(Studio_UI_Delete(id)){
                paging.totalRecords=Studio_Srv_FetchAll(head);
                List_Paging(head,paging,studio_node_t);
            }
            break;
            case 'u':
            case 'U':
            getchar();
            printf("\t\t\tInput the Room ID:");
            scanf("%d",&id);
            system("clear");
            if(Studio_UI_Modify(id)){
                paging.totalRecords=Studio_Srv_FetchAll(head);
                List_Paging(head,paging,studio_node_t);
            }
            break;
            case 's':
            case 'S':
            getchar();
            printf("\t\t\tInput the Room ID:");
            scanf("%d",&id);
            system("clear");
            Seat_UI_MgtEntry(id,flag);
            paging.totalRecords=Studio_Srv_FetchAll(head);
            List_Paging(head,paging,studio_node_t);
            break;  
        }
    }while(choice !='r'&& choice !='R');     //必须&&
    List_Destroy(head,studio_node_t);
}
Esempio n. 18
0
//根据计划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');