ZHJA_HJGL/HJGL_ZH/FineUIPro.Web/common/BaseInfo/AudiFlowSet.aspx.cs

242 lines
7.9 KiB
C#

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("你确定要删除选中的&nbsp;<b><script>{0}</script></b>&nbsp;行数据吗?", 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
/// <summary>
/// 加载树
/// </summary>
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);
}
}
}
/// <summary>
/// 添加菜单树
/// </summary>
/// <param name="nodes"></param>
/// <param name="parentId"></param>
/// <param name="type"></param>
private void BoundTree(TreeNodeCollection nodes, string systemId, string superMenu, bool IsEnableClickEvent)
{
List<Model.Sys_Menu> 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
/// <summary>
/// 点击TreeView
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void tvAudiFlow_NodeCommand(object sender, TreeCommandEventArgs e)
{
if (this.tvAudiFlow.SelectedNodeID != "0" && this.tvAudiFlow.SelectedNode != null)
{
BindGrid();
}
}
#endregion
#endregion
#region
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// Grid双击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 批量删除数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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
/// <summary>
/// 关闭弹出窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
#endregion
/// <summary>
/// 得到角色名称字符串
/// </summary>
/// <param name="bigType"></param>
/// <returns></returns>
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
/// <summary>
/// 获取按钮权限
/// </summary>
/// <param name="button"></param>
/// <returns></returns>
private bool GetButtonPower(string button)
{
return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.AudiFlowMenuId, button);
}
}
}