public int InsertUser(UserInfo user) { int num = 0; SqlParameter[] parms = SqlHelper.GetCachedParameters(SQL_INSERT_USER); // 如果参数为空,创建新的参数 if (parms == null) { parms = new SqlParameter[] { new SqlParameter(PARAM_USER_NAME,SqlDbType.NVarChar), new SqlParameter(PARAM_USER_PASSWORD,SqlDbType.NVarChar), }; SqlHelper.CacheParameters(SQL_INSERT_USER, parms); } // 设置新的参数 parms[0].Value = user.UserName; parms[1].Value = user.PassWord; num = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.ConnectionStringLocalTransaction, System.Data.CommandType.Text, SQL_INSERT_USER, parms)); //这里返回的是UserID return num; }
public int InsertUser(UserInfo user) { return dal.InsertUser(user); }
public bool InsertUser(UserInfo user) { return dal.InsertUser(user); }
public override System.Web.Security.MembershipUser CreateUser( string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status) { if (string.IsNullOrEmpty(username)) { status = System.Web.Security.MembershipCreateStatus.InvalidUserName; return null; } FWSync.IDAL.IUser dal = FWSync.DALFactory.DataAccess.CreateUser(); bool isexist = dal.ValidateUserExist(username); if (isexist) { status = System.Web.Security.MembershipCreateStatus.DuplicateUserName; return null; } UserInfo us = new UserInfo(); us.UserName = username; //这里要用到md5加密 us.PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password,"MD5"); //us.PassWord = password; int userid = dal.InsertUser(us); status = System.Web.Security.MembershipCreateStatus.Success; System.Web.Security.MembershipUser user = new System.Web.Security.MembershipUser( "MyMemberShip", username, userid, string.Empty, string.Empty, string.Empty, true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now ); return user; }