当前位置: 首页>>代码示例>>C#>>正文


C# User.Update方法代码示例

本文整理汇总了C#中User.Update方法的典型用法代码示例。如果您正苦于以下问题:C# User.Update方法的具体用法?C# User.Update怎么用?C# User.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在User的用法示例。


在下文中一共展示了User.Update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            String tmp = Context.Request["verify"].ToString();
            if (tmp.Length > 0)
            {
                String[] guid = tmp.Split('-');
                if (guid.Length == 5 && guid[4].Length == 12)
                {
                    int id = Convert.ToInt32(guid[4].Substring(guid[4].Length - 4, 4));
                    Fpp.WebModules.Business.User user = new User(id);
                    if (user.EmailAddress.Length > 0)
                    {

                        var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                        var stringChars = new char[8];
                        var random = new Random();

                        for (int i = 0; i < stringChars.Length; i++)
                        {
                            stringChars[i] = chars[random.Next(chars.Length)];
                        }

                        user.Password = new String(stringChars);
                        user.Update();

                        sendEmail(user, "");
                        Session["message"] = "<h2>Thank you for getting in touch.</h2><p>An email has been sent to you with your password.</p>";
                    }
                    else
                    {
                    }
                }

            }
            tmp = Context.Request["quick"].ToString();
            if (tmp.Length > 0)
            {
                String[] guid = tmp.Split('-');
                if (guid.Length == 5 && guid[4].Length == 12)
                {
                    int id = Convert.ToInt32(guid[4].Substring(guid[4].Length - 4, 4));
                    Fpp.WebModules.Business.User user = new User(id);
                }
            }
            Response.Redirect("/");
        }
开发者ID:woofwoof88,项目名称:first-place-processing,代码行数:46,代码来源:default.aspx.cs

示例2: EditUser

 public void EditUser(User SelectedUser, string NewFirstName, string NewLastName, string NewUserName, string NewPassword, string NewEmail)
 {
     SelectedUser.Update(
         new User()
         {
             FirstName = NewFirstName,
             LastName = NewLastName,
             UserName = NewUserName,
             Password = NewPassword,
             Email = NewEmail
         });
 }
开发者ID:kirillbeldyaga,项目名称:GameIntoMusic,代码行数:12,代码来源:Controller.cs

示例3: SaveUser4Page

    private void SaveUser4Page()
    {
        using (Session session = new Session())
        {
            try
            {
                User user = new User();
                user.UserName = this.txtUserName.Text.Trim();
                user.Password = this.txtPassword.Text;
                user.Email = txtEmail.Text.Trim();
                user.Ext = txtExt.Text.Trim();
                user.FullName = txtFullName.Text.Trim();
                if(Org.UseDefaultOrg(session))
                    user.OrgId = Org.DefaultOrg(session);
                else
                    user.OrgId = Cast.Int(this.txtOrgId.Text, -1);
                user.Status = Cast.Enum<UserStatus>(this.rblStatus.SelectedValue);
                user.UserType = Cast.Enum<OrgType>(this.ddlUserType.SelectedValue);
                user.ModifyBy = SecuritySession.CurrentUser.UserId;
                user.ModifyTime = DateTime.Now;

                if (IsAddNew())
                {
                    //检查帐号是否重复
                    int existsUserCount = session.CreateEntityQuery<Magic.Sys.User>()
                        .Where(Magic.Framework.ORM.Query.Exp.Eq("UserName", user.UserName))
                        .Count();
                    if (existsUserCount > 0)
                    {
                        WebUtil.ShowMsg(this, string.Format("用户帐号{0}已经存在", user.UserName), "错误");
                        return; //这里的return语句,using会保证session释放
                    }
                    //UserId是自增长主键,新增时不要设置它的值,新增完毕后框架会自动设置好这个值
                    user.CreateBy = SecuritySession.CurrentUser.UserId;
                    user.CreateTime = DateTime.Now;
                    user.Create(session);
                }
                else
                {
                    user.UserId = Cast.Int(this.txtUserId.Value, -1); //UserId是主键,更新时需要设置
                    user.Update(session, "Email", "Ext", "FullName", "OrgId", "Password", "Status", "UserType", "ModifyBy", "ModifyTime");
                }
                this.txtUserId.Value = user.UserId.ToString(); //如果是新增用户,新增完毕后将用户ID设置到以页面隐藏控件(新增后UserId已经被赋值了)
                WebUtil.ShowMsg(this, "用户保存成功", "操作成功");
            }
            catch (Exception ex)
            {
                logger.Info("保存User", ex);
                WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
            }
        }
    }
开发者ID:XtremeKevinChow,项目名称:rdroad,代码行数:52,代码来源:UserEdit.aspx.cs


注:本文中的User.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。