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 AudiFlowEdit : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { LoadData(); string menuId = Request.Params["menuId"]; string audiFlowId = Request.Params["audiFlowId"]; BindDropDownBox(); if (!string.IsNullOrEmpty(audiFlowId)) { var audit = BLL.AudiFlowService.GetAudiFlowsByFlowModuleAndAudiFlowId(menuId, audiFlowId); if (audit != null) { this.txtAudiFlowStep.Text = audit.AudiFlowStep.ToString(); this.txtAuditFlowName.Text = audit.AuditFlowName; if (audit.IsFlowEnd != null) { this.IsFlowEnd.Checked = Convert.ToBoolean(audit.IsFlowEnd); } DropDownBox1.Value = audit.RoleId; } } else { this.txtAudiFlowStep.Text = GetMaxId(); } } } protected void btnSave_Click(object sender, EventArgs e) { if (GetButtonPower(BLL.Const.BtnDelete)) { Model.AudiFlow flow = new Model.AudiFlow(); string[] roleIds = DropDownBox1.Values; bool? isAuditFlow = null; if (this.IsFlowEnd.Checked) { isAuditFlow = true; } else { isAuditFlow = false; } string menuId = Request.Params["menuId"]; string audiFlowId = Request.Params["audiFlowId"]; flow.AudiFlowStep = Convert.ToInt32(this.txtAudiFlowStep.Text); flow.AuditFlowName = this.txtAuditFlowName.Text.Trim(); flow.FlowModule = menuId; flow.RoleId = this.ConvertRole(roleIds); flow.IsFlowEnd = isAuditFlow; if (string.IsNullOrEmpty(audiFlowId)) { if (isAuditFlow == true) { if (!BLL.AudiFlowService.IsAuditFlowEnd(menuId, audiFlowId)) { flow.RoleId = null; BLL.AudiFlowService.AddAuditFlow(flow); BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加菜单流程信息"); } else { ShowNotify("流程步骤设置已完成,没有下一步骤!"); } } else { if (roleIds.Count() > 0) { BLL.AudiFlowService.AddAuditFlow(flow); BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "添加菜单流程信息"); } else { ShowNotify("请选择角色!"); } } } else { flow.AudiFlowId = audiFlowId; if (isAuditFlow == true) { if (BLL.AudiFlowService.IsAuditFlowEnd(menuId, audiFlowId)) { ShowNotify("流程已有完成步骤!"); } else { flow.RoleId = null; BLL.AudiFlowService.UpdateAuditFlow(flow); BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改菜单流程信息"); } } else { if (roleIds.Count() > 0) { BLL.AudiFlowService.UpdateAuditFlow(flow); BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "修改菜单流程信息"); } else { ShowNotify("请选择角色!"); } } } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } else { ShowNotify("您没有这个权限,请与管理员联系!"); } } /// /// 加载页面 /// private void LoadData() { btnClose.OnClientClick = ActiveWindow.GetHideReference(); } private void BindDropDownBox() { string strSql = @"select RoleId,RoleName from Sys_Role where IsAuditFlow=1 order by SortIndex"; DataTable tb = SQLHelper.GetDataTableRunText(strSql, null); RadioButtonList1.DataSource = tb; this.RadioButtonList1.DataTextField = "RoleName"; this.RadioButtonList1.DataValueField = "RoleId"; RadioButtonList1.DataBind(); } /// /// 得到角色ID字符串 /// /// /// protected string ConvertRole(string[] roleIds) { string roles = null; if (roleIds != null && roleIds.Count() > 0) { foreach (string roleId in roleIds) { roles += roleId + ","; } if (roles != string.Empty) { roles = roles.Substring(0, roles.Length - 1); ; } } return roles; } private string GetMaxId() { int maxId = 0; string str = "SELECT (ISNULL(MAX(AudiFlowStep),0)+1) from AudiFlow where FlowModule='" + Request.Params["menuId"] + "'"; maxId = BLL.SQLHelper.getIntValue(str); return maxId.ToString(); } /// /// 获取按钮权限 /// /// /// private bool GetButtonPower(string button) { return BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.AudiFlowMenuId, button); } protected void IsFlowEnd_CheckedChanged(object sender, CheckedEventArgs e) { if (IsFlowEnd.Checked) { DropDownBox1.Value = null; DropDownBox1.Text = string.Empty; } } } }