/// <summary> /// 保存工作流实例 /// </summary> /// <param name="obj"></param> /// <param name="WfStatus"></param> /// <param name="SumitTime"></param> /// <param name="WfInstanceId"></param> /// <returns></returns> private bool SaveWorkFlowInstance(ContractAuditOfGroupInfo obj, string WfStatus, DateTime?SumitTime, string WfInstanceId) { bool result = false; WorkFlowInstance workFlowInstance = null; try { workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(obj.FormID); bool isEdit = false; if (workFlowInstance == null) { workFlowInstance = new WorkFlowInstance(); workFlowInstance.InstanceId = Guid.NewGuid().ToString(); workFlowInstance.CreateDeptCode = ddlDepartName.SelectedItem.Value.ToString(); workFlowInstance.CreateDeptName = ddlDepartName.SelectedItem.Text; workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.CreateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.CreateByUserName = CurrentEmployee.EmployeeName; workFlowInstance.AppId = "3007"; } else { workFlowInstance.CreateAtTime = DateTime.Now; workFlowInstance.UpdateByUserCode = CurrentEmployee.EmployeeCode; workFlowInstance.UpdateByUserName = CurrentEmployee.EmployeeName; isEdit = true; } workFlowInstance.FormId = obj.FormID; workFlowInstance.FormTitle = obj.ContractTitle; workFlowInstance.WfStatus = WfStatus; if (SumitTime != null) { workFlowInstance.SumitTime = SumitTime; } if (WfInstanceId != "") { workFlowInstance.WfInstanceId = WfInstanceId; } if (!isEdit) { result = wf_WorkFlowInstance.AddWorkFlowInstance(workFlowInstance); } else { result = wf_WorkFlowInstance.UpdateWorkFlowInstance(workFlowInstance); } FlowRelated1.ProcId = workFlowInstance.InstanceId; Countersign1.ProcId = workFlowInstance.InstanceId; Countersign1.SaveData(true); } catch (Exception ex) { throw ex; } return(result); }
/// <summary> /// 保存方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Save_Click(object sender, EventArgs e) { string id = ViewState["FormID"].ToString(); ContractAuditOfGroupInfo obj = SaveData(id, "00"); if (obj != null) { if (SaveWorkFlowInstance(obj, "0", null, "")) { Alert(Page, "保存成功!"); } } else { Alert(Page, "保存失败"); } }
/// <summary> /// 保存数据 /// </summary> /// <param name="p"></param> /// <returns></returns> private void SaveData(string ID, string wfStatus) { ContractAuditOfGroupInfo obj = null; try { obj = Aitems.Get(ID); obj.FormID = ViewState["FormID"].ToString(); obj.LeadersSelected = lblApprovers.Text; obj.IsReport = cbIsReport.Checked ? "1" : "0"; obj.ContractContent = tbContractContent.Text; obj.ContractTitle = tbContractTitle.Text; Aitems.Update(obj); WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(obj.FormID); Countersign1.ProcId = workFlowInstance.InstanceId; Countersign1.SaveData(true); } catch (Exception ex) { throw ex; } }
/// <summary> /// <summary> /// 绑定表单数据 /// </summary> private void BindFormData() { try { WorkFlowInstance Instance = wf_WorkFlowInstance.GetWorkFlowInstanceById(ViewState["InstanceID"].ToString()); if (Instance == null) { ExceptionHander.GoToErrorPage("记录不存在"); } ContractAuditOfGroupInfo obj = Vitems.Get(Instance.FormId.ToString()); if (obj == null) { ExceptionHander.GoToErrorPage("记录不存在"); } if (obj != null) { //保存数据 tbReportCode.Text = obj.FormID; cblSecurityLevel.SelectedIndex = int.Parse(obj.SecurityLevel.ToString()); cblUrgenLevel.SelectedIndex = int.Parse(obj.UrgenLevel.ToString()); tbDepartName.Text = obj.DeptName; lbDeptCode.Text = obj.DeptCode; tbUserName.Text = obj.UserName; tbMobile.Text = obj.Mobile; tbDateTime.Text = obj.DateTime; //合同类型 if (obj.ContractType1 == "00") { ddlContractType1.Text = ""; } else { ddlContractType1.Text = obj.ContractTypeName1; } ddlContractType2.Text = obj.ContractTypeName2; ddlContractType3.Text = obj.ContractTypeName3; tbContractSum.Text = obj.ContractSum; cblIsSupplementProtocol.SelectedValue = obj.IsSupplementProtocol; tbSupplementProtocol.Text = obj.IsSupplementProtocolText; cblIsFormatContract.SelectedValue = obj.IsFormatContract; cblIsNormText.SelectedValue = obj.IsNormText; cblIsBidding.SelectedValue = obj.IsBidding; cblIsEstateProject.SelectedValue = obj.IsEstateProject; if (obj.EstateProjectName == "0") { ddlEstateProjectName.Text = ""; } else { ddlEstateProjectName.Text = obj.EstateProjectNameText; } if (obj.EstateProjectNum == "0") { ddlEstateProjectNum.Text = ""; } else { ddlEstateProjectNum.Text = obj.EstateProjectNumText; } //合同主体 if (obj.ContractSubject == "00000") { ddlContractSubject.Text = ""; } else { ddlContractSubject.Text = obj.ContractSubjectName; } tbContractSubject1.Text = obj.ContractSubjectName2; tbContractSubject2.Text = obj.ContractSubjectName3; tbContractSubject3.Text = obj.ContractSubjectName4; tbContractTitle.Text = obj.ContractTitle; tbContractContent.Text = obj.ContractContent.Replace(" ", " ").Replace("\n", "<br/>"); cbIsReport.Checked = obj.IsReport == "1" ? true : false; //if (!string.IsNullOrEmpty(obj.IsApproval)) //{ // lbIsApproval.Text = string.Format("{1}({0})", obj.IsApproval == "1" ? "批准" : "拒绝", lbIsApproval.Text); // if (obj.IsApproval == "1") // { // this.lbIsApproval.Style.Add("color", "green"); // } // else // { // this.lbIsApproval.Style.Add("color", "red"); // } //} } FlowRelated1.ProcId = ViewState["InstanceID"].ToString(); Countersign1.ProcId = ViewState["InstanceID"].ToString(); UploadAttachments1.ProcId = ViewState["InstanceID"].ToString(); #region 审批意见框 OpinionDeptManager.InstanceId = ViewState["InstanceID"].ToString(); OpinionCountersign.InstanceId = ViewState["InstanceID"].ToString(); OpinionLawDept.InstanceId = ViewState["InstanceID"].ToString(); OpinionAP.InstanceId = ViewState["InstanceID"].ToString(); OpinionLawAP.InstanceId = ViewState["InstanceID"].ToString(); OpinionVP.InstanceId = ViewState["InstanceID"].ToString(); OpinionDirectors.InstanceId = ViewState["InstanceID"].ToString(); OpinionPresident.InstanceId = ViewState["InstanceID"].ToString(); OpinionChairman.InstanceId = ViewState["InstanceID"].ToString(); OpinionStartToFinallyContract.InstanceId = ViewState["InstanceID"].ToString(); OpinionLawAuditOpinion.InstanceId = ViewState["InstanceID"].ToString(); OpinionSealAdministrator.InstanceId = ViewState["InstanceID"].ToString(); OpinionFileManager.InstanceId = ViewState["InstanceID"].ToString(); #endregion } catch (Exception ex) { throw ex; } }
/// <summary> /// 保存数据 /// </summary> /// <param name="ID"></param> /// <param name="wfStatus"></param> /// <returns></returns> private ContractAuditOfGroupInfo SaveData(string ID, string wfStatus) { SaveWFParams(); ContractAuditOfGroupInfo obj = null; try { UploadAttachments1.SaveAttachment(ViewState["FormID"].ToString()); obj = Eitems.Get(ID); bool isEdit = false; if (obj == null) { obj = new ContractAuditOfGroupInfo(); obj.FormID = ViewState["FormID"].ToString(); } else { isEdit = true; obj.FormID = ViewState["FormID"].ToString(); //obj.ApproveStatus = wfStatus; } //存储数据 //LINQ //var info = BizContext.OA_ContractAuditOfGroup.FirstOrDefault(x => x.FormID == FormId); //if (info == null) //{ // BizContext.OA_ContractAuditOfGroup.InsertOnSubmit(new Pkurg.PWorldBPM.Business.BIZ.OA_ContractAuditOfGroup() // { // FormID = FormId // }); //} //else //{ // info.DeptName = ""; //} //BizContext.SubmitChanges(); obj.DeptCode = ddlDepartName.SelectedItem.Value.ToString(); obj.DeptName = ddlDepartName.SelectedItem.Text; obj.UserName = tbUserName.Text; obj.DateTime = UpdatedTextBox.Value; obj.Mobile = tbMobile.Text; //新添加的存储数据 //合同类型 //obj.ContractType2 = ddlContractType2.SelectedItem.Value; obj.ContractType1 = ddlContractType1.SelectedItem.Value; obj.ContractType2 = ddlContractType2.SelectedItem != null ? ddlContractType2.SelectedItem.Value : ""; obj.ContractType3 = ddlContractType3.SelectedItem != null ? ddlContractType3.SelectedItem.Value : ""; //obj.ContractTypeName2 = ddlContractType2.SelectedItem.Text; obj.ContractTypeName1 = ddlContractType1.SelectedItem.Text; obj.ContractTypeName2 = ddlContractType2.SelectedItem != null ? ddlContractType2.SelectedItem.Text : ""; obj.ContractTypeName3 = ddlContractType3.SelectedItem != null ? ddlContractType3.SelectedItem.Text : ""; obj.ContractSum = tbContractSum.Text; //需要和下面的两个一样进行判断吗? obj.IsSupplementProtocol = cblIsSupplementProtocol.SelectedValue.ToString(); obj.IsSupplementProtocolText = tbSupplementProtocol.Text; obj.IsFormatContract = cblIsFormatContract.SelectedValue.ToString(); obj.IsNormText = cblIsNormText.SelectedValue.ToString(); obj.IsBidding = cblIsBidding.SelectedValue.ToString(); obj.IsEstateProject = cblIsEstateProject.SelectedValue.ToString(); obj.EstateProjectName = ddlEstateProjectName.SelectedValue.ToString(); obj.EstateProjectNameText = ddlEstateProjectName.SelectedItem.Text; obj.EstateProjectNum = ddlEstateProjectNum.SelectedValue.ToString(); obj.EstateProjectNumText = ddlEstateProjectNum.SelectedItem.Text; //合同主体 obj.ContractSubject = ddlContractSubject.SelectedItem.Value; obj.ContractSubjectName = ddlContractSubject.SelectedItem.Text; obj.ContractSubjectName2 = tbContractSubject1.Text; obj.ContractSubjectName3 = tbContractSubject2.Text; obj.ContractSubjectName4 = tbContractSubject3.Text; obj.ContractTitle = tbContractTitle.Text; obj.ContractContent = tbContractContent.Text; obj.LeadersSelected = lblApprovers.Text; obj.SecurityLevel = cblSecurityLevel.SelectedIndex.ToString(); obj.UrgenLevel = cblUrgenLevel.SelectedIndex.ToString(); obj.IsReport = cbIsReport.Checked ? "1" : "0"; obj.RelatedFormID = string.Empty; if (!isEdit) { Eitems.Insert(obj); } else { Eitems.Update(obj); } } catch (Exception ex) { throw ex; } return(obj); }
/// <summary> /// 绑定表单数据 /// </summary> private void BindFormDate() { try { //根据formid得到合同表单数据 ContractAuditOfGroupInfo obj = Eitems.Get(ViewState["FormID"].ToString()); lbIsReport.Text = string.IsNullOrEmpty(obj.RelatedFormID) ? "0" : "1"; if (lbIsReport.Text == "0") { ListItem item = ddlDepartName.Items.FindByValue(obj.DeptCode); if (item != null) { ddlDepartName.SelectedIndex = ddlDepartName.Items.IndexOf(item); } } else { ddlDepartName.Items.Clear(); string CompanyCode = BPMHelp.GetCompanyCodeByDeptID(obj.DeptCode); Department deptInfo = new Pkurg.PWorld.Services.DepartmentService().GetByDepartCode(CompanyCode); ListItem item = new ListItem { Text = deptInfo.DepartName, Value = CompanyCode }; ddlDepartName.Items.Add(item); ddlDepartName.Enabled = false; } //保存数据 tbReportCode.Text = obj.FormID; tbUserName.Text = obj.UserName; tbMobile.Text = obj.Mobile; UpdatedTextBox.Value = obj.DateTime; //合同类型 ListItem li1 = ddlContractType1.Items.FindByValue(obj.ContractType1); if (li1 != null) { li1.Selected = true; } ddlContractType2.DataSource = ContractTypeInfosHelper.GetSecondContractTypeInfos(ddlContractType1.SelectedItem.Value); ddlContractType2.DataTextField = "value"; ddlContractType2.DataValueField = "key"; ddlContractType2.DataBind(); ListItem li2 = ddlContractType2.Items.FindByValue(obj.ContractType2); if (li2 != null) { li2.Selected = true; } if (ddlContractType2.SelectedItem != null) { ddlContractType3.DataSource = ContractTypeInfosHelper.GetThirdContractTypeInfos(ddlContractType2.SelectedItem.Value); ddlContractType3.DataTextField = "value"; ddlContractType3.DataValueField = "key"; ddlContractType3.DataBind(); ListItem li3 = ddlContractType3.Items.FindByValue(obj.ContractType3); if (li3 != null) { li3.Selected = true; } } tbContractSum.Text = obj.ContractSum; cblIsSupplementProtocol.SelectedValue = obj.IsSupplementProtocol; tbSupplementProtocol.Text = obj.IsSupplementProtocolText; cblIsFormatContract.SelectedValue = obj.IsFormatContract; cblIsNormText.SelectedValue = obj.IsNormText; cblIsBidding.SelectedValue = obj.IsBidding; cblIsEstateProject.SelectedValue = obj.IsEstateProject; ddlEstateProjectName.SelectedValue = obj.EstateProjectName; ddlEstateProjectNum.SelectedValue = obj.EstateProjectNum; //合同主体 ddlContractSubject.SelectedValue = obj.ContractSubject; tbContractSubject1.Text = obj.ContractSubjectName2; tbContractSubject2.Text = obj.ContractSubjectName3; tbContractSubject3.Text = obj.ContractSubjectName4; tbContractTitle.Text = obj.ContractTitle; tbContractContent.Text = obj.ContractContent; cblSecurityLevel.SelectedIndex = int.Parse(obj.SecurityLevel.ToString()); cblUrgenLevel.SelectedIndex = int.Parse(obj.UrgenLevel.ToString()); cbIsReport.Checked = obj.IsReport == "1" ? true : false; } catch (Exception ex) { throw ex; } }
/// <summary> /// 初始化CheckBoxList /// </summary> private void InitCheckBoxList() { BFPmsUserRoleDepartment bfurd = new BFPmsUserRoleDepartment(); DataTable dtLeaders = bfurd.GetSelectRoleUser(GroupCode, "总办会成员"); foreach (DataRow user in dtLeaders.Rows) { ListItem li = new ListItem(); li.Value = "K2:Founder\\" + user["LoginName"].ToString(); li.Text = user["EmployeeName"].ToString(); if (!cblDirectors.Items.Contains(li)) { cblDirectors.Items.Add(li); } } if (!string.IsNullOrEmpty(Request.QueryString["id"])) { //将选择的领导存储在xml中 XmlDocument xmldoc = new XmlDocument(); ContractAuditOfGroupInfo formDataInfo = Eitems.Get(FormId); if (!string.IsNullOrEmpty(formDataInfo.LeadersSelected)) { xmldoc.LoadXml(formDataInfo.LeadersSelected); } XmlNode NodeLeaders = xmldoc.SelectSingleNode("//Directors"); if (NodeLeaders != null && NodeLeaders.Attributes["ID"].Value.Length > 0) { foreach (string UserGuid in NodeLeaders.Attributes["ID"].Value.Split(',')) { for (int i = 0; i < cblDirectors.Items.Count; i++) { if (cblDirectors.Items[i].Value == UserGuid) { cblDirectors.Items[i].Selected = true; } } } } XmlNode NodeChairman = xmldoc.SelectSingleNode("//Chairman"); if (NodeChairman != null && NodeChairman.Attributes["ID"].Value != "noapprovers") { cbChairman.Checked = true; } else { cbChairman.Checked = false; } XmlNode NodePresident = xmldoc.SelectSingleNode("//President"); if (NodePresident != null && NodePresident.Attributes["ID"].Value != "noapprovers") { cbPresident.Checked = true; } else { cbPresident.Checked = false; } XmlNode NodeVP = xmldoc.SelectSingleNode("//VicePresident"); if (NodeVP != null && NodeVP.Attributes["ID"].Value != "noapprovers") { cbVP.Checked = true; } else { cbVP.Checked = false; } XmlNode NodeAP = xmldoc.SelectSingleNode("//AssiPresident"); if (NodeAP != null && NodeAP.Attributes["ID"].Value != "noapprovers") { cbAP.Checked = true; } else { cbAP.Checked = false; } } else { for (int i = 0; i < cblDirectors.Items.Count; i++) { cblDirectors.Items[i].Selected = false; } } }
/// <summary> /// 提交事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Submit_Click(object sender, EventArgs e) { //合同验证 if (NotifyCompanyAndContractType()) { return; } string id = ViewState["FormID"].ToString(); string SaveVerification = SaveWFParams(); if (string.IsNullOrEmpty(SaveVerification)) { return; } #region 工作流参数 NameValueCollection dataFields = SetWFParams(); if (dataFields == null) { return; } #endregion ContractAuditOfGroupInfo obj = SaveData(id, "02"); if (obj != null) { //开启流程 WorkflowHelper.CurrentUser = "******" + _BPMContext.CurrentUser.LoginId; AppDict appInfo = new Pkurg.BPM.Services.AppDictService().GetByAppId("3007"); if (appInfo == null) { Alert("提交失败"); return; } int wfInstanceId = 0; //process instance id WorkflowHelper.StartProcess(@"K2Workflow\OA_ContractAuditOfGroup", id, dataFields, ref wfInstanceId); if (wfInstanceId > 0) { if (SaveWorkFlowInstance(obj, "1", DateTime.Now, wfInstanceId.ToString())) { if (Eitems.UpdateStatus(id, "02")) { string Opinion = ""; string ApproveResult = "同意"; string OpinionType = ""; string IsSign = "0"; string DelegateUserName = ""; string DelegateUserCode = ""; WorkFlowInstance workFlowInstance = wf_WorkFlowInstance.GetWorkFlowInstanceByFormId(obj.FormID); var appRecord = new Pkurg.PWorldBPM.Business.Sys.WF_Approval_Record() { ApprovalID = Guid.NewGuid().ToString(), FormID = id, InstanceID = workFlowInstance.InstanceId, Opinion = Opinion, ApproveAtTime = DateTime.Now, ApproveByUserCode = CurrentEmployee.EmployeeCode, ApproveByUserName = CurrentEmployee.EmployeeName, ApproveResult = ApproveResult, OpinionType = OpinionType, CurrentActiveName = "拟稿", ISSign = IsSign, DelegateUserName = DelegateUserName, DelegateUserCode = DelegateUserCode, CreateAtTime = DateTime.Now, CreateByUserCode = CurrentEmployee.EmployeeCode, CreateByUserName = CurrentEmployee.EmployeeName, UpdateAtTime = DateTime.Now, UpdateByUserCode = CurrentEmployee.EmployeeCode, UpdateByUserName = CurrentEmployee.EmployeeName, FinishedTime = DateTime.Now }; BFApprovalRecord bfApproval = new BFApprovalRecord(); bfApproval.AddApprovalRecord(appRecord); } ScriptManager.RegisterClientScriptBlock(this, typeof(string), "1", "alert('提交成功');", true); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "ajax", " window.opener=null; window.open('', '_self', '');window.close();", true); } } } Alert("提交失败"); }
/// <summary> /// 绑定表单数据 /// </summary> private void BindFormData() { try { ContractAuditOfGroupInfo obj = Aitems.Get(FormID); if (obj != null) { //保存数据 tbReportCode.Text = obj.FormID; cblSecurityLevel.SelectedIndex = int.Parse(obj.SecurityLevel.ToString()); cblUrgenLevel.SelectedIndex = int.Parse(obj.UrgenLevel.ToString()); tbDepartName.Text = obj.DeptName; lbDeptCode.Text = obj.DeptCode; tbUserName.Text = obj.UserName; tbMobile.Text = obj.Mobile; tbDateTime.Text = obj.DateTime; //合同类型 if (obj.ContractType1 == "00") { ddlContractType1.Text = ""; } else { ddlContractType1.Text = obj.ContractTypeName1; } ddlContractType2.Text = obj.ContractTypeName2; ddlContractType3.Text = obj.ContractTypeName3; tbContractSum.Text = obj.ContractSum; cblIsSupplementProtocol.SelectedValue = obj.IsSupplementProtocol; tbSupplementProtocol.Text = obj.IsSupplementProtocolText; cblIsFormatContract.SelectedValue = obj.IsFormatContract; cblIsNormText.SelectedValue = obj.IsNormText; cblIsBidding.SelectedValue = obj.IsBidding; cblIsEstateProject.SelectedValue = obj.IsEstateProject; if (obj.EstateProjectName == "0") { ddlEstateProjectName.Text = ""; } else { ddlEstateProjectName.Text = obj.EstateProjectNameText; } if (obj.EstateProjectNum == "0") { ddlEstateProjectNum.Text = ""; } else { ddlEstateProjectNum.Text = obj.EstateProjectNumText; } //合同主体 if (obj.ContractSubject == "00000") { ddlContractSubject.Text = ""; } else { ddlContractSubject.Text = obj.ContractSubjectName; } tbContractSubject1.Text = obj.ContractSubjectName2; tbContractSubject2.Text = obj.ContractSubjectName3; tbContractSubject3.Text = obj.ContractSubjectName4; tbContractTitle.Text = obj.ContractTitle; tbContractContent.Text = obj.ContractContent; cbIsReport.Checked = obj.IsReport == "1" ? true : false; } } catch (Exception ex) { throw ex; } }