Esempio n. 1
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. 2
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. 3
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. 4
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');