Example #1
0
//添加一个用户账号信息
int Account_UI_Add(void) {
	
	int er=0,newRecCount=0;
       		char choice;
		account_t data,buf;	
		do { 

				system("clear");
				printf("\n\t\t==================================================================");
       			printf("\n\t\t***************************添加用户********************************");
        		printf("\n\t\t==================================================================");
       				
                cl_stdin();
				while(1){
				printf("\n\t\t|	用户名:");
                    gets(data.username);
					if(Account_Srv_FetchByUsrName(data.username,&buf)){
						printf("\t\t           	          **用户已存在!**");
                        //cl_stdin();
					}else break;
				}
		        //cl_stdin();
				printf("\n\t\t|       密码:");
			gets(data.password);	
            printf("\n		-------[1].CLERK------------[2].MANG-------------[3].ADMAIN--------");
				while(1){
				printf("\n		|     请选择用户类型:");
					er=0;
					choice=l_getc();
					switch(choice){
						case '1': data.type= USR_CLERK;  	break;
						case '2': data.type= USR_MANG;   	break;
						case '3': data.type= USR_ADMIN; 	break;
						default : er=1; printf("\n\t\t         	           **输入有误!**   ");
					}
					if(er!=1) break;
				}
				data.id = EntKey_Srv_CompNewKey("User");
			
				
				if(Account_Srv_Add(&data)){
					newRecCount++;
					printf("\n		----------------------------添加成功!------------------------------");
				}else{
					printf("\n		----------------------------添加失败!------------------------------");
					
				}
				printf("\n		==================================================================");
       				printf("\n		|         [A]dd More               |             [R]eturn        |");
        			printf("\n		******************************************************************");
        			printf("\n		Input Your choice:");
				choice=l_getc();
        } while ('a' == choice || 'A' == choice);	
        return newRecCount;

}
Example #2
0
//添加一个用户账号信息,如果账号名存在,提示出错信息
int Account_UI_Add(account_list_t list ) {
	int i=0;
	int newRecCount=0;
	char a[30];
	char choice;
	account_t  pos;
	account_node_t *temp;
//	account_list_t p;
	do{
		
		printf("请输入用户名\n");fflush(stdin);
		gets(pos.username);
		temp=(account_node_t *)malloc(sizeof(account_node_t));
		temp=Account_Srv_FindByUsrName(list,pos.username);
		if(temp!=NULL)
		{
		printf("用户名已存在\n");
		return 0;
		}
		printf("请输入密码\n");
		fflush(stdin);
		scanf("%s",&(pos.password));
		
		printf("请输入账户类型:\n");
		printf("0.匿名用户 1.销售经理 2.经理 9.系统管理员");
		fflush(stdin);
		scanf("%d",&i);
		pos.type=(account_type_t)i;
		pos.id=EntKey_Srv_CompNewKey("usr");
				
	
	if (Account_Srv_Add(&pos)) {
		newRecCount ++;
		printf("The new room added successfully!\n");
	//	p=(account_list_t)malloc(sizeof(account_node_t));
	//	p->data=pos;
	//	List_AddTail(list,p);
		
	} else
		printf("The new room added failed!\n");
		
	printf("-------------------------------------------------------\n");
	printf("[A]dd more, [R]eturn:");
	fflush(stdin);
	scanf("%c", &choice);
} while ('a' == choice || 'A' == choice);
	return newRecCount;
}
Example #3
0
//创建系统初始化账号admin
void Account_Srv_InitSys(){
	char entName[8];
	if(Account_Perst_CheckAccFile());
	else
		{
            system("clear");
			account_t data_admin;
			data_admin.id=EntKey_Srv_CompNewKey(entName);//调用函数获取用户id
			printf("\n\n\n\t\t\t\t   \033[31m为您创建系统初始化帐号ADMIN\033[0m");
            printf("\n\n\t\t\t\t请输入姓名:");
            scanf("%s",data_admin.username);//为ata_admin账号赋值成员信息 
			data_admin.type=9;
            cl_stdin();
            printf("\n\t\t\t\t请输入密码:");
			getpwd(30,data_admin.password);
            Account_Srv_Add(&data_admin);//将新建data_admin账号写入文件 
            printf("\n\t\t\t\t\t创建成功!");
            sleep(1);

}
}