本文整理汇总了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("/");
}
示例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
});
}
示例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, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
}
}
}