protected void btnSave_Click(object sender, EventArgs e) { bool ret = false; if (State.Equals("new", StringComparison.OrdinalIgnoreCase)) { ret = AddProcessNode(CreateObject()); if (ret) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>AlertAndNewLoad('添加成功');</script>"); RefreshClose(this.Page, "/Admin/ProcessNodeManage.aspx"); } else { ExecAlertScritp("添加失败"); } } else if (State.Equals("edit", StringComparison.OrdinalIgnoreCase)) { ProcessNodeInfo info = CreateObject(); info.NodeID = new Guid(NodeID); ret = UpdateProcessNode(info); if (ret) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>AlertAndNewLoad('更新成功');</script>"); RefreshClose(this.Page, "/Admin/ProcessNodeManage.aspx"); } else { ExecAlertScritp("更新失败"); } } }
/// <summary> /// 取得指定的审批节点 /// </summary> /// <param name="nodeIds"></param> /// <returns></returns> public IList <ProcessNodeInfo> GetApproveNodesByNodeIds(string nodeIds) { DataSet ds = dal.GetApproveNodesByNodeIds(nodeIds); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { List <ProcessNodeInfo> pnList = new List <ProcessNodeInfo>(); foreach (DataRow dr in ds.Tables[0].Rows) { ProcessNodeInfo info = new ProcessNodeInfo(); info.NodeID = new Guid(dr["NodeID"].ToString()); info.ProcessID = dr["ProcessID"].ToString(); info.NodeName = dr["NodeName"].ToString(); info.IsAllowMeet = Convert.ToBoolean(dr["IsAllowMeet"]); info.IsAllowEndorsement = Convert.ToBoolean(dr["IsAllowEndorsement"]); info.Notification = dr["Notification"].ToString(); info.WayBack = Convert.ToInt32(dr["WayBack"]); info.IsAllowSpecialApproval = Convert.ToBoolean(dr["IsAllowSpecialApproval"]); info.ApproveRule = Convert.ToInt32(dr["ApproveRule"]); info.DeclineRule = Convert.ToInt32(dr["DeclineRule"]); info.State = Convert.ToBoolean(dr["State"]); info.CreatedOn = Convert.ToDateTime(dr["CreatedOn"]); info.CreatedBy = dr["CreatedBy"].ToString(); pnList.Add(info); } return(pnList); } return(null); }
/// <summary> /// 当为编辑状态(edit)时绑定数据 /// </summary> private void BindData() { ProcessRuleBLL bll = new ProcessRuleBLL(); ProcessNodeInfo pn = bll.GetProcessNodeByNodeID(NodeID); if (pn != null) { txtNodeName.Text = pn.NodeName; //cbMeet.Checked = pn.IsAllowMeet; //cbEndorsement.Checked = pn.IsAllowEndorsement; //cbIsAllowSpecialApproval.Checked = pn.IsAllowSpecialApproval; //txtApproveRule.Text = pn.ApproveRule.ToString(); //txtDeclineRule.Text = pn.DeclineRule.ToString(); txtURL.Text = pn.URL; txtNotification.Text = pn.Notification; txtOrderNo.Text = pn.OrderNo.ToString(); if (pn.WayBackNodeID != Guid.Empty) { foreach (ListItem li in ddlWayBack.Items) { if (li.Value.Equals(pn.WayBackNodeID.ToString(), StringComparison.OrdinalIgnoreCase)) { li.Selected = true; break; } } } //绑定加权方式 foreach (ListItem li in ddlWeighted.Items) { if (li.Value.Equals(pn.WeightedType, StringComparison.OrdinalIgnoreCase)) { li.Selected = true; break; } } txtSamplingRate.Text = pn.SamplingRate; if (pn.DepartCode != "") { ListItem listItem = new ListItem(pn.DepartName, pn.DepartCode); ddlDept.Items.Add(listItem); } //所属部门 //foreach (ListItem li in ddlDept.Items) //{ // if (li.Value.Equals(pn.DepartCode, StringComparison.OrdinalIgnoreCase)) // { // li.Selected = true; // break; // } //} } }
/// <summary> /// 通过processId取得流程审批节点 /// </summary> /// <param name="processId"></param> /// <returns></returns> public List <ProcessNodeInfo> GetProcessNodesByProcessID(string processId) { List <ProcessNodeInfo> pnList = new List <ProcessNodeInfo>(); //Guid ProcessID = Guid.Empty; //try //{ // ProcessID = new Guid(processId); //} //catch //{ // return null; //} DataSet ds = dal.GetProcessNodesByProcessID(processId); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { ProcessNodeInfo info = new ProcessNodeInfo(); info.NodeID = new Guid(dr["NodeID"].ToString()); info.ProcessID = dr["ProcessID"].ToString(); info.NodeName = dr["NodeName"].ToString(); info.IsAllowMeet = Convert.ToBoolean(dr["IsAllowMeet"]); info.IsAllowEndorsement = Convert.ToBoolean(dr["IsAllowEndorsement"]); info.Notification = dr["Notification"].ToString(); info.WayBack = Convert.ToInt32(dr["WayBack"]); info.IsAllowSpecialApproval = Convert.ToBoolean(dr["IsAllowSpecialApproval"]); info.ApproveRule = Convert.ToInt32(dr["ApproveRule"]); info.DeclineRule = Convert.ToInt32(dr["DeclineRule"]); info.State = Convert.ToBoolean(dr["State"]); info.CreatedOn = Convert.ToDateTime(dr["CreatedOn"]); info.CreatedBy = dr["CreatedBy"].ToString(); info.URL = dr["URL"].ToString(); if (dr["WayBackNodeID"] == DBNull.Value) { info.WayBackNodeID = Guid.Empty; } else { info.WayBackNodeID = new Guid(dr["WayBackNodeID"].ToString()); } info.OrderNo = Convert.ToInt32(dr["OrderNo"]); pnList.Add(info); } } return(pnList); }
/// <summary> /// 保存审批节点 /// </summary> /// <param name="context"></param> /// <returns></returns> private string SaveSPNode(HttpContext context) { string notification = context.Request.Form["notification"]; string nodeName = context.Request.Form["nodeName"]; string url = context.Request.Form["url"]; string wayBack = context.Request.Form["waybacknodeId"]; ProcessNodeInfo info = new ProcessNodeInfo(); info.ProcessID = context.Request.Form["ProcessID"]; info.State = true; info.ApproveRule = 1; info.DeclineRule = 1; info.NodeName = nodeName; info.IsAllowMeet = true; info.IsAllowEndorsement = true; info.Notification = notification; info.WayBack = 1; //退回方式去除 info.URL = url; info.WayBackNodeID = Guid.Empty; //if (string.IsNullOrEmpty(ddlWayBack.SelectedValue)) // info.WayBackNodeID = Guid.Empty; //else // info.WayBackNodeID = new Guid(ddlWayBack.SelectedValue); info.CreatedBy = context.Request.Form["createdBy"]; info.OrderNo = 1; //ProcessRuleBLL bll = new ProcessRuleBLL(); //bll.InsertProcessNode(info); return(Guid.NewGuid().ToString()); }
/// <summary> /// 更新节点 /// </summary> /// <param name="pn"></param> /// <returns></returns> private bool UpdateProcessNode(ProcessNodeInfo pn) { ProcessRuleBLL bll = new ProcessRuleBLL(); return(bll.UpdateProcessNode(pn)); }
/// <summary> /// 创建节点 /// </summary> /// <param name="pn"></param> /// <returns></returns> private bool AddProcessNode(ProcessNodeInfo pn) { ProcessRuleBLL bll = new ProcessRuleBLL(); return(bll.InsertProcessNode(pn)); }
/// <summary> /// 创建页面对象 /// </summary> /// <returns></returns> private ProcessNodeInfo CreateObject() { ProcessNodeInfo info = new ProcessNodeInfo(); info.ProcessID = ProcessID; info.State = true; //if (string.IsNullOrEmpty(txtApproveRule.Text)) info.ApproveRule = 1; //else // info.ApproveRule = Int32.Parse(txtApproveRule.Text); //if (string.IsNullOrEmpty(txtDeclineRule.Text)) info.DeclineRule = 1; //else // info.DeclineRule = Int32.Parse(txtDeclineRule.Text); info.NodeName = txtNodeName.Text; //info.IsAllowMeet = cbMeet.Checked; //info.IsAllowEndorsement = cbEndorsement.Checked; info.IsAllowMeet = true; info.IsAllowEndorsement = true; info.Notification = txtNotification.Text; info.WayBack = 1; //退回方式去除 //info.IsAllowSpecialApproval = cbIsAllowSpecialApproval.Checked; info.URL = txtURL.Text; if (string.IsNullOrEmpty(ddlWayBack.SelectedValue)) { info.WayBackNodeID = Guid.Empty; } else { info.WayBackNodeID = new Guid(ddlWayBack.SelectedValue); } info.WeightedType = ddlWeighted.SelectedValue; //加权 if (string.IsNullOrEmpty(txtSamplingRate.Text.Trim())) { info.SamplingRate = string.Empty; } else { info.SamplingRate = txtSamplingRate.Text.Trim(); } info.CreatedBy = Page.User.Identity.Name; try { info.OrderNo = Convert.ToInt32(txtOrderNo.Text.Trim()); } catch { info.OrderNo = 1; } if (ddlDept.SelectedItem != null) { info.DepartName = ddlDept.SelectedItem.Text; info.DepartCode = ddlDept.SelectedItem.Value; } else { info.DepartName = ""; info.DepartCode = ""; } return(info); }
/// <summary> /// 创建节点 /// </summary> /// <param name="pn"></param> /// <returns></returns> public bool InsertProcessNode(ProcessNodeInfo pn) { return(dal.InsertProcessNode(pn)); }
/// <summary> /// 更新审批节点 /// </summary> /// <param name="info"></param> /// <returns></returns> public bool UpdateProcessNode(ProcessNodeInfo info) { return(dal.UpdateProcessNode(info)); }
/// <summary> /// 通过NodeID取得节点信息 /// </summary> /// <param name="nodeId"></param> /// <returns></returns> public ProcessNodeInfo GetProcessNodeByNodeID(string nodeId) { Guid NodeID = Guid.Empty; try { NodeID = new Guid(nodeId); } catch { return(null); } DataSet ds = dal.GetProcessNodeByNodeID(NodeID); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow dr in ds.Tables[0].Rows) { ProcessNodeInfo info = new ProcessNodeInfo(); info.NodeID = new Guid(dr["NodeID"].ToString()); info.ProcessID = dr["ProcessID"].ToString(); info.NodeName = dr["NodeName"].ToString(); info.IsAllowMeet = Convert.ToBoolean(dr["IsAllowMeet"]); info.IsAllowEndorsement = Convert.ToBoolean(dr["IsAllowEndorsement"]); info.Notification = dr["Notification"].ToString(); info.WayBack = Convert.ToInt32(dr["WayBack"]); info.IsAllowSpecialApproval = Convert.ToBoolean(dr["IsAllowSpecialApproval"]); info.ApproveRule = Convert.ToInt32(dr["ApproveRule"]); info.DeclineRule = Convert.ToInt32(dr["DeclineRule"]); info.State = Convert.ToBoolean(dr["State"]); info.CreatedOn = Convert.ToDateTime(dr["CreatedOn"]); info.CreatedBy = dr["CreatedBy"].ToString(); info.URL = dr["URL"].ToString(); if (!string.IsNullOrEmpty(dr["WayBackNodeID"].ToString())) { info.WayBackNodeID = new Guid(dr["WayBackNodeID"].ToString()); } else { info.WayBackNodeID = Guid.Empty; } info.OrderNo = Convert.ToInt32(dr["OrderNo"]); info.WeightedType = dr["WeightedType"].ToString(); if (dr["SamplingRate"] == DBNull.Value) { info.SamplingRate = string.Empty; } else { info.SamplingRate = dr["SamplingRate"].ToString(); } //增加所属部门选择 if (dr["DepartName"] == DBNull.Value) { info.DepartName = string.Empty; } else { info.DepartName = dr["DepartName"].ToString(); } if (dr["DepartCode"] == DBNull.Value) { info.DepartCode = string.Empty; } else { info.DepartCode = dr["DepartCode"].ToString(); } return(info); } } return(null); }
/// <summary> /// 更新审批节点 /// </summary> /// <param name="info"></param> /// <returns></returns> public bool UpdateProcessNode(ProcessNodeInfo info) { try { string sql = "P_K2_Admin_UpdateProcessNode"; SqlParameter[] parms = { new SqlParameter("@NodeName", info.NodeName), new SqlParameter("@IsAllowMeet", info.IsAllowMeet), new SqlParameter("@IsAllowEndorsement", info.IsAllowEndorsement), new SqlParameter("@Notification", info.Notification), new SqlParameter("@WayBack", info.WayBack), new SqlParameter("@IsAllowSpecialApproval", info.IsAllowSpecialApproval), new SqlParameter("@ApproveRule", info.ApproveRule), new SqlParameter("@DeclineRule", info.DeclineRule), new SqlParameter("@NodeID", info.NodeID), new SqlParameter("@URL", info.URL), new SqlParameter("@WayBackNodeID", ""), new SqlParameter("@OrderNo", info.OrderNo), new SqlParameter("@WeightedType", info.WeightedType), new SqlParameter("@SamplingRate", ""), new SqlParameter("@DepartName", ""), new SqlParameter("@DepartCode", "") }; if (info.WayBackNodeID == Guid.Empty) { parms[10].Value = DBNull.Value; } else { parms[10].Value = info.WayBackNodeID; } if (string.IsNullOrEmpty(info.SamplingRate)) { parms[13].Value = DBNull.Value; } else { parms[13].Value = info.SamplingRate; } //所属部门 if (string.IsNullOrEmpty(info.DepartName)) { parms[14].Value = DBNull.Value; } else { parms[14].Value = info.DepartName; } if (string.IsNullOrEmpty(info.DepartCode)) { parms[15].Value = DBNull.Value; } else { parms[15].Value = info.DepartCode; } SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, sql, parms); return(true); } catch (Exception ex) { //DBManager.RecoreErrorProfile(ex, "ProcessRuleDAL.UpdateProcessNode", HttpContext.Current.User.Identity.Name); return(false); } }
/// <summary> /// 创建节点 /// </summary> /// <param name="pn"></param> /// <returns></returns> public bool InsertProcessNode(ProcessNodeInfo pn) { try { string sql = "P_K2_Admin_InsertProcessNode"; SqlParameter[] parms = { new SqlParameter("@ProcessID", pn.ProcessID), new SqlParameter("@NodeName", pn.NodeName), new SqlParameter("@IsAllowMeet", pn.IsAllowMeet), new SqlParameter("@IsAllowEndorsement", pn.IsAllowEndorsement), new SqlParameter("@Notification", pn.Notification), new SqlParameter("@WayBack", pn.WayBack), new SqlParameter("@IsAllowSpecialApproval", pn.IsAllowSpecialApproval), new SqlParameter("@ApproveRule", pn.ApproveRule), new SqlParameter("@DeclineRule", pn.DeclineRule), new SqlParameter("@State", pn.State), new SqlParameter("@CreatedBy", pn.CreatedBy), new SqlParameter("@URL", pn.URL), new SqlParameter("@WayBackNodeID", ""), new SqlParameter("@OrderNo", pn.OrderNo), new SqlParameter("@WeightedType", pn.WeightedType), new SqlParameter("@SamplingRate", ""), new SqlParameter("@DepartName", string.Empty), new SqlParameter("@DepartCode", string.Empty) }; if (pn.WayBackNodeID == Guid.Empty) { parms[12].Value = DBNull.Value; } else { parms[12].Value = pn.WayBackNodeID; } if (string.IsNullOrEmpty(pn.SamplingRate)) { parms[15].Value = DBNull.Value; } else { parms[15].Value = pn.SamplingRate; } if (string.IsNullOrEmpty(pn.DepartName)) { parms[16].Value = DBNull.Value; } else { parms[16].Value = pn.DepartName; } if (string.IsNullOrEmpty(pn.DepartCode)) { parms[17].Value = DBNull.Value; } else { parms[17].Value = pn.DepartCode; } SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, sql, parms); return(true); } catch (Exception ex) { return(false); } }