using BLL; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.common.BaseInfo { public partial class AudiFlowSet : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { btnDelete.OnClientClick = Grid1.GetNoSelectionAlertReference("请至少选择一项!"); btnDelete.ConfirmText = String.Format("你确定要删除选中的  行数据吗?", Grid1.GetSelectedCountReference()); InitTreeMenu();//加载树 } } private void BindGrid() { string strSql = @"select * from AudiFlow where FlowModule=@FlowModule order by AudiFlowStep"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@FlowModule",this.tvAudiFlow.SelectedNodeID) }; DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.DataSource = tb; Grid1.DataBind(); } #region /// /// 加载树 /// private void InitTreeMenu() { this.tvAudiFlow.Nodes.Clear(); TreeNode rootNode = new TreeNode(); rootNode.Text = "审批流程菜单"; rootNode.NodeID = "0"; rootNode.Expanded = true; this.tvAudiFlow.Nodes.Add(rootNode); var sys = from x in Funs.DB.Sys_System where x.IsEnable == true orderby x.SorIndex select x; if (sys.Count() > 0) { TreeNode tn = null; foreach (var q in sys) { tn = new TreeNode(); tn.Text = q.SystemName; tn.NodeID = q.SystemId; rootNode.Nodes.Add(tn); BoundTree(tn.Nodes, q.SystemId, "0", false); } } } /// /// 添加菜单树 /// /// /// /// private void BoundTree(TreeNodeCollection nodes, string systemId, string superMenu, bool IsEnableClickEvent) { List menus = (from x in Funs.DB.Sys_Menu where x.SuperMenu==superMenu && x.MenuModule==systemId && x.IsAudiFlow==true orderby x.SortIndex select x).ToList(); if (menus.Count() > 0) { TreeNode tn = null; foreach (var q in menus) { tn = new TreeNode(); tn.Text = q.MenuName; tn.NodeID = q.MenuId; tn.EnableClickEvent = IsEnableClickEvent; nodes.Add(tn); BoundTree(tn.Nodes, q.MenuModule, q.MenuId, true); } } } #region 点击TreeView /// /// 点击TreeView /// /// /// protected void tvAudiFlow_NodeCommand(object sender, TreeCommandEventArgs e) { if (this.tvAudiFlow.SelectedNodeID != "0" && this.tvAudiFlow.SelectedNode != null) { BindGrid(); } } #endregion #endregion #region 排序 /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); } #endregion protected void btnNew_Click(object sender, EventArgs e) { if (this.tvAudiFlow.SelectedNode != null) { var q = from x in Funs.DB.Sys_Menu where x.SuperMenu == this.tvAudiFlow.SelectedNodeID select x; if (q.Count() == 0 && this.tvAudiFlow.SelectedNodeID.Length > 2) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("AudiFlowEdit.aspx?menuId={0}", tvAudiFlow.SelectedNodeID, "编辑 - "))); } else { Alert.ShowInTop("请选择末级菜单!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("请选择菜单!", MessageBoxIcon.Warning); } } #region 得到角色字符串 /// /// Grid双击事件 /// /// /// protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e) { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("AudiFlowEdit.aspx?menuId={0}&audiFlowId={1}", tvAudiFlow.SelectedNodeID, Grid1.SelectedRowID, "编辑 - "))); } #region 删除数据 /// /// 批量删除数据 /// /// /// protected void btnDelete_Click(object sender, EventArgs e) { if (GetButtonPower(BLL.Const.BtnDelete)) { if (Grid1.SelectedRowIndexArray.Length > 0) { foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); BLL.AudiFlowService.DeleteAuditFlow(rowID); } BindGrid(); BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "删除审批流程信息"); ShowNotify("删除数据成功!(表格数据已重新绑定)"); } } else { ShowNotify("您没有这个权限,请与管理员联系!"); } } #endregion #region 关闭弹出窗口 /// /// 关闭弹出窗口 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { BindGrid(); } #endregion /// /// 得到角色名称字符串 /// /// /// protected string ConvertRole(object roleIds) { string roleName = string.Empty; if (roleIds != null) { string[] roles = roleIds.ToString().Split(','); foreach (string roleId in roles) { var q = BLL.Sys_RoleService.GetRole(roleId); if (q != null) { roleName += q.RoleName + ","; } } if (roleName != string.Empty) { roleName = roleName.Substring(0, roleName.Length - 1); ; } } return roleName; } #endregion /// /// 获取按钮权限 /// /// /// private bool GetButtonPower(string button) { return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.AudiFlowMenuId, button); } } }