Example #1
0
//根据用户账号名删除一个已经存在的用户账号信息,如果不存在这个用户账号名,提示出错信息
int Account_UI_Delete(account_list_t head,char usrName[]) {

		int ret=0;
       		char choice;
		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\n", data.username);
				printf("\n		-----------------------------------------------------------------");
				printf("\n		|          [D]elete          |               [R]eturn           |");
				printf("\n		******************************************************************");
       			 printf("\n		Input Your choice:");
				choice=l_getc();
				if('r'==choice || 'R'==choice) break;	
				
				if('d'==choice || 'D'==choice){
					
					if(Account_Srv_DeleteByID(data.id)){
						printf("\n		----------------------------删除成功!------------------------------");
						ret=1;
					}else{
						 printf("\n		----------------------------删除失败!------------------------------");
					}
				sleep(1);
				}
			}
		
		
       
       }else{
       		printf("\n		----------------------------未找到信息!------------------------------");
		cl_stdin();
		sleep(1);
       	}
       
       return ret;
}
Example #2
0
//根据用户账号名删除一个已经存在的用户账号信息,如果不存在这个用户账号名,提示出错信息
int Account_UI_Delete(account_list_t list ,char usrName[]) {
	account_node_t *temp;
	printf("请输入用户名\n");
	fflush(stdin);
	scanf("%s",usrName);
	temp=(account_node_t *)malloc(sizeof(account_node_t));
	temp=Account_Srv_FindByUsrName(list,usrName);
	if(temp==NULL)
	{
		printf("用户名不存在\n");
		return 0;
	}
	else if(Account_Srv_DeleteByID(temp->data.id))
	{
	printf("删除成功\n");
	return 1;
	
	}
}