Example #1
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');


}
Example #2
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');
Example #3
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);
	
	
}