示例#1
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);
}
示例#2
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);
}
示例#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");
		//显示数据
		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');