/// <summary> /// 绑定部门权限 /// </summary> protected void BindUserPermissions() { List <User_Permissions> bPaseList = new User_PermissionsBLL().GetListByCpyNo(mUser.CpyNo); ddlUserPermissions.DataSource = bPaseList; ddlUserPermissions.DataTextField = "DeptName"; ddlUserPermissions.DataValueField = "id"; ddlUserPermissions.DataBind(); }
/// <summary> /// 绑定数据 /// </summary> public void BindUserPermissions() { try { List <User_Permissions> iPost = new User_PermissionsBLL().GetListByCpyNo(mUser.CpyNo); repUserPermissions.DataSource = iPost; repUserPermissions.DataBind(); } catch (Exception ex) { } }
/// <summary> /// 绑定部门权限 /// </summary> protected void BindUserPermissions() { List <User_Permissions> bPaseList = new User_PermissionsBLL().GetListByCpyNo(mUser.CpyNo); //ddlBM.Items.Add(new ListItem("-全部-", "0")); //for (int i = 0; i < bPaseList.Count; i++) //{ // ddlBM.Items.Add(new ListItem(bPaseList[i].DeptName, bPaseList[i].id.ToString())); //} ddlBM.Items.Insert(0, new ListItem("--选择--", "0")); ddlBM.DataSource = bPaseList; ddlBM.DataTextField = "DeptName"; ddlBM.DataValueField = "id"; ddlBM.DataBind(); }
/// <summary> /// 修改时,绑定原来已有的页面权限 /// </summary> /// <param name="id">当前ID</param> private void GetPostDataBind(string id) { try { #region 权限集合 List <User_Permissions> UPermissions = new User_PermissionsBLL().GetListById(Guid.Parse(id));//mUser.DeptId User_Permissions mPost = UPermissions[0]; //权限集合 if (mPost != null) { this.txtRemark.Text = mPost.Remark; string[] value = mPost.Permissions.Split(','); //遍历权限 foreach (TreeNode childnodes in trvPagePower.Nodes) { foreach (TreeNode childnodes2 in childnodes.ChildNodes) { foreach (TreeNode childnodes3 in childnodes2.ChildNodes) { for (int i = 0; i < value.Length; i++) { if (value[i] == childnodes3.Value) { childnodes.Checked = true; childnodes2.Checked = true; childnodes.Expanded = true; childnodes2.Expanded = true; childnodes3.Expanded = true; childnodes3.Checked = true; } } } } } } #endregion } catch (Exception ex) { } }
/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { string msg = ""; bool result = false; try { string strDeptName = txtDeptName.Text.Trim(); if (string.IsNullOrEmpty(strDeptName)) { msg = "该名称不能为空!"; } List <User_Permissions> iPost = new User_PermissionsBLL().GetListByCpyNo(mUser.CpyNo); foreach (var item in iPost) { if (item.DeptName == strDeptName && hidId.Value == "") { msg = "添加失败,该名称已经存在!"; break; } //else if (item.DeptName == strDeptName && hidId.Value != item.id.ToString()) //{ // msg = "修改失败,该名称已经存在!"; // break; //} } if (msg == "") { if (hidId.Value == "") { #region 添加 User_Permissions model = new User_Permissions(); model.id = Guid.NewGuid(); model.CpyNo = mUser.CpyNo; model.DeptName = strDeptName; model.ParentIndex = 1; model.DeptIndex = 1; model.Remark = txtRemark.Text.Trim(); model.Permissions = GetPermissions(); model.A1 = 1; model.A2 = 0.00M; model.A3 = DateTime.Now; model.A4 = ""; model.A5 = ""; result = (bool)baseDataManage.CallMethod("User_Permissions", "Insert", null, new Object[] { model }); if (result) { msg = "添加成功!"; } else { msg = "添加失败!"; } #endregion } else { #region 修改 IHashObject parameter = new HashObject(); //User_Permissions model = new User_Permissions(); parameter.Add("id", Guid.Parse(hidId.Value)); parameter.Add("DeptName", strDeptName); parameter.Add("Permissions", GetPermissions()); parameter.Add("Remark", txtRemark.Text.Trim()); result = (bool)baseDataManage.CallMethod("User_Permissions", "Update", null, new Object[] { parameter }); if (result) { msg = "修改成功!"; } else { msg = "修改失败!"; } #endregion } } } catch (Exception) { msg = "操作失败!"; } finally { ScriptManager.RegisterStartupScript(this, GetType(), DateTime.Now.Ticks.ToString(), "showdialog('" + msg + "');", true); } }