protected void btnSave_Click(object sender, EventArgs e) { PRoleData model = new PRoleData(); PRoleBB roleBB = new PRoleBB(); if (this.roleName.Text == "") { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"��λ���Ʊ�����д!\");", true); } else { try { if (this.State == "1") { this.SetModel(ref model); //model.isrtEmpId = this.currentUser.empId; //model.isrtDt = DateTime.Now.ToString(); this.IdValue = roleBB.AddRecord(model); } else if (this.State == "2") { model = roleBB.GetModel(this.IdValue); this.SetModel(ref model); if (model.isSys) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"����λΪϵͳ��λ�������ġ�\");", true); return; } roleBB.ModifyRecord(model); } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { roleBB.Dispose(); } Response.Redirect("PRoleList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false); } }
//邦定角色名称 private void BindRole() { PRoleData roleData = new PRoleData(); PRoleBB roleBB = new PRoleBB(); try { roleData = roleBB.GetModel(this.RoleId); this.roleNm.Text = "当前角色:" + roleData.roleName; } finally { roleBB.Dispose(); } }
/// <summary> /// ɾ�� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDel_Click(object sender, EventArgs e) { PRoleBB roleBB = new PRoleBB(); PUserRoleBB userRoleBB = new PUserRoleBB(); PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB(); //��ȡѡ�е�����Id try { foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); int id = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["id"]); if (chkId.Checked == true) { PRoleData roleData = new PRoleData(); roleData = roleBB.GetModel(id); if (roleData.isSys) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"����λΪϵͳ��λ������ɾ����\");", true); return; } else { //ɾ����ɫ��ͬʱ��ɾ����Ա��ɫ����ɫȨ�� roleBB.DeleteRecord(id); userRoleBB.DeleteRecordByRole(id); rolePermissionsBB.DeleteRecordByRole(id, 2); } } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { roleBB.Dispose(); userRoleBB.Dispose(); rolePermissionsBB.Dispose(); } this.BindGrid(); }
private void ShowInfo(int id) { PRoleBB roleBB = new PRoleBB(); PRoleData model = new PRoleData(); try { model = roleBB.GetModel(id); this.roleName.Text = model.roleName; this.isSys.Checked = model.isSys; this.mark.Text = model.mark; } finally { roleBB.Dispose(); } }
/// <summary> /// �� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEdit_Click(object sender, EventArgs e) { //��ȡѡ�е�����Id foreach (GridViewRow gvrow in this.grid.Rows) { CheckBox chkId = (CheckBox)gvrow.FindControl("chkId"); int id = Convert.ToInt32(this.grid.DataKeys[gvrow.RowIndex]["id"]); if (chkId.Checked == true) { using (PRoleBB roleBB = new PRoleBB()) { PRoleData roleData = new PRoleData(); roleData = roleBB.GetModel(id); if (roleData.isSys) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"����λΪϵͳ��λ�������ġ�\");", true); return; } else { Response.Redirect("PRole.aspx?state=2&itemNo=" + this.itemNo + "&pTypeNo=edit" + "&id=" + id, false); } } } } this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"��ѡ��һ����¼!\");", true); }