/// <summary> /// 注册用户 /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public LoginResult Reg(string username, string password) { var rcount = _accountInterface.RecordCount(); LoginResult result = new LoginResult(); string cmd = string.Format(" where UserName = '******'", username); var list = _accountInterface.GetList(cmd).ToList(); if (list.Count == 0) { AccountInfo account = new AccountInfo(); account.UserName = username; account.UserPwd = CryptographyHelper.MD5(password); account.LastLoginDate = DateTime.Now; account.LastMoneyDate = DateTime.Now; account.RegDate = DateTime.Now; account.NickName = username; account.RegIp = ClientHelper.ClientIp; account.LastLoginIp = ClientHelper.ClientIp; if (rcount == 0) { //第一个用户是超级管理员 account.UserType = 100; } var uid = _accountInterface.Insert(account); if (uid.HasValue) { account.Id = uid.Value; } var user = account; result.UserName = user.UserName; result.UserId = user.Id; BaseUserData userData = new BaseUserData(); userData.UserId = user.Id; userData.DepartmentId = user.DepartmentId; userData.CompanyId = user.CompanyId; userData.UserName = user.UserName; result.UserData = userData; result.Status = true; } else { result.Msg = "己经存在该用户名,请重新更换用户名。"; } return(result); }