protected void GridDpt_RowCommand(object sender, GridCommandEventArgs e) { int deptID = GetSelectedDataKeyID(GridDpt); if (e.CommandName == "Delete") { if (TreeDpt.FindNode(deptID.ToString()).Nodes.Count > 0) { Alert.ShowInTop("请先删除该部门下子部门!"); return; } BLL.tUsers uBLL = new BLL.tUsers(); if (uBLL.GetModelList(string.Format(" roleCode=10 and dptId={0}", deptID.ToString())).Count > 0) { Alert.ShowInTop("超级用户所在部门无法删除!"); return; } BLL.tDepartMent BLL = new Maticsoft.BLL.tDepartMent(); bool isTrue = BLL.Delete(deptID); if (!isTrue) { Alert.ShowInTop("删除失败!"); return; } else { BindTree(); LoadData(); } } if (e.CommandName == "Edit") { Window1.Title = "部门管理"; string openUrl = String.Format("./DptMentEdit.aspx?dptId={0}", HttpUtility.UrlEncode(deptID.ToString())); PageContext.RegisterStartupScript(Window1.GetSaveStateReference(deptID.ToString()) + Window1.GetShowReference(openUrl)); } }
protected void LoadData() { Maticsoft.BLL.tDepartMent BLL = new Maticsoft.BLL.tDepartMent(); string sortField = GridDpt.SortField; string sortDirection = GridDpt.SortDirection; if (TreeDpt.SelectedNode == null) { GridDpt.RecordCount = BLL.GetRecordCount(" dptId<>10000 "); DataView view = BLL.GetListByPage(" dptId<>10000 ", " dptId asc ", GridDpt.PageIndex * GridDpt.PageSize, (GridDpt.PageIndex + 1) * GridDpt.PageSize).Tables[0].DefaultView; view.Sort = String.Format("{0} {1}", sortField, sortDirection); GridDpt.DataSource = view.ToTable(); } else { string NodeId = TreeDpt.SelectedNodeID; GridDpt.RecordCount = BLL.GetRecordCount(" dptFatherId=" + NodeId); DataView view = BLL.GetListByPage(" dptFatherId=" + NodeId, " dptId asc ", GridDpt.PageIndex * GridDpt.PageSize, (GridDpt.PageIndex + 1) * GridDpt.PageSize).Tables[0].DefaultView; view.Sort = String.Format("{0} {1}", sortField, sortDirection); GridDpt.DataSource = view.ToTable(); } GridDpt.DataBind(); }
protected string GetDptName(string Rid) { Maticsoft.BLL.tDepartMent bll = new Maticsoft.BLL.tDepartMent(); Maticsoft.Model.tDepartMent model = bll.GetModel(int.Parse(Rid)); return(model.dptName); }