protected void btnAdd_Click(object sender, EventArgs e) { STreeFunctionData model = new STreeFunctionData(); STreeFunctionBB treeFunctionBB = new STreeFunctionBB(); try { //项目编号不允许重复 string strWhere = "nodeId=" + this.NodeId.ToString() + " and functionNo='" + this.functionNo.Text + "'"; if (treeFunctionBB.GetList(strWhere).Tables[0].Rows.Count > 0) { this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"该功能编号已存在,请重新输入!\");", true); this.functionNo.Focus(); return; } model.nodeId= this.NodeId; model.functionNo= this.functionNo.Text; model.functionNm= this.functionNm.Text; treeFunctionBB.AddRecord(model); } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { treeFunctionBB.Dispose(); } this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string idValue = Request.Params["id"]; if (idValue != null) { int id = int.Parse(idValue); //删除节点的同时,删除TreeFunction、角色权限、人员权限 STreeData treeData = new STreeData(); STreeBB treeBB = new STreeBB(); STreeFunctionBB treeFunctionBB = new STreeFunctionBB(); PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB(); PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB(); try { treeData = treeBB.GetModel(id); treeBB.DeleteRecord(id); treeFunctionBB.DeleteRecordByNode(id); rolePermissionsBB.DeleteRecordByItem(treeData.itemNo); empPermissionsBB.DeleteRecordByItem(treeData.itemNo); this.RefreshApplicationPageUrlTable(); this.RefreshApplicationTreeTable(); ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true); } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { treeBB.Dispose(); treeFunctionBB.Dispose(); rolePermissionsBB.Dispose(); empPermissionsBB.Dispose(); } } } }
protected void btnAdd_Click(object sender, EventArgs e) { STreeFunctionData treeFunctionData = new STreeFunctionData(); STreeFunctionBB treeFunctionBB = new STreeFunctionBB(); try { //ɾ����ǰ�˵����й��� treeFunctionBB.DeleteRecordByNode(this.NodeId); //�������� foreach (DataListItem item in this.DataList1.Items) { CheckBox checkBox = (CheckBox)item.FindControl("typeNm"); if (checkBox.Checked) { HtmlInputHidden hid = (HtmlInputHidden)item.FindControl("typeNo"); string typeNo = hid.Value; treeFunctionData.nodeId = this.NodeId; treeFunctionData.functionNo = typeNo; treeFunctionData.functionNm = checkBox.Text; treeFunctionBB.AddRecord(treeFunctionData); } } } catch (Exception ex) { this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true); return; } finally { treeFunctionBB.Dispose(); } this.ClientScript.RegisterStartupScript(this.GetType(), "Close", "window.close();", true); }
/// <summary> /// 根据当前人员绑定DataList /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB(); STreeFunctionBB treeFunctionBB = new STreeFunctionBB(); HEemployeeBB eemployeeBB = new HEemployeeBB(); SCommBB commBB = new SCommBB(); DataSet perDs = new DataSet(); DataSet ds = new DataSet(); try { HtmlInputHidden hid = (HtmlInputHidden)e.Item.FindControl("nodeId"); string nodeId = hid.Value; Label label = (Label)e.Item.FindControl("itemNo"); string itemNo = label.Text; if (itemNo.IndexOf('-') >= 0) { itemNo = itemNo.Substring(itemNo.LastIndexOf('-') + 1); } //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配 if (this.IsHaveRole(1)) { ds = treeFunctionBB.GetList("nodeId=" + nodeId); } else { ds = commBB.Query("select distinct permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId=" + this.currentUser.empId.ToString() + " and nodeId=" + nodeId + " order by permissionsTypeId"); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow row = ds.Tables[0].Rows[i]; //添加文本“<TD></TD>"以控制格式 HtmlGenericControl td = new HtmlGenericControl(); td.InnerHtml = "</td><td>"; e.Item.Controls.Add(td); CheckBox checkBox = new CheckBox(); checkBox.ID = "checkBox" + i.ToString(); checkBox.Text = row["functionNm"].ToString(); checkBox.ToolTip = row["functionNo"].ToString(); //给checkBox赋值 if (eemployeeBB.HasPermissions(this.EmpId, itemNo, row["functionNo"].ToString())) { checkBox.Checked = true; } e.Item.Controls.Add(checkBox); } } finally { empPermissionsBB.Dispose(); treeFunctionBB.Dispose(); eemployeeBB.Dispose(); commBB.Dispose(); } }
/// <summary> /// 初始化默认权限数据 /// </summary> private void InitPermissionData() { PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB(); STreeFunctionBB treeFunctionBB = new STreeFunctionBB(); SCommBB commBB = new SCommBB(); try { //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配 if (this.IsHaveRole(1)) { this.treeFunctionDs = treeFunctionBB.GetList(""); } else { this.treeFunctionDs = commBB.Query("select distinct nodeId,permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId=" + this.currentUser.empId.ToString() + " order by permissionsTypeId"); } //获取岗位具体权限 this.rolePermissionsDs = rolePermissionsBB.GetList("roleId=" + this.RoleId.ToString()); } finally { rolePermissionsBB.Dispose(); treeFunctionBB.Dispose(); commBB.Dispose(); } }
/// <summary> /// ���ݵ�ǰ��ɫ��Ȩ������grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { STreeFunctionBB treeFunctionBB = new STreeFunctionBB(); DataSet ds = new DataSet(); try { HtmlInputHidden hid = (HtmlInputHidden)e.Item.FindControl("typeNo"); string typeNo = hid.Value; CheckBox checkBox = (CheckBox)e.Item.FindControl("typeNm"); //��checkBox��ֵ ds = treeFunctionBB.GetList("nodeId=" + this.NodeId.ToString() + " and functionNo='" + typeNo + "'"); if (ds.Tables[0].Rows.Count > 0) { checkBox.Checked = true; } } finally { treeFunctionBB.Dispose(); } }