using log4net; using System; using System.Collections.Generic; using ADODB; using MSXML2; using NoteManageAR; using UFIDA.U8.Framework.Api.ControlObject.Common; using UFIDA.U8.Framework.Api.ControlObject.Json; using UFIDA.U8.Framework.Api.ControlObject.Models; using UFIDA.U8.Framework.Api.ControlObject.U8M; // ReSharper disable IdentifierTypo // ReSharper disable InconsistentNaming // ReSharper disable StringLiteralTypo namespace UFIDA.U8.Framework.Api.ControlObject.AP { public class UFAPBO { protected readonly ILog logInfo = LogManager.GetLogger("logInfo"); /// /// 收付款单保存 /// /// 登录对象 /// 单据数据 /// 子系统Id /// 是否新增 /// 是否期初 /// 表体数据字段 /// public BaseResult CloseBillSave(BaseLogin baseLogin,Dictionary dictionary,string cSubId,bool isAdd=true, bool bFirst=false,string bodyKey="body") { try { var m_Login = baseLogin._vbLogin; var domHead = dictionary.ToDocument2(); IXMLDOMDocument2 domBody = new DOMDocument(); if (dictionary[bodyKey] is List> bodyList && bodyList.Count > 0) { domBody = bodyList.ToDocument2(domBody); } var bo = "UFAPBO.clsCloseBill".GetComObject(); var m_conn = new Connection(); m_conn.Open(m_Login.UfDbName); bo.Init(m_Login, m_conn, null,cSubId); bo.First = bFirst; var errorMessage = ""; var checkFlag = bo.VouchCheck(domHead, domBody, ref errorMessage, isAdd); if (!checkFlag) throw new Exception(errorMessage); errorMessage = ""; var saveFlag = bo.SaveVouch(domHead, domBody, ref errorMessage, isAdd); if (!saveFlag) throw new Exception(errorMessage); return new BaseResult { bSuccess = true, message = "保存成功", result = "保存成功" }; } catch (Exception ex) { logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "保存失败", result = ex.Message }; } } /// /// 收付款单审核 /// /// 登录对象 /// 单号 /// 单据类型 /// 单据Id /// 子系统Id /// 是否期初 /// public BaseResult CloseBillSign(BaseLogin baseLogin,string cLink,string cVouchType,string cVouchID, string cSubId, bool bFirst = false) { try { IXMLDOMDocument2 oDom = new DOMDocument(); oDom.loadXML(""); var oElm = oDom.documentElement; oElm.setAttribute("type", 0); oElm.setAttribute("cLink", cLink); oElm.setAttribute("cVouchType", cVouchType); oElm.setAttribute("cVouchID", cVouchID); oElm.setAttribute("bFirst", bFirst); var bo = "UFAPBO.clsCloseBill".GetComObject(); var m_Login = baseLogin._vbLogin; var m_conn = new Connection(); m_conn.Open(m_Login.UfDbName); bo.Init(m_Login, m_conn, null, cSubId); var errorMessage = ""; var signFlag = bo.Sign(oElm.xml, ref errorMessage); if (!signFlag) throw new Exception(errorMessage); return new BaseResult { bSuccess = true, message = "审核成功", result = "审核成功" }; } catch (Exception ex) { logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "审核失败", result = ex.Message }; } } /// /// 票据录入 /// /// 登录对象 /// 单据数据 /// 是否新增 /// /// public BaseResult ApNoteSave(BaseLogin baseLogin, Dictionary dictionary, string cSubId, bool isAdd = true, bool bFirst = false) { try { var m_Login = baseLogin._vbLogin; var domHead = dictionary.ToDocument2(); if (cSubId == "AR") { var pub = "NoteManageAR.clsPub".GetComObject(); pub.main(m_Login); var ar = "NoteManageAR.Voucher".GetComObject(); ar.Init(m_Login, pub.RepSys, pub.RepManager); var da = new VoucherDataClass(); var apar = new APARHelper(da); ar.m_bStartFlag = false; ar.bLastYearBill = false; ar.m_strCardNum = "RP02"; ar.m_strVoucherType = "50"; ar.m_strVoucherDirect = pub.strNoteDirect; //ar.bUpdateiAmount = true; //ar.NotExec = true; //ar.NotExec = true; ar.objPub = pub; apar.SetValue(dictionary); ar.m_strVoucherID = da.CVouchId; ar.m_VoucherHead = domHead; ar.OneVoucherData = da; ar.bNeedBillClosed = true; //da.cVouchTypeName = "银行承兑汇票"; //da.cPayBillBank = "华夏银行股份有限公司深圳分行营业部"; var msg = ""; //logInfo.Debug($"da:{da.ToJson()}"); //if (!ar.VoucherHeadCheck(da, true, ref msg)) //{ // throw new Exception(msg); //} //msg = ""; if (!ar.NoteCheck(da, ref msg)) { throw new Exception(msg); } msg = ""; if (!ar.NoteSave(da, ref msg)) { throw new Exception(msg); } //ar.re //var bo = "UFAPBO.clsApNote".GetComObject(); var apPub = "NoteManageAR.PZ_Proc".GetComObject(); apPub.objPub = pub; var aa=apPub.ProcSign("9A"); var bb = pub.cNoteCancelNo; //var m_conn = new Connection(); //m_conn.Open(m_Login.UfDbName); //bo.Init(m_Login, m_conn); //var errorMessage = ""; //var saveFlag = bo.Sign($"", ref errorMessage); //if (!saveFlag) // throw new Exception(errorMessage); return new BaseResult { bSuccess = true, message = "保存成功", result = "保存成功" }; } //var ap= "UFAPBO.clsAccount_AP".GetComObject(); //var bo = "UFAPBO.clsApNote".GetComObject(); //var a=ap.Init(m_Login, cSubId); //logInfo.Debug($"ap.Init:{a}"); //var b=ap.InitSubOption2(cSubId); //logInfo.Debug($"ap.InitSubOption2:{b}"); //var c=ap.ARAPStart(cSubId); //logInfo.Debug($"ap.ARAPStart:{c}"); //var m_conn = new Connection(); //m_conn.Open(m_Login.UfDbName); //var d=bo.Init(m_Login); //logInfo.Debug($"bo.Init:{d}"); //var errorMessage = ""; //var saveFlag = bo.SaveVouch(domHead, ref errorMessage); //logInfo.Debug($"bo.SaveVouch:{errorMessage}"); //if (!saveFlag) // throw new Exception(errorMessage); return new BaseResult { bSuccess = true, message = "保存成功", result = "保存成功" }; } catch (Exception ex) { logInfo.Error(ex.Message, ex); return new BaseResult { bSuccess = false, message = "保存失败", result = ex.Message }; } } } }