/// <summary> /// 发送消息 /// </summary> private void SendInformation(int jobflowid, int ruleid) { EtNet_Models.ApprovalRule rule = EtNet_BLL.ApprovalRuleManager.GetModel(ruleid); string[] list = rule.idgourp.Split(','); EtNet_Models.JobFlow model = EtNet_BLL.JobFlowManager.GetModel(jobflowid); EtNet_Models.Information informodel = null; if (model != null) { informodel = new EtNet_Models.Information(); informodel.sortid = 9; informodel.associationid = jobflowid; informodel.contents = "编号为" + model.cname + "的客户需要您审批!"; informodel.createtime = DateTime.Now; informodel.sendtime = DateTime.Now; informodel.founderid = ((EtNet_Models.LoginInfo)Session["login"]).Id; if (EtNet_BLL.InformationManager.Add(informodel)) { int maxid = EtNet_BLL.InformationManager.GetMaxId(); EtNet_Models.InformationNotice infnotic = null; int len = (rule.sort == "单审") ? 1 : list.Length; for (int j = 0; j < len; j++) { infnotic = new EtNet_Models.InformationNotice(); infnotic.informationid = maxid; infnotic.recipientid = int.Parse(list[j].ToString()); infnotic.remind = "是"; EtNet_BLL.InformationNoticeManager.Add(infnotic); } } } }
//添加并保存 protected void ibtnSaveAdd_Click(object sender, ImageClickEventArgs e) { string path = "~/UploadFile/AuditRole/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt"; string stridgroup = ""; EtNet_Models.ApprovalRule model = new EtNet_Models.ApprovalRule(); model.cname = this.iptcname.Value; model.jobflowsort = this.seljobflowsort.Value; model.rolepic = path; // 保存文件的路径 model.sort = this.selauditsort.Value; model.txt = Server.UrlDecode(this.teratxt.Value); model.departidtxt = this.iptdepartlist.Value; model.departidlist = this.hiddepartlist.Value; model.hide = 1; model.showpattern = Convert.ToInt32(this.selhide.Value); for (int i = 0; i < this.lbtake.Items.Count; i++) { stridgroup += this.lbtake.Items[i].Value + ","; } model.idgourp = stridgroup.Substring(0, stridgroup.Length - 1); if (EtNet_BLL.ApprovalRuleManager.Add(model)) { SaveFile(path); this.seljobflowsort.SelectedIndex = 0; } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "audit", "<script>alert('保存失败!')</script>", false); } }
/// <summary> /// 加载审批流程图 /// </summary> public void LoadAuditImg(int ruleid) { EtNet_Models.ApprovalRule model = EtNet_BLL.ApprovalRuleManager.GetModel(ruleid); if (model != null) { string strpath = Server.MapPath(model.rolepic); if (File.Exists(strpath)) { this.auditpic.InnerHtml = File.ReadAllText(strpath); } } }
/// <summary> /// 发送审批消息给下一个审批人员 /// </summary> public void SendNextAudit(int jfid) { EtNet_Models.LoginInfo login = ((EtNet_Models.LoginInfo)Session["login"]); EtNet_Models.JobFlow jfmodel = EtNet_BLL.JobFlowManager.GetModel(jfid); if (jfmodel != null) { EtNet_Models.ApprovalRule rule = EtNet_BLL.ApprovalRuleManager.GetModel(jfmodel.ruleid); string[] list = rule.idgourp.Split(','); if (rule.sort != "单审" || list.Length == 1) { return; } if (list[list.Length - 1] == login.Id.ToString()) { return; } int recipientid = 0; for (int i = 0; i < list.Length; i++) { if (list[i] == login.Id.ToString() && i != list.Length - 1) { recipientid = int.Parse(list[i + 1]); } } EtNet_Models.Information model = new EtNet_Models.Information(); model.sortid = 10; model.associationid = jfid; model.createtime = DateTime.Now; model.sendtime = DateTime.Now; model.founderid = jfmodel.founderid; model.contents = "名称为" + jfmodel.cname + "的单据需要您审批!";; EtNet_BLL.InformationManager.Add(model); int maxid = EtNet_BLL.InformationManager.GetMaxId(jfmodel.founderid.ToString()); EtNet_Models.InformationNotice infnotic = new EtNet_Models.InformationNotice(); infnotic.informationid = maxid; infnotic.recipientid = recipientid; infnotic.remind = "是"; EtNet_BLL.InformationNoticeManager.Add(infnotic); } }
/// <summary> /// 创建审批序列 /// </summary> ///<param name="ruleid">审核规则id值</param> /// <param name="id">工作流的id号</param> private void CreateApproval(int ruleid, int id) { EtNet_Models.ApprovalRule rule = EtNet_BLL.ApprovalRuleManager.GetModel(ruleid); string stafflist = rule.idgourp; string auditsort = rule.sort; string[] staff = null; int len = 0; //审批人员的个数 EtNet_Models.AuditJobFlow model = null; if (stafflist.IndexOf(",") == -1) { staff = new string[1]; staff[0] = stafflist; len = 1; } else { staff = stafflist.Split(','); len = staff.Length; } switch (auditsort) { case "单审": for (int i = 0; i < staff.Length; i++) { model = new EtNet_Models.AuditJobFlow(); model.auditoperat = "未操作"; model.operatstatus = "未审批"; model.audittime = new DateTime(1900, 1, 1); if (i == 0) { model.nowreviewer = "T"; //第一个审核的人员 } else { model.nowreviewer = "F"; } if ((i + 1) == len) { model.mainreviewer = "T"; //最终审核的人员 } else { model.mainreviewer = "F"; } model.numbers = i + 1; model.jobflowid = id; model.reviewerid = int.Parse(staff[i]); model.opiniontxt = ""; EtNet_BLL.AuditJobFlowManager.Add(model); } break; case "选审": case "会审": for (int i = 0; i < staff.Length; i++) { model = new EtNet_Models.AuditJobFlow(); model.audittime = new DateTime(1900, 1, 1); model.nowreviewer = "T"; model.mainreviewer = "T"; model.numbers = 1; model.jobflowid = id; model.auditoperat = "未操作"; model.operatstatus = "未审批"; model.opiniontxt = ""; model.reviewerid = int.Parse(staff[i]); EtNet_BLL.AuditJobFlowManager.Add(model); } break; } }
/// <summary> /// 拒绝 /// </summary> private void OrderRefuse() { int jobflowid = int.Parse(Request.QueryString["jobflowid"].ToString()); //工作流的id EtNet_Models.LoginInfo login = (EtNet_Models.LoginInfo)Session["login"]; string comparedata = " reviewerid=" + login.Id + " AND jobflowid=" + jobflowid.ToString(); if (EtNet_BLL.AuditJobFlowManager.GetList(comparedata).Rows.Count == 0) { //该工作流被收回或删除导致审批提交失败 Response.Redirect("../Job/AuditError.aspx?error=0"); } else if (EtNet_BLL.JobFlowManager.GetModel(jobflowid).auditstatus == "03" || EtNet_BLL.JobFlowManager.GetModel(jobflowid).auditstatus == "04") { //该工作流是审核方式是选审或会签所以在提交审核时,工作流已由他人审核通过 Response.Redirect("../Job/AuditError.aspx?error=1"); } else { string ruletxt = ""; //审核的分类 string strsql = " jobflowid=" + jobflowid.ToString(); DataTable tbl = EtNet_BLL.To_OrderInfoManager.getList("", strsql); if (tbl.Rows.Count == 1) { int ruleid = int.Parse(tbl.Rows[0]["ruleid"].ToString()); EtNet_Models.ApprovalRule rule = EtNet_BLL.ApprovalRuleManager.GetModel(ruleid); ruletxt = rule.sort; //修改当前审核人的记录 EtNet_Models.AuditJobFlow auditmodel = null; string auditstr = " jobflowid=" + jobflowid.ToString() + " AND reviewerid=" + login.Id; DataTable audittbl = EtNet_BLL.AuditJobFlowManager.GetList(auditstr); // 查找到当前审核人员的记录 int num = int.Parse(audittbl.Rows[0]["numbers"].ToString()); //当前审核人员编号 string mainreviewer = audittbl.Rows[0]["mainreviewer"].ToString(); //当前审核人是不是最终审核人 auditmodel = new EtNet_Models.AuditJobFlow(); auditmodel.auditoperat = "拒绝"; auditmodel.audittime = DateTime.Now; auditmodel.id = int.Parse(audittbl.Rows[0]["id"].ToString()); auditmodel.jobflowid = int.Parse(audittbl.Rows[0]["jobflowid"].ToString()); auditmodel.mainreviewer = audittbl.Rows[0]["mainreviewer"].ToString(); auditmodel.nowreviewer = "P"; //能查找到工作流记录,但不能进行审核操作 auditmodel.numbers = int.Parse(audittbl.Rows[0]["numbers"].ToString()); auditmodel.operatstatus = "已审批"; auditmodel.reviewerid = int.Parse(audittbl.Rows[0]["reviewerid"].ToString()); auditmodel.opiniontxt = Server.UrlDecode(this.iptcomment.Value.Trim()); EtNet_BLL.AuditJobFlowManager.Update(auditmodel); EtNet_Models.JobFlow jobflowmodel = new EtNet_Models.JobFlow(); jobflowmodel = EtNet_BLL.JobFlowManager.GetModel(jobflowid); //依据不同的审核类型进行操作 switch (ruletxt) { case "单审": case "会审": jobflowmodel.endtime = DateTime.Now; jobflowmodel.auditstatus = "03"; //工作流的审核状态为“被拒绝” EtNet_BLL.JobFlowManager.Update(jobflowmodel); break; case "选审": string st = " jobflowid=" + jobflowid.ToString(); DataTable tbla = EtNet_BLL.AuditJobFlowManager.GetList(st); bool refuse = true; for (int j = 0; j < tbla.Rows.Count; j++) { if (tbla.Rows[j]["auditoperat"].ToString() != "拒绝") { refuse = false; //还有其他审核人员未审 break; } } if (refuse) { jobflowmodel.endtime = DateTime.Now; jobflowmodel.auditstatus = "03"; // 工作流的审核状态为被拒绝 EtNet_BLL.JobFlowManager.Update(jobflowmodel); } else { jobflowmodel.auditstatus = "02"; // 工作流的审核状态为进行中 EtNet_BLL.JobFlowManager.Update(jobflowmodel); } break; } string strad = "编号为" + jobflowmodel.cname + "的订单,【" + login.Cname + "】审批被拒绝!"; SendInfo(strad, jobflowmodel.id); SendNextAudit(jobflowmodel.id); //修改客户的审核意见与启用状态 //int cusid = int.Parse(tbl.Rows[0]["id"].ToString()); EtNet_Models.AuditJobFlow cus = EtNet_BLL.AuditJobFlowManager.GetModelByJFID(jobflowid); cus.opiniontxt = cus.opiniontxt + login.Cname + "的审批意见:" + Server.UrlDecode(this.iptcomment.Value.Trim()) + "|"; //if (jobflowmodel.auditstatus == "04") //{ // cus.Used = 1; //} EtNet_BLL.AuditJobFlowManager.Update(cus); if (HttpContext.Current.Request.QueryString["pageindex"] != null) { int page = int.Parse(HttpContext.Current.Request.QueryString["pageindex"]); Response.Redirect("../Job/AuditJobFlow.aspx?page=" + page + ""); } else { Response.Redirect("../Job/AuditJobFlow.aspx"); } } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "audit", "<script> alert('审批出错!')</script>", false); } } }
private void OrderPass() { int jobflowid = int.Parse(Request.QueryString["jobflowid"].ToString()); //工作流的id EtNet_Models.LoginInfo login = (EtNet_Models.LoginInfo)Session["login"]; string comparedata = " reviewerid=" + login.Id + " AND jobflowid=" + jobflowid.ToString(); if (EtNet_BLL.AuditJobFlowManager.GetList(comparedata).Rows.Count == 0) { //该工作流被收回或删除导致审批提交失败 Response.Redirect("../Job/AuditError.aspx?error=0"); } else if (EtNet_BLL.JobFlowManager.GetModel(jobflowid).auditstatus == "03" || EtNet_BLL.JobFlowManager.GetModel(jobflowid).auditstatus == "04") { //该工作流是审核方式是选审或会签所以在提交审核时,工作流已由他人审核通过 Response.Redirect("../Job/AuditError.aspx?error=1"); } else { string ruletxt = ""; //审核的分类 string strsql = " jobflowID=" + jobflowid.ToString(); DataTable tbl = EtNet_BLL.To_OrderInfoManager.getList("", strsql);//获取视图数据 if (tbl.Rows.Count == 1) { int ruleid = int.Parse(tbl.Rows[0]["ruleid"].ToString()); EtNet_Models.ApprovalRule rule = EtNet_BLL.ApprovalRuleManager.GetModel(ruleid); ruletxt = rule.sort; //修改当前审核人的记录 EtNet_Models.AuditJobFlow auditmodel = null; string auditstr = " jobflowid=" + jobflowid.ToString() + " AND reviewerid=" + login.Id; DataTable audittbl = EtNet_BLL.AuditJobFlowManager.GetList(auditstr); // 查找到当前审核人员的记录 int num = int.Parse(audittbl.Rows[0]["numbers"].ToString()); //当前审核人员编号 string mainreviewer = audittbl.Rows[0]["mainreviewer"].ToString(); //当前审核人是不是最终审核人 auditmodel = new EtNet_Models.AuditJobFlow(); auditmodel.auditoperat = "通过"; auditmodel.audittime = DateTime.Now; auditmodel.id = int.Parse(audittbl.Rows[0]["id"].ToString()); auditmodel.jobflowid = int.Parse(audittbl.Rows[0]["jobflowid"].ToString()); auditmodel.mainreviewer = audittbl.Rows[0]["mainreviewer"].ToString(); auditmodel.nowreviewer = "P"; //能查找到工作流记录,但不能进行审核操作 auditmodel.numbers = int.Parse(audittbl.Rows[0]["numbers"].ToString()); auditmodel.operatstatus = "已审批"; auditmodel.reviewerid = int.Parse(audittbl.Rows[0]["reviewerid"].ToString()); if (this.iptcomment.Value != "") { auditmodel.opiniontxt = Server.UrlDecode(this.iptcomment.Value.Trim()); } else { auditmodel.opiniontxt = " "; } EtNet_BLL.AuditJobFlowManager.Update(auditmodel); EtNet_Models.JobFlow jobflowmodel = new EtNet_Models.JobFlow(); jobflowmodel = EtNet_BLL.JobFlowManager.GetModel(jobflowid); //依据不同的审核类型进行操作 switch (ruletxt) { case "单审": if (mainreviewer != "T") { auditmodel = new EtNet_Models.AuditJobFlow(); //设置下一个审核人的数据记录 string nextauditstr = " jobflowid=" + jobflowid.ToString() + " AND numbers=" + (num + 1).ToString(); DataTable nextaudittbl = EtNet_BLL.AuditJobFlowManager.GetList(nextauditstr); auditmodel.auditoperat = nextaudittbl.Rows[0]["auditoperat"].ToString(); auditmodel.audittime = DateTime.Parse(nextaudittbl.Rows[0]["audittime"].ToString()); auditmodel.id = int.Parse(nextaudittbl.Rows[0]["id"].ToString()); auditmodel.jobflowid = int.Parse(nextaudittbl.Rows[0]["jobflowid"].ToString()); auditmodel.mainreviewer = nextaudittbl.Rows[0]["mainreviewer"].ToString(); auditmodel.nowreviewer = "T"; //设置其为审核人员 auditmodel.numbers = int.Parse(nextaudittbl.Rows[0]["numbers"].ToString()); auditmodel.operatstatus = nextaudittbl.Rows[0]["operatstatus"].ToString(); auditmodel.reviewerid = int.Parse(nextaudittbl.Rows[0]["reviewerid"].ToString()); auditmodel.opiniontxt = nextaudittbl.Rows[0]["opiniontxt"].ToString(); EtNet_BLL.AuditJobFlowManager.Update(auditmodel); jobflowmodel.auditstatus = "02"; //工作流的审核状态为“进行中” EtNet_BLL.JobFlowManager.Update(jobflowmodel); } else { jobflowmodel.endtime = DateTime.Now; jobflowmodel.auditstatus = "04"; //工作流的审核状态为“已通过” EtNet_BLL.JobFlowManager.Update(jobflowmodel); EtNet_BLL.To_OrderInfoManager.updateOrdersjGross(jobflowid.ToString(), this.lblsjml.Text); } break; case "选审": jobflowmodel.endtime = DateTime.Now; jobflowmodel.auditstatus = "04"; //工作流的审核状态为“已通过” EtNet_BLL.JobFlowManager.Update(jobflowmodel); EtNet_BLL.To_OrderInfoManager.updateOrdersjGross(jobflowid.ToString(), this.lblsjml.Text); //审核通过后,删除其他审核人员的审核流数据 AuditJobFlowManager.UpdateOther(" reviewerid != " + login.Id + " and jobflowid=" + jobflowid.ToString()); break; case "会审": bool pass = true; string straudit = " jobflowid=" + jobflowid.ToString(); DataTable auditjobtbl = EtNet_BLL.AuditJobFlowManager.GetList(straudit); for (int i = 0; i < auditjobtbl.Rows.Count; i++) { if (auditjobtbl.Rows[i]["auditoperat"].ToString() != "通过") { pass = false; //说明还有其他审核人员未开始审核 break; } } if (pass) { jobflowmodel.endtime = DateTime.Now; jobflowmodel.auditstatus = "04"; //工作流的状审核状态为“已通过” EtNet_BLL.JobFlowManager.Update(jobflowmodel); EtNet_BLL.To_OrderInfoManager.updateOrdersjGross(jobflowid.ToString(), this.lblsjml.Text); } else { jobflowmodel.auditstatus = "02"; //工作流的状审核状态为“进行中” EtNet_BLL.JobFlowManager.Update(jobflowmodel); } break; } string strad = "编号为" + jobflowmodel.cname + "的订单,【" + login.Cname + "】通过审批!"; SendInfo(strad, jobflowmodel.id); SendNextAudit(jobflowmodel.id); //修改客户的审核意见与启用状态 //int cusid = int.Parse(tbl.Rows[0]["id"].ToString()); EtNet_Models.AuditJobFlow cus = EtNet_BLL.AuditJobFlowManager.GetModelByJFID(jobflowid); cus.opiniontxt = cus.opiniontxt + login.Cname + "的审批意见:" + Server.UrlDecode(this.iptcomment.Value.Trim()) + "|"; //if (jobflowmodel.auditstatus == "04") //{ // cus.Used = 1; //} EtNet_BLL.AuditJobFlowManager.Update(cus); if (HttpContext.Current.Request.QueryString["pageindex"] != null) { int page = int.Parse(HttpContext.Current.Request.QueryString["pageindex"]); Response.Redirect("../Job/AuditJobFlow.aspx?page=" + page + ""); } else { Response.Redirect("../Job/AuditJobFlow.aspx"); } } else { Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "audit", "<script> alert('审批出错!')</script>", false); } } }