62,041
社区成员
发帖
与我相关
我的任务
分享
public void UpdateWithLog(T entity, Guid creatorGuid)
{
dbContext.Entry(entity).State = EntityState.Modified;
//dbContext.Set<T>().Attach(entity);
//dbContext.Entry(entity).State = EntityState.Modified;
dbContext.Set<ModelLog>().Add(GetModelLog(entity, creatorGuid, "Update"));
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (!string.IsNullOrEmpty(Request.QueryString["userid"]) && CheckValue.IsInteger(Request.QueryString["userid"]))
{
LoadInfo();
}
else
{
this.btnSave.Enabled = false;
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
BLL.UserService bll = new BLL.UserService();
Model.User model = (Model.User)ViewState["model"];
//Model.User model = bll.GetById(int.Parse(Request.QueryString["userid"]));
model.OrganizationID = int.Parse(this.OrganizationList.SelectedValue);
bll.UpdateWithLog(model);
ShowMsgHelper.ShowScript("art.dialog({title: \"恭喜,操作成功\", content: \"恭喜,操作成功,用户信息已成功更新!\", ok:function(){ art.dialog.close(); art.dialog.opener.ListGrid(); }});");
}
private void LoadInfo()
{
BLL.UserService bll = new BLL.UserService();
BLL.UserTypeService usertype = new BLL.UserTypeService();
BLL.OrganizationService org = new BLL.OrganizationService();
Model.User model = bll.GetById(int.Parse(Request.QueryString["userid"]));
CSS = model.Sex ? "man" : "woman";
OfficeID = model.OfficeID;
this.ltlUserName.Text = model.UserName;
this.ltlRealName.Text = model.RealName;
this.ltlUserType.Text = usertype.GetById(model.UserTypeID).UserTypeName;
this.ltlOrganizationName.Text = org.GetOrganizationFullName(model.OrganizationID);
ViewState["model"] = model;
this.OrganizationList.SelectedValue = model.OrganizationID.ToString();
}