protected void btnAdd_Click(object sender, EventArgs e) { if (this.FormCheck()) { try { A_Role role = new A_Role(); role.A_RoleName = this.txtRoleName.Text.Trim(); role.A_IFEdit = this.CbIfEdit.Checked; if (this.roleSer.Add(role) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加成功!');</script>"); this.txtRoleName.Text = ""; CbIfEdit.Checked = false; this.txtRoleName.Focus(); } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('添加失败!');</script>"); } } catch (Exception ex) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + ex.Message + "!');</script>"); } } }
public P_RolePermission() { Message = string.Empty; Role = new A_Role(); ListA_Function = new List <A_Function>(); ListA_Function_Basic = new List <A_Function>(); ListA_Function_Addition = new List <A_Function>(); ListP_Object = new List <P_Object>(); ListA_ObjectFunction = new List <P_A_ObjectFunction>(); }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { if (base.Request["RoleId"] != null) { this.btnAdd.Visible = false; A_Role ROLE = this.roleSer.GetModelList("A_RoleId=" + base.Request["RoleId"])[0]; this.txtRoleName.Text = ROLE.A_RoleName; CbIfEdit.Checked = ROLE.A_IFEdit; } else { this.btnUpdate.Visible = false; } } }
protected void btnUpdate_Click(object sender, EventArgs e) { if (this.FormCheck()) { try { A_Role role = new A_Role(); role.A_RoleName = this.txtRoleName.Text.Trim(); role.A_IFEdit = this.CbIfEdit.Checked; role.A_RoleId = Convert.ToInt32(base.Request["RoleId"]); roleSer.Update(role); base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('修改成功!');</script>"); } catch (Exception ex) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + ex.Message + "!');</script>"); } } }
//新增和修改仓库设置 public void AddOrUpdate(RoleModel Models) { using (var db = new HTJKEntities()) { if (Models.Id > 0) { var table = db.A_Role.Where(k => k.Id == Models.Id).SingleOrDefault(); table.UserId = Models.UserId; table.UserName = Models.UserName; table.MenuList = Models.MenuList; } else { A_Role table = new A_Role(); table.UserId = Models.UserId; table.UserName = Models.UserName; table.MenuList = Models.MenuList; table.CreateTime = DateTime.Now; table.DeleteFlag = true; db.A_Role.Add(table); } db.SaveChanges(); } }