using SuperMap.RealEstate.Configuration; using SuperMap.RealEstate.CoreFrameWork; using SuperMap.RealEstate.Web.UI.WebControls; using SuperMap.RealEstate.Utility; using SuperMap.RealEstate.WorkFlow; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml; using System.Xml.Xsl; using System.Reflection; using Instance = SuperMap.RealEstate.WorkFlow.Instance; using HZQR.Common; namespace SuperMap.RealEstate.HighWay.Compents.ApproveTender { public partial class ApproveBillManagement : SuperMap.RealEstate.Web.UI.UserControl { Running.Business.HIGHWAYPROINST _ProInst = null; #region ViewState string XslPath = @"/PrintReport/HighWay/ApproveBillManagement/ApproveTenderBill.xsl"; private string ReportXmlPath { get { return ViewState["ApproveBillManagementXmlPath"] == null ? "" : (string)ViewState["ApproveBillManagementXmlPath"]; } set { ViewState["ApproveBillManagementXmlPath"] = value; } } private string ReportXslPath { get { return ViewState["ApproveBillManagementXslPath"] == null ? XslPath : (string)ViewState["ApproveBillManagementXslPath"]; } } #endregion protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; } #region 初始加载 public override bool LoadData() { string _FileName = "ApproveBillManagement_" + (string.IsNullOrEmpty(_ProInst.Accept_Code) ? Guid.NewGuid().ToString() : _ProInst.Accept_Code) + ".xml"; CreateDocumentInit(_FileName); return true; } #endregion #region CreateDocumentInit 创建文档 private void CreateDocumentInit(String File_Name) { ReportXmlPath = File_Name; if (!Directory.Exists(EnvironmentHelper.Temp + "HighWay\\")) Directory.CreateDirectory(EnvironmentHelper.Temp + "HighWay\\"); if (File.Exists(EnvironmentHelper.Temp + "HighWay\\" + File_Name)) File.Delete(EnvironmentHelper.Temp + "HighWay\\" + File_Name); using (FileStream _FileStream = new FileStream(EnvironmentHelper.Temp + "HighWay\\" + File_Name, FileMode.OpenOrCreate)) { using (StreamWriter _StreamWriter = new StreamWriter(_FileStream)) { _StreamWriter.Write(CreateXmlBill()); _StreamWriter.Close(); InitXml(); } } } #endregion #region 组件加载扩展 LoadDataEx /// /// 组件加载扩展 /// /// 脚本 /// public override bool LoadDataEx(ClientSetEventArgs ClientSet) { string _FileName = "ApproveBillManagement_" + (string.IsNullOrEmpty(_ProInst.Accept_Code) ? Guid.NewGuid().ToString() : _ProInst.Accept_Code) + ".xml"; //报表解析 CreateDocumentInit(_FileName); string _Document = Running.Business.HIGHWAYPROINST.Transform(_FileName, ReportXslPath); //执行前端重置 ClientSet.ExcuteClientScript("$('#" + ApproveBillManagement_Report.ClientID + "').html('" + _Document + "');"); return true; } #endregion #region 创建文档 private string CreateXmlBill() { XmlDocument _XmlDocument = new XmlDocument(); #region 文档头 XmlDeclaration _XmlDeclaration = _XmlDocument.CreateXmlDeclaration("1.0", "utf-8", "yes"); _XmlDocument.AppendChild(_XmlDeclaration); XmlProcessingInstruction _XmlProcessingInstruction = _XmlDocument.CreateProcessingInstruction("xml-stylesheet", " type='text/xsl' href='" + XslPath + "'"); _XmlDocument.AppendChild(_XmlProcessingInstruction); XmlElement _XmlElement = null; _XmlElement = _XmlDocument.CreateElement("SuperMapDoucuments"); _XmlDocument.AppendChild(_XmlElement); #endregion #region 枚举 Dictionary _Dictionary = new Dictionary(); _Dictionary.Add("OPERATION_TYPE", "OPERATION_TYPE"); _Dictionary.Add("URGENT_STATE", "URGENT_STATE"); _Dictionary.Add("TENDER_TYPE", "TENDER_TYPE"); _Dictionary.Add("APPLYIMPLEMENT_TYPE", "APPLYIMPLEMENT_TYPE"); _Dictionary.Add("PROJECT_BELONG", "APPLYIMPLEMENT_TYPE"); #endregion switch (_ProInst.ProInst.Operation_Type_BaseValue) { case 350100: _XmlElement = _XmlDocument.CreateElement("SuperMap"); _XmlDocument.DocumentElement.AppendChild(_XmlElement); GetProInst(_XmlDocument, _XmlElement, _Dictionary, true); GetApproved(_XmlDocument, _XmlElement, _Dictionary, true); break; case 350200: _XmlElement = _XmlDocument.CreateElement("SuperMap"); _XmlDocument.DocumentElement.AppendChild(_XmlElement); GetProInst(_XmlDocument, _XmlElement, _Dictionary, true); GetApproved(_XmlDocument, _XmlElement, _Dictionary, true); break; case 350300: _XmlElement = _XmlDocument.CreateElement("SuperMap"); _XmlDocument.DocumentElement.AppendChild(_XmlElement); GetProInst(_XmlDocument, _XmlElement, _Dictionary, true); GetApproved(_XmlDocument, _XmlElement, _Dictionary, true); break; case 350400: _XmlElement = _XmlDocument.CreateElement("SuperMap"); _XmlDocument.DocumentElement.AppendChild(_XmlElement); GetProInst(_XmlDocument, _XmlElement, _Dictionary, true); GetApproved(_XmlDocument, _XmlElement, _Dictionary, true); break; default: _XmlElement = _XmlDocument.CreateElement("SuperMap"); _XmlDocument.DocumentElement.AppendChild(_XmlElement); GetProInst(_XmlDocument, _XmlElement, _Dictionary, true); GetApproved(_XmlDocument, _XmlElement, _Dictionary, true); break; } #region 根据业务类型执行文档解析 //根据业务类型执行文档解析 switch (_ProInst.ProInst.Operation_Type_BaseValue) { //合同插件 case 350100: //InitTenderInsert(_XmlDocument, _XmlElement, _Dictionary); //break; case 350200: //InitTenderInsert(_XmlDocument, _XmlElement, _Dictionary); //break; case 350300: InitTenderInsert(_XmlDocument, _XmlElement, _Dictionary); break; case 350400: InitTenderInsert(_XmlDocument, _XmlElement, _Dictionary); break; } #endregion return _XmlDocument.InnerXml; } #endregion #region 流程信息 private void GetProInst(XmlDocument _XmlDocument, XmlElement _XmlElement, Dictionary _Dictionary, bool isChildNodes = false) { XmlElement _ChildXmlElement = _XmlDocument.CreateElement("ProInst"); if (isChildNodes) _XmlElement.AppendChild(_ChildXmlElement); else _XmlDocument.DocumentElement.AppendChild(_ChildXmlElement); _ProInst.CreateXmlNode(_ProInst.ProInst, _XmlDocument, _ChildXmlElement, _Dictionary); } #endregion #region 审批意见 private void GetApproved(XmlDocument _XmlDocument, XmlElement _XmlElement, Dictionary _Dictionary, bool isChildNodes = false) { short _Approved_Type = 0; //审批意见 foreach (Running.Business.APPROVED _Approved in _ProInst.ApprovedCollection) { if (_Approved_Type == _Approved.Approved_Type.Value) { continue; } _Approved_Type = _Approved.Approved_Type.Value; XmlElement _ChildXmlElement = _XmlDocument.CreateElement("ApprovedInfo"); if (isChildNodes) { _XmlElement.AppendChild(_ChildXmlElement); } else { _XmlDocument.DocumentElement.AppendChild(_ChildXmlElement); } if (new Running.Business.JOINTLYSIGN(_ProInst).GetCount("WHERE HIGHWAYPROINST_ID = " + _ProInst.HIGHWAYPROINST_ID + " AND APPROVED_TYPE = " + _Approved.Approved_Type) > 0 || _Approved.GetCount("WHERE HIGHWAYPROINST_ID = " + _ProInst.HIGHWAYPROINST_ID + " AND APPROVED_TYPE = " + _Approved.Approved_Type) > 1) { XmlElement _XmlElementChildCollection = null; XmlElement _XmlElementChild = null; //审核环节 _XmlElementChildCollection = _XmlDocument.CreateElement("Approved_Name"); _ChildXmlElement.AppendChild(_XmlElementChildCollection); _XmlElementChildCollection.InnerText = _Approved.Approved_Name; foreach (Running.Business.APPROVED _APPROVED in new Running.Business.APPROVED(_ProInst).FillCollection( "WHERE HIGHWAYPROINST_ID = " + _ProInst.HIGHWAYPROINST_ID + " AND APPROVED_TYPE = " + _Approved.Approved_Type + " ORDER BY APPROVED_DATE")) { _XmlElementChildCollection = _XmlDocument.CreateElement("ApproveCollection"); _ChildXmlElement.AppendChild(_XmlElementChildCollection); //审核内容 _XmlElementChild = _XmlDocument.CreateElement("Approved_Info"); _XmlElementChildCollection.AppendChild(_XmlElementChild); _XmlElementChild.InnerText = _APPROVED.Approved_Info; //审核人员 _XmlElementChild = _XmlDocument.CreateElement("Approved_Staff"); _XmlElementChildCollection.AppendChild(_XmlElementChild); _XmlElementChild.InnerText = _APPROVED.Approved_Staff; //审核日期 _XmlElementChild = _XmlDocument.CreateElement("Approved_Date"); _XmlElementChildCollection.AppendChild(_XmlElementChild); _XmlElementChild.InnerText = _APPROVED.Approved_Date.Value.ToLongDateString(); } } else { _ProInst.CreateXmlNode(_Approved, _XmlDocument, _ChildXmlElement, _Dictionary); } } } #endregion //////////////--------------------------业务相关----------------// #region 方法 -> 审批信息 private void InitTenderInsert(XmlDocument _XmlDocument, XmlElement _XmlElement, Dictionary _Dictionary) { if (_XmlElement == null) throw new Exception("首节点不能为空"); if (_ProInst.TenderCollection == null) return; XmlElement _ChildXmlElement = null; XmlElement _XmlElementChild = null; foreach (Running.Business.TENDER _TENDER in _ProInst.TenderCollection) { _ChildXmlElement = _XmlDocument.CreateElement("Tender"); _XmlElement.AppendChild(_ChildXmlElement); //供应商邀请方式 _XmlElementChild = _XmlDocument.CreateElement("INVITATION_METHOD"); _ChildXmlElement.AppendChild(_XmlElementChild); _XmlElementChild.InnerText = DictionaryHelper.GetFieldEnumName("INVITATION_METHOD", _TENDER.APPLYIMPLEMENT_TYPE.TryParseToString(), Transaction); _XmlElementChild = _XmlDocument.CreateElement("SERVERPART_NAME"); _ChildXmlElement.AppendChild(_XmlElementChild); _XmlElementChild.InnerText = _ProInst.Dept_Name; _ProInst.CreateXmlNode(_TENDER, _XmlDocument, _ChildXmlElement, _Dictionary); } } #endregion //#region 使用 //void Use(XmlDocument _XmlDocument, XmlElement _XmlElement, Dictionary _Dictionary) //{ // if (_XmlElement == null) // throw new Exception("SuperMap首节点不能为空"); // if (_ProInst.FundUseProjectScopeCollection.Count == 0) // { // XmlElement _ChildXmlElement = _XmlDocument.CreateElement("SuperMap"); // _XmlDocument.DocumentElement.AppendChild(_ChildXmlElement); // GetProInst(_XmlDocument, _ChildXmlElement, _Dictionary, true); // GetProposer(_XmlDocument, _ChildXmlElement, _Dictionary, true); // GetApproved(_XmlDocument, _ChildXmlElement, _Dictionary, true); // } // foreach (Running.Business.FundUseProjectScope _FundUseProjectScope in _ProInst.FundUseProjectScopeCollection) // { // XmlElement _ChildXmlElement = _XmlDocument.CreateElement("SuperMap"); // _XmlDocument.DocumentElement.AppendChild(_ChildXmlElement); // GetProInst(_XmlDocument, _ChildXmlElement, _Dictionary, true); // GetProposer(_XmlDocument, _ChildXmlElement, _Dictionary, true); // GetApproved(_XmlDocument, _ChildXmlElement, _Dictionary, true); // XmlElement _ChildXmlElementFundUseProjectScope = _XmlDocument.CreateElement("FundUseProjectScope"); // _ChildXmlElement.AppendChild(_ChildXmlElementFundUseProjectScope); // _ProInst.CreateXmlNode(_FundUseProjectScope, _XmlDocument, _ChildXmlElementFundUseProjectScope, _Dictionary); // foreach (Running.Business.BuildingSection _BuildingSection in _FundUseProjectScope.BuildingSectionCollection) // { // XmlElement _ChildXmlElementBuildingSection = _XmlDocument.CreateElement("BuildingSection"); // _ChildXmlElement.AppendChild(_ChildXmlElementBuildingSection); // _ProInst.CreateXmlNode(_BuildingSection, _XmlDocument, _ChildXmlElementBuildingSection, _Dictionary); // } // string strsql = "SELECT A.BANK_NAME,A.AUDITUNIT_NAME,A.BANK_PASSPORTNAME,A.BANK_ACCOUNT FROM PROPERTYMANAGE_RUNNING.T_AUDITUNITSECTION A,PROPERTYMANAGE_RUNNING.T_PROJECTFUND B,PROPERTYMANAGE_RUNNING.T_FUNDUSEPLAN C WHERE A.PROJECTFUND_ID = B.PROJECTFUND_ID AND B.FUNDUSEPLAN_ID = C.FUNDUSEPLAN_ID AND C.FUNDUSEPROJECTSCOPE_ID = " + _FundUseProjectScope.FundUseProjectScope_ID; // DataTable _DataTable = (new Running.Business.FundUseProjectScope()).ExecuteDataTable(strsql); // foreach (DataRow _DataRow in _DataTable.Rows) // { // XmlElement _ChildXmlElementAUDITUNITSECTION = _XmlDocument.CreateElement("SHUnit"); // _ChildXmlElement.AppendChild(_ChildXmlElementAUDITUNITSECTION); // //单位 // XmlElement _ChildXmlElementAUDITUNITSECTIONObject = _XmlDocument.CreateElement("SHUnitName"); // _ChildXmlElementAUDITUNITSECTION.AppendChild(_ChildXmlElementAUDITUNITSECTIONObject); // _ChildXmlElementAUDITUNITSECTIONObject.InnerText = _DataRow["AUDITUNIT_NAME"] == null ? "" : _DataRow["AUDITUNIT_NAME"].ToString(); // //开户行 // _ChildXmlElementAUDITUNITSECTIONObject = _XmlDocument.CreateElement("SHUnitKHH"); // _ChildXmlElementAUDITUNITSECTION.AppendChild(_ChildXmlElementAUDITUNITSECTIONObject); // _ChildXmlElementAUDITUNITSECTIONObject.InnerText = _DataRow["BANK_NAME"] == null ? "" : _DataRow["BANK_NAME"].ToString(); // //开户名 SHUnitKHName // _ChildXmlElementAUDITUNITSECTIONObject = _XmlDocument.CreateElement("SHUnitKHName"); // _ChildXmlElementAUDITUNITSECTION.AppendChild(_ChildXmlElementAUDITUNITSECTIONObject); // _ChildXmlElementAUDITUNITSECTIONObject.InnerText = _DataRow["BANK_PASSPORTNAME"] == null ? "" : _DataRow["BANK_PASSPORTNAME"].ToString(); // //账号 SHUnitKHAccount // _ChildXmlElementAUDITUNITSECTIONObject = _XmlDocument.CreateElement("SHUnitKHAccount"); // _ChildXmlElementAUDITUNITSECTION.AppendChild(_ChildXmlElementAUDITUNITSECTIONObject); // _ChildXmlElementAUDITUNITSECTIONObject.InnerText = _DataRow["BANK_ACCOUNT"] == null ? "" : _DataRow["BANK_ACCOUNT"].ToString(); // } // XmlElement _ChildXmlElementSupervisePassport = _XmlDocument.CreateElement("SupervisePassport"); // _ChildXmlElement.AppendChild(_ChildXmlElementSupervisePassport); // _ProInst.CreateXmlNode(_FundUseProjectScope.SupervisePassportInfo, _XmlDocument, _ChildXmlElementSupervisePassport, _Dictionary); // double OtherMoney = 0.0; // foreach (Running.Business.FundUsePlan _FundUsePlan in _FundUseProjectScope.FundUsePlanCollection) // { // XmlElement _ChildXmlElementFundUsePlan = _XmlDocument.CreateElement("FundUsePlan"); // _ChildXmlElement.AppendChild(_ChildXmlElementFundUsePlan); // _ProInst.CreateXmlNode(_FundUsePlan, _XmlDocument, _ChildXmlElementFundUsePlan, _Dictionary); // foreach( Running.Business.ProjectFund _ProjectFund in _FundUsePlan.ProjectFundCollection) // { // OtherMoney += _ProjectFund.ProjectFund_Money.Value; // } // } // _ProInst.CreateXmlNode("ProjectFund_Money", OtherMoney.ToString(), _XmlDocument, _ChildXmlElementFundUseProjectScope, _Dictionary); // } //} //#endregion protected override void OnInit(EventArgs e) { base.OnInit(e); Common.PageHelper.CreateHeaderStyle(Page); _ProInst = Running.Business.HIGHWAYPROINST.CreateInstance(Page); this.ButtonVisible = false; InitXml(); } private void InitXml() { if (!string.IsNullOrEmpty(ReportXmlPath)) { Xml1.TransformSource = ReportXslPath; Xml1.DocumentSource = @"/Temporary/Temp/HighWay/" + ReportXmlPath; } } protected void CallBackButton_Print_CallBackClick(object sender, ClientSetEventArgs e) { e.ClientScript = Page.GetOpenPopDialogClientScript("/HighWay/Common/ReportDefault.aspx?ReportXmlPath=" + ReportXmlPath + "&ReportXslPath=" + ReportXslPath + "&ProInst_ID=" + _ProInst.ProInst.ProInst_ID_Encrypt.ToString(), "ReportDefault", 1000, 600, true, false, true); } public override bool Save(bool AutoBindData = true) { InitXml(); Running.Business.JOINTLYSIGN _JOINTLYSIGN = new Running.Business.JOINTLYSIGN(_ProInst); _JOINTLYSIGN.AddSearchParameter("HIGHWAYPROINST_ID", _ProInst.HIGHWAYPROINST_ID); _JOINTLYSIGN.AddSearchParameter("ActDef_ID", _ProInst.ProInst.NowActInst.ActDef_ID); if (_JOINTLYSIGN.Search()) { if (string.IsNullOrEmpty(_JOINTLYSIGN.APPROVED_IDS) || (_JOINTLYSIGN.USER_IDS.Split(',').Length != _JOINTLYSIGN.APPROVED_IDS.Split(',').Length)) { //2017/11/17朱梓毅修改,会审转出时提示未进行会审人员 if (string.IsNullOrEmpty(_JOINTLYSIGN.APPROVED_IDS)) { throw new Exception("请" + _JOINTLYSIGN.USER_NAMES + "审核后再转出业务!"); } else if (_JOINTLYSIGN.USER_IDS.Split(',').Length != _JOINTLYSIGN.APPROVED_IDS.Split(',').Length) { string _USER_NAMES = "," + _JOINTLYSIGN.USER_NAMES + ","; foreach (Running.Business.APPROVED _APPROVED in new Running.Business.APPROVED(_ProInst).FillCollection( "WHERE APPROVED_ID IN (" + _JOINTLYSIGN.APPROVED_IDS + ")")) { if (_USER_NAMES.Contains("," + _APPROVED.Approved_Staff + ",")) { _USER_NAMES = _USER_NAMES.Replace("," + _APPROVED.Approved_Staff + ",", ","); } } _USER_NAMES = _USER_NAMES.Trim(','); if (!string.IsNullOrWhiteSpace(_USER_NAMES)) { throw new Exception("请" + _USER_NAMES + "审核后再转出业务!"); } } } } return true; } public override bool SaveEx(ClientSetEventArgs ClientSet) { return true; } public override void BindObjectToControl() { } protected void CallBackButton_Reflash_CallBackClick(object sender, ClientSetEventArgs e) { LoadDataEx(e); } } }