int Account_Srv_DelByID(char userID[])
{
	USER *HEAD, *User;
	HEAD = Account_Srv_FetchAll();
	User = HEAD->NODE_NEXT;
	while (User != HEAD)
	{
		if (strcmp(userID,User->USER_ACCOUT) == 0)
		{
			User->NODE_NEXT->NODE_PREV = User->NODE_PREV;
			User->NODE_PREV->NODE_NEXT = User->NODE_NEXT;
		}
		User = User->NODE_NEXT;
	}
	Account_Perst_Update(HEAD);
	return 0;
}
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
//登录函数,提示用户输入用户名和密码,登录成功return 1,否则提示重新登录,超过3次,登录失败
int SysLogin() {

	int i=1,j,k;
   	account_list_t data,head;//
   	List_Init(head,account_node_t);//
   	data=(account_list_t)malloc(sizeof(account_node_t));//
    Account_Srv_FetchAll(head);//
    char choice;
    char username[30];
	char password[30];
	char vipname[10]={"vip"};
	char vippassword[10]={"123456"};
	do{
			system("cls");
	printf("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆  欢迎来到博纳新天地影院  ☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n");
	printf("☆                              【A】管理员登录                                       ☆\n\n");
	printf("☆                              【B】售票员登录                                       ☆\n\n");
	printf("☆                              【M】经理登录                                         ☆\n\n");
	printf("☆                              【E】退出                                             ☆\n\n");      
//	printf("☆                              【D】返回上一层                                       ☆\n\n");    
	printf("☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n");
    fflush(stdin);
	choice = getchar();
    switch(choice){
			case 'A':
			case 'a':    //创建系统初始化账号 
                      while(i<=3)
 				   	  { 
						printf("请输入用户名:\n");	
     					scanf("%s",username);
	  				    printf("请输入密码:\n");	
     					scanf("%s",password);
						if(Account_Srv_Verify(username,password))
						{
							data=Account_Srv_FindByUsrName(head,username);
							if(data->data.type!=9)
								printf("账户权限不够\n");
						
						else{
						
 										do {
 												system("cls");
												printf("\n==================================================================\n");
												printf("**************** 剧院门票管理系统 ****************\n");
												printf("                 [T]系统用户管理.\n");
												printf("                 [S]演出厅管理.\n");
												printf("                 [R]返回上一层.\n");
												printf("                 [E]退出系统.\n");
												printf("\n==================================================================\n");
												printf("请选择:");
												fflush(stdin);
												choice = getchar();
												switch (choice) {
												
													case 'T':
													case 't':
														Account_UI_MgtEntry();
														break;
													case 'S':
													case 's':
														Studio_UI_MgtEntry();
														break;	
													case 'R':
													case 'r':
														SysLogin(); 
														break;
												
													}
											} while ('E' != choice && 'e' != choice);
											break; 
 								}
 						
					}
						else 
						{
								printf("密码错误,请重试.\n");
								j=0; 
								i++;
								fflush(stdin); 
								continue;
						}
				  	  }
				  	  if(j==0)
					  {
							exit(0);
					  }		
					  break;
		     	case 'B':
				case 'b': 
					 while(i<=3)  {
					 	printf("请输入用户名:\n");	
     					scanf("%s",username);
	  				    printf("请输入密码:\n");	
     					scanf("%s",password);
     					if(Account_Srv_Verify(username,password)){
     						data=Account_Srv_FindByUsrName(head,username);
							if(data->data.type!=1)
								printf("账户权限不够\n");
							else
     						Main_Menu(1);
     					}
     					else
     					{
     						printf("密码错误,请重试.\n");
							j=0; 
							i++;
							fflush(stdin); 
							continue;
     					}
     					if(j==0)
     					{
							exit(0);
     					}
					 }
     					break;	
     			case 'M':
				case 'm': while(i<=3) 
						{
							  printf("请输入用户名:\n");	
	     				  	  scanf("%s",username);
		  				      printf("请输入密码:\n");	
	     					  scanf("%s",password);
	     					  if(Account_Srv_Verify(username,password)){
	     					  			data=Account_Srv_FindByUsrName(head,username);
								if(data->data.type!=2)
										printf("账户权限不够\n");
								else
										Main_Menu(2);
		     					}
	     					  	else
		     					{
		     						printf("密码错误,请重试.\n");
									j=0; 
									i++;
									fflush(stdin); 
									continue;
		     					}
		     					if(j==0)
		     					{
									exit(0);
		     					}		
						  }
					
     					break;	
			    case 'E':
			    case 'e':return 0;
			    case 'D':
				case 'd':
						SysLogin(); 
						break; 
			    
            }}while(1);


}
Example #4
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 #5
0
//根据用户账号名修改用户账号密码,不存在这个用户账号名,提示出错信息
int Account_UI_Modify(account_list_t head,char usrName[]) {
       		int er=0,ret=0,q=0;
       		char choice;
            void Passwd();
            
	Pagination_t paging;
	paging.totalRecords = Account_Srv_FetchAll(head);
		account_t data;	
		if( Account_Srv_FetchByUsrName(usrName,&data) ){
			if(gl_CurUser.id==data.id){
				printf("\n		----------------------------没有权限!------------------------------");
				cl_stdin();
				getchar();
				return 0;
			}
			while(1) { 

				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------------------------------------------------------------------");
            	printf("\n		             \033[31m**该功能涉及系统安全,请谨慎操作!**\033[0m\n");
				printf("\n\t\t------------------------------------------------------------------");
				printf("\n\t\t\t%d\t\t ", data.id);
			
				switch(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;
				}
				printf("%-20s", data.username);
				printf("\n		==================================================================");
        		printf("\n		|---------总数%2d------------------------------%2d/%2d页----------|",paging.totalRecords ,Pageing_CurPage(paging),Pageing_TotalPages(paging));
        		printf("\n		==================================================================");;
				printf("\n		******************************************************************");
        		printf("\n\t\t|	  [T]ype	|	[P]asswd	|	[R]eturn	|");
        		printf("\n		******************************************************************");
        		printf("\n\t\tYour choice:");
				choice=l_getc();
				if('r'==choice || 'R'==choice) break;	
				switch(choice){
					
						
					case 'p':
					case 'P':
                        Passwd();
						/*{
						char fpwd[30]spwd[30];
						while(1){
							printf("\n\t\t|	新密码:");
							cl_stdin();
							getpwd(30,fpwd);
							printf("\n\t\t|请再次输入新密码:");
							
							getpwd(30spwd);
							if( strcmp(fpwdspwd)==0 ){
								strcpy(data.password,fpwd);
								q=1;
								break;
							}else{
							printf("\n\n		-----------------两次新密码输入不一致!-------------------------");
							}
						}
						}*/
						break;
						
					case 't':
					case 'T':
						printf("\n		-------[1].CLERK------------[2].MANG-------------[3].ADMAIN--------");
						printf("\n		|     请选择用户类型:");
						while(1){
							er=0;
							choice=l_getc();
							switch(choice){
								case '1': 
									
									if(data.type!= USR_CLERK){
										data.type= USR_CLERK;
									}else{
										printf("\n		----------------------------类型相同!------------------------------");
									} 	
									break;
									
								case '2': 
								
									if(data.type!= USR_MANG){
										data.type= USR_MANG;
										q=1;
									}else{
										printf("\n		----------------------------类型相同!------------------------------");
										q=0;
									} 	
									break;
								case '3': 
								
									if(data.type!= USR_ADMIN){
										data.type= USR_ADMIN;
										q=1;
									}else{
										printf("\n		----------------------------类型相同!------------------------------");
										q=0;
									} 	
									break;
								default : er=1; printf("\n\t\t        	           **输入有误!**   ");
							}
							if(er!=1) break;
						}
						break;
					}
			
				
				if(q && Account_Srv_Modify(&data)){
					printf("\n		----------------------------修改成功!------------------------------");
					ret=1;
				}else{
					if(q!=0) printf("\n		----------------------------修改成功!------------------------------");;
				}
				cl_stdin();
				sleep(1);
		
		}
       
       }else{
       		printf("\n		----------------------------未找到信息!------------------------------");
		cl_stdin();
		sleep(1);
       	}
       
       return ret;
}
Example #6
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);
	
	
}