private bool HasString(AspnetUserExtInfo user)
 {
     bool result = true;
     string key = txtKeyword.Text.Trim();
     if ( key != "")
     {
         result = (user.TrueName.IndexOf(key) >= 0 || user.UserName.IndexOf(key) >= 0);
     }
     return result;
 }
        protected void btnSaveUserInfo_Click(object sender, EventArgs e)
        {
            string userName = txtUserName.Text.Trim();
            string password = txtUserPassword.Text;
            string email = txtEmail.Text.Trim();
            bool status = chkSetActive.Checked;

            // �����û�
            MembershipUser user = null;
            try
            {
                user = Membership.CreateUser(userName, password, email);
            }
            catch(Exception ex)
            {
                lblResult.Text = "�����û�ʧ�ܣ�" + ex.Message;
                return;
            }

            // �����û�״̬
            user.IsApproved = status;
            user.Email = email;
            Membership.UpdateUser(user);

            // �����û���չ��Ϣ
            AspnetUserExtInfo profile = new AspnetUserExtInfo();
            profile.UserName = user.UserName;
            profile.TrueName = txtTrueName.Text.Trim();
            profile.Email = txtEmail.Text.Trim();
            profile.QQ = txtQQ.Text.Trim();
            profile.MSN = txtMSN.Text.Trim();
            profile.Mobile = txtMobile.Text.Trim();
            profile.IdCard = txtIdCard.Text.Trim();
            profile.TelePhone = txtPhone.Text.Trim();
            AspnetUserExt.SaveUserExt(profile);

            // �޸��û������ɫ
            foreach (ListItem item in chkRoles.Items)
            {
                if (item.Selected)
                {
                    if (!Roles.IsUserInRole(user.UserName, item.Text))
                        Roles.AddUserToRole(user.UserName, item.Text);
                }
                else
                {
                    if (Roles.IsUserInRole(user.UserName, item.Text))
                        Roles.RemoveUserFromRole(user.UserName, item.Text);
                }
            }

            lblResult.Text = "�û������ɹ�";
        }
Exemplo n.º 3
0
        private AspnetUserExtInfo BuildUserExtInfo(DataRow row)
        {
            AspnetUserExtInfo model = new AspnetUserExtInfo();

            model.UserName  = row["username"].ToString();
            model.TrueName  = row["TrueName"].ToString();
            model.IdCard    = row["IdCard"].ToString();
            model.TelePhone = row["TelePhone"].ToString();
            model.Mobile    = row["Mobile"].ToString();
            model.QQ        = row["QQ"].ToString();
            model.MSN       = row["MSN"].ToString();
            model.Email     = row["Email"].ToString();
            return(model);
        }
Exemplo n.º 4
0
        public override AspnetUserExtInfo GetModel(string username)
        {
            string    spname = "aspnet_UserExtentInfo_GetModel";
            Database  db     = DatabaseFactory.CreateDatabase(_connectionStringName);
            DbCommand comm   = db.GetStoredProcCommand(spname);

            db.AddParameter(comm, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue,
                            String.Empty, DataRowVersion.Default, null);
            db.AddInParameter(comm, "@ApplicationName", DbType.String, _applicationName);
            db.AddInParameter(comm, "@UserName", DbType.String, username);
            DataSet           ds    = db.ExecuteDataSet(comm);
            AspnetUserExtInfo model = null;

            if (ds.Tables[0].Rows.Count > 0)
            {
                model = BuildUserExtInfo(ds.Tables[0].Rows[0]);
            }
            return(model);
        }
Exemplo n.º 5
0
        public override bool Save(AspnetUserExtInfo user)
        {
            string    spname = "aspnet_UserExtentInfo_SaveUser";
            Database  db     = DatabaseFactory.CreateDatabase(_connectionStringName);
            DbCommand comm   = db.GetStoredProcCommand(spname);

            db.AddParameter(comm, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue,
                            String.Empty, DataRowVersion.Default, null);
            db.AddInParameter(comm, "@ApplicationName", DbType.String, _applicationName);
            db.AddInParameter(comm, "@UserName", DbType.String, user.UserName);
            db.AddInParameter(comm, "@TrueName", DbType.String, user.TrueName);
            db.AddInParameter(comm, "@IdCard", DbType.String, user.IdCard);
            db.AddInParameter(comm, "@TelePhone", DbType.String, user.TelePhone);
            db.AddInParameter(comm, "@Mobile", DbType.String, user.Mobile);
            db.AddInParameter(comm, "@QQ", DbType.String, user.QQ);
            db.AddInParameter(comm, "@MSN", DbType.String, user.MSN);
            db.AddInParameter(comm, "@Email", DbType.String, user.Email);
            db.ExecuteNonQuery(comm);
            int result = (int)db.GetParameterValue(comm, "@ReturnValue");

            return(result == 0);
        }
 /// <summary>
 /// �洢�û���չ��Ϣ
 /// </summary>
 public abstract bool Save(AspnetUserExtInfo user);
        private void BindUserList()
        {
            AspnetUserExtInfo user = new AspnetUserExtInfo();

            List<AspnetUserExtInfo> users = AspnetUserExt.GetAllUserExt();
            chkUserList.DataSource = users;
            chkUserList.DataTextField = "TrueName";
            chkUserList.DataValueField = "Username";
            chkUserList.DataBind();
            SetUserListState();
        }
 private AspnetUserExtInfo BuildUserExtInfo(DataRow row)
 {
     AspnetUserExtInfo model = new AspnetUserExtInfo();
     model.UserName = row["username"].ToString();
     model.TrueName = row["TrueName"].ToString();
     model.IdCard = row["IdCard"].ToString();
     model.TelePhone = row["TelePhone"].ToString();
     model.Mobile = row["Mobile"].ToString();
     model.QQ = row["QQ"].ToString();
     model.MSN = row["MSN"].ToString();
     model.Email = row["Email"].ToString();
     return model;
 }
 public override bool Save(AspnetUserExtInfo user)
 {
     string spname = "aspnet_UserExtentInfo_SaveUser";
     Database db = DatabaseFactory.CreateDatabase(_connectionStringName);
     DbCommand comm = db.GetStoredProcCommand(spname);
     db.AddParameter(comm, "@ReturnValue", DbType.Int32, ParameterDirection.ReturnValue,
       String.Empty, DataRowVersion.Default, null);
     db.AddInParameter(comm, "@ApplicationName", DbType.String, _applicationName);
     db.AddInParameter(comm, "@UserName", DbType.String, user.UserName);
     db.AddInParameter(comm,"@TrueName",DbType.String,user.TrueName);
     db.AddInParameter(comm,"@IdCard",DbType.String,user.IdCard);
     db.AddInParameter(comm,"@TelePhone",DbType.String,user.TelePhone);
     db.AddInParameter(comm,"@Mobile",DbType.String,user.Mobile);
     db.AddInParameter(comm,"@QQ",DbType.String,user.QQ);
     db.AddInParameter(comm,"@MSN",DbType.String,user.MSN);
     db.AddInParameter(comm,"@Email",DbType.String,user.Email);
     db.ExecuteNonQuery(comm);
     int result = (int)db.GetParameterValue(comm, "@ReturnValue");
     return result == 0;
 }
        /// <summary>
        /// �����û�������Ϣ
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSaveUserInfo_Click(object sender, EventArgs e)
        {
            AspnetUserExtInfo user = new AspnetUserExtInfo();

            user.UserName = lblUserId.Text;
            user.TrueName = txtTrueName.Text.Trim();
            user.Email = txtEmail.Text.Trim();
            user.QQ = txtQQ.Text.Trim();
            user.MSN = txtMSN.Text.Trim();
            user.Mobile = txtMobile.Text.Trim();
            user.IdCard = txtIdCard.Text.Trim();
            user.TelePhone = txtPhone.Text.Trim();

            if (AspnetUserExt.SaveUserExt(user))
            {
                lblSaveUserInfoResult.Text = "����ɹ�";
            }
            else
            {
                lblSaveUserInfoResult.Text = "����ʧ��";
            }
        }
 public static bool SaveUserExt(AspnetUserExtInfo user)
 {
     return _provider.Save(user);
 }
 public static bool SaveUserExt(AspnetUserExtInfo user)
 {
     return(_provider.Save(user));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 存储用户扩展信息
 /// </summary>
 public abstract bool Save(AspnetUserExtInfo user);