From 7245c08c949e4a23c6091363cab9cccd3727385c Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 7 Jan 2021 14:06:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=87=E8=B4=AD=E5=85=A5=E5=BA=93=E6=88=90?= =?UTF-8?q?=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NX.ERP.Model/Purchase/Arrival.cs | 12 + NX.ERP.Model/Purchase/ArrivalDetail.cs | 5 + NX.ERP.Model/Store/PuStoreIn.cs | 17 +- NX.ERP.Model/Store/PuStoreInDetail.cs | 12 +- NX.ERP.U8.App/FrmMain.Designer.cs | 30 ++- NX.ERP.U8.App/FrmMain.cs | 42 +++- NX.ERP.U8.App/FrmMain.resx | 6 +- NX.ERP.U8/Purchase/ArrivalDAL.cs | 43 +++- NX.ERP.U8/Store/PuStoreInDAL.cs | 322 ++++++++++++++++++++++++- NX.ERP.U8/U8LoginContext.cs | 92 ++++++- NX.ERP.U8/VoucherParameter.cs | 23 +- 11 files changed, 543 insertions(+), 61 deletions(-) diff --git a/NX.ERP.Model/Purchase/Arrival.cs b/NX.ERP.Model/Purchase/Arrival.cs index 240cc6b..026e074 100644 --- a/NX.ERP.Model/Purchase/Arrival.cs +++ b/NX.ERP.Model/Purchase/Arrival.cs @@ -21,5 +21,17 @@ namespace NX.ERP.Model.Purchase public DateTime Date { get => _date; set => _date = value; } public ICollection ArrivalDetails { get => arrivalDetails; set => arrivalDetails = value; } public string SupplierCode { get => supplierCode; set => supplierCode = value; } + + public decimal ExchRate { get; set; } + public string ExchName { get; set; } + + public string VenCode { get; set; } + + + public decimal TaxRate { get; set; } + + public string PTCode { get; set; } + + } } diff --git a/NX.ERP.Model/Purchase/ArrivalDetail.cs b/NX.ERP.Model/Purchase/ArrivalDetail.cs index 3065e47..a1a5481 100644 --- a/NX.ERP.Model/Purchase/ArrivalDetail.cs +++ b/NX.ERP.Model/Purchase/ArrivalDetail.cs @@ -27,5 +27,10 @@ namespace NX.ERP.Model.Purchase private string unitCode; private decimal quantity; private int iverifystateex; + + public int posId { get; set; } + + public string OrderCode { get; set; } + public int PoId { get; set; } } } diff --git a/NX.ERP.Model/Store/PuStoreIn.cs b/NX.ERP.Model/Store/PuStoreIn.cs index c5c5c4f..1c17dc6 100644 --- a/NX.ERP.Model/Store/PuStoreIn.cs +++ b/NX.ERP.Model/Store/PuStoreIn.cs @@ -10,17 +10,17 @@ namespace NX.ERP.Model.Store /// public class PuStoreIn { - + private int id; private string code; private DateTime date; private string depcode; private string whcode; - private ICollection puStoreInDetails = new List(); + private IList puStoreInDetails = new List(); private string _puCode; private string maker; private string personCode; - public ICollection PuStoreInDetails { get => puStoreInDetails; set => puStoreInDetails = value; } + public IList PuStoreInDetails { get => puStoreInDetails; set => puStoreInDetails = value; } public int Id { get => id; set => id = value; } public string Code { get => code; set => code = value; } public DateTime Date { get => date; set => date = value; } @@ -30,5 +30,16 @@ namespace NX.ERP.Model.Store public string Maker { get => maker; set => maker = value; } public string PersonCode { get => personCode; set => personCode = value; } public string RdCode { get; set; } + public string SupplierName { get; set; } + public string SupplierCode { get; set; } + /// + /// 源单类别 + /// + public string Source { get; set; } + /// + /// 源单编号 + /// + public string SourceCode { get; set; } + } } diff --git a/NX.ERP.Model/Store/PuStoreInDetail.cs b/NX.ERP.Model/Store/PuStoreInDetail.cs index 4e7eda9..394171f 100644 --- a/NX.ERP.Model/Store/PuStoreInDetail.cs +++ b/NX.ERP.Model/Store/PuStoreInDetail.cs @@ -11,6 +11,16 @@ namespace NX.ERP.Model.Store private int puStoreInId; private string invcode; private string unit; - private string quantity; + private decimal quantity; + public string Batch { get; set; } + + public int Id { get => id; set => id = value; } + public int PuStoreInId { get => puStoreInId; set => puStoreInId = value; } + public string Invcode { get => invcode; set => invcode = value; } + public string Unit { get => unit; set => unit = value; } + public decimal Quantity { get => quantity; set => quantity = value; } + + + public int SorceDetailId { get; set; } } } diff --git a/NX.ERP.U8.App/FrmMain.Designer.cs b/NX.ERP.U8.App/FrmMain.Designer.cs index 3a87739..1f23311 100644 --- a/NX.ERP.U8.App/FrmMain.Designer.cs +++ b/NX.ERP.U8.App/FrmMain.Designer.cs @@ -32,6 +32,7 @@ namespace U8AppMain this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.操作ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.BtnReadExcel = new System.Windows.Forms.ToolStripMenuItem(); + this.登录ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.导入ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ImportBom = new System.Windows.Forms.ToolStripMenuItem(); this.BtnPurchaseImport = new System.Windows.Forms.ToolStripMenuItem(); @@ -41,13 +42,12 @@ namespace U8AppMain this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.richTextBox1 = new System.Windows.Forms.RichTextBox(); - this.登录ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); - this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); - + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // // menuStrip1 @@ -68,7 +68,8 @@ namespace U8AppMain // this.操作ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.BtnReadExcel, - this.登录ToolStripMenuItem}); + this.登录ToolStripMenuItem, + this.toolStripMenuItem2}); this.操作ToolStripMenuItem.Name = "操作ToolStripMenuItem"; this.操作ToolStripMenuItem.Size = new System.Drawing.Size(45, 19); this.操作ToolStripMenuItem.Text = "文件"; @@ -80,6 +81,13 @@ namespace U8AppMain this.BtnReadExcel.Text = "读取Excel"; this.BtnReadExcel.Click += new System.EventHandler(this.BtnReadExcel_Click); // + // 登录ToolStripMenuItem + // + this.登录ToolStripMenuItem.Name = "登录ToolStripMenuItem"; + this.登录ToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.登录ToolStripMenuItem.Text = "登录"; + this.登录ToolStripMenuItem.Click += new System.EventHandler(this.登录ToolStripMenuItem_Click); + // // 导入ToolStripMenuItem // this.导入ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -178,12 +186,12 @@ namespace U8AppMain this.richTextBox1.Text = ""; this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged); // - // 登录ToolStripMenuItem + // toolStripMenuItem2 // - this.登录ToolStripMenuItem.Name = "登录ToolStripMenuItem"; - this.登录ToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.登录ToolStripMenuItem.Text = "登录"; - this.登录ToolStripMenuItem.Click += new System.EventHandler(this.登录ToolStripMenuItem_Click); + this.toolStripMenuItem2.Name = "toolStripMenuItem2"; + this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 22); + this.toolStripMenuItem2.Text = "1"; + this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click); // // FrmMain // @@ -201,9 +209,8 @@ namespace U8AppMain this.menuStrip1.PerformLayout(); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); - this.splitContainer1.ResumeLayout(false); - + ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -223,6 +230,7 @@ namespace U8AppMain private System.Windows.Forms.ToolStripMenuItem 打印ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 打印ToolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem 登录ToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; } } diff --git a/NX.ERP.U8.App/FrmMain.cs b/NX.ERP.U8.App/FrmMain.cs index 0be68ca..2d0af00 100644 --- a/NX.ERP.U8.App/FrmMain.cs +++ b/NX.ERP.U8.App/FrmMain.cs @@ -287,8 +287,46 @@ namespace U8AppMain private void 登录ToolStripMenuItem_Click(object sender, EventArgs e) { - u8LoginContext = new NX.ERP.U8.U8LoginContext(); - u8LoginContext.Login(true); + var a = new NX.ERP.U8.Store.PuStoreInDAL(); + a.Loadd(); + + + //u8LoginContext = new NX.ERP.U8.U8LoginContext(); + //u8LoginContext.Login(true); + } + + private void toolStripMenuItem2_Click(object sender, EventArgs e) + { + var a = new NX.ERP.U8.Store.PuStoreInDAL(); + a.AddPuStoreIn(new NX.ERP.Model.Store.PuStoreIn() + { + Code = "0001", + PersonCode = "wx065", + PuCode = "0002", + Date = DateTime.Today, + Id = 1000021, + Depcode = "24", + //SupplierName = "上海拓恩机电科技有限公司", + SupplierCode = "10001", + Source = "采购到货单", + Whcode = "1", + SourceCode = "CGDH210100002", + Maker = "222", + RdCode = "101", + PuStoreInDetails = new List() { + new NX.ERP.Model.Store.PuStoreInDetail(){ + //Batch="001", + Quantity=2, + Id=1, + Invcode="201001", + PuStoreInId=1000021, + + SorceDetailId=1000023146, + + } + + } + }); ; } } } diff --git a/NX.ERP.U8.App/FrmMain.resx b/NX.ERP.U8.App/FrmMain.resx index d5494e3..3e14bf8 100644 --- a/NX.ERP.U8.App/FrmMain.resx +++ b/NX.ERP.U8.App/FrmMain.resx @@ -112,12 +112,12 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file diff --git a/NX.ERP.U8/Purchase/ArrivalDAL.cs b/NX.ERP.U8/Purchase/ArrivalDAL.cs index 4d361ab..1d92729 100644 --- a/NX.ERP.U8/Purchase/ArrivalDAL.cs +++ b/NX.ERP.U8/Purchase/ArrivalDAL.cs @@ -7,19 +7,25 @@ namespace NX.ERP.U8.Purchase { public class ArrivalDAL { - public IEnumerable GetList() + public IEnumerable GetList(string strWhere = "", object param = null) { using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net)) { - string strSQL = @"select a.id,a.cCode as ArrivalCode,a.dDate as date,A.cVenCode AS SupplierCode, - B.Autoid as id,b.ID as ArrivalID, - b.cInvCode AS MaterielCode, - b.cBatch AS BatchNo, - b.cUnitID AS UnitCode, - B.iQuantity as Quantity - from PU_ArrivalVouch as a - left join PU_ArrivalVouchs as b on a.id=b.id"; + string strSQL = @"select a.id,a.cCode as ArrivalCode,a.cptcode as PTCode,a.iTaxRate as TaxRate,a.iexchrate as Exchrate,cexch_name as ExchName,cVenCode as VenCode,a.dDate as date,A.cVenCode AS SupplierCode, + B.Autoid as id,b.ID as ArrivalID, + b.cInvCode AS MaterielCode, + b.cBatch AS BatchNo, + b.cUnitID AS UnitCode, + B.iQuantity as Quantity,b.iposid as PosId ,B.CORDERCODE as OrderCode,C.POID as Poid from + pu_ArrHead as a + left join pu_arrbody as b on a.id=b.id + Left Join PO_Podetails C WITH (NOLOCK) ON B.iPOsID = C.ID + "; + if (!string.IsNullOrEmpty(strWhere)) + { + strSQL += $" where {strWhere} "; + } var lookup = new Dictionary(); // return conn.Query(strSQL,null); var list = conn.Query(strSQL, (arrival, ArrivalDetail) => @@ -27,16 +33,31 @@ namespace NX.ERP.U8.Purchase if (!lookup.TryGetValue(arrival.Id, out var _arrival)) { lookup.Add(arrival.Id, arrival); - } else + } + else { arrival = _arrival; } arrival.ArrivalDetails.Add(ArrivalDetail); return arrival; - }, null, null, true, "id", 10, System.Data.CommandType.Text); + }, param, null, true, "id", 10, System.Data.CommandType.Text); return lookup.Values; } } + + public Model.Purchase.Arrival GetModel(int id) + { + return this.GetList(" a.id=@Id ", new { id }).FirstOrDefault(); + + } + + + public Model.Purchase.Arrival GetModel(string Code) + { + return this.GetList(" a.cCode=@Code ", new { Code }).FirstOrDefault(); + + } + } } diff --git a/NX.ERP.U8/Store/PuStoreInDAL.cs b/NX.ERP.U8/Store/PuStoreInDAL.cs index fd87110..2cb57c3 100644 --- a/NX.ERP.U8/Store/PuStoreInDAL.cs +++ b/NX.ERP.U8/Store/PuStoreInDAL.cs @@ -1,6 +1,7 @@ using MSXML2; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using UFIDA.U8.U8APIFramework; @@ -11,6 +12,41 @@ namespace NX.ERP.U8.Store { public class PuStoreInDAL { + public static string ReadFile(string strFileName) + { + if (!File.Exists(strFileName)) + { + return string.Empty; + } + using (StreamReader streamReader = new StreamReader(strFileName, Encoding.Default)) + { + return streamReader.ReadToEnd(); + } + } + + + public static bool WriteFile(string strContentToFile, string strFilePathName, Encoding encoding) + { + using (StreamWriter streamWriter = new StreamWriter(strFilePathName, append: false, encoding)) + { + streamWriter.Write(strContentToFile); + return true; + } + } + + + + public static bool WriteFile(string strContentToFile, string strFilePathName) + { + using (StreamWriter streamWriter = new StreamWriter(strFilePathName, append: false, Encoding.Default)) + { + streamWriter.Write(strContentToFile); + return true; + } + } + + + /// /// 保存一个采购到货单 /// @@ -22,21 +58,285 @@ namespace NX.ERP.U8.Store voucherParameter.DomHead = new DOMDocumentClass(); voucherParameter.DomBody = new DOMDocumentClass(); - IXMLDOMElement iXMLDOMElement = voucherParameter.DomHead.createElement("z:row"); - iXMLDOMElement.setAttribute("biafirst", "0"); - iXMLDOMElement.setAttribute("bpufirst", "0"); - iXMLDOMElement.setAttribute("bisstqc", "0"); - iXMLDOMElement.setAttribute("bomfirst", "0"); - iXMLDOMElement.setAttribute("brdflag", 1); - iXMLDOMElement.setAttribute("ccode", puStoreIn.Code); - iXMLDOMElement.setAttribute("ddate", puStoreIn.Date.ToShortDateString()); - iXMLDOMElement.setAttribute("cmaker", puStoreIn.Maker); - iXMLDOMElement.setAttribute("cvouchtype", "01"); - ///iXMLDOMElement.setAttribute("vt_id", ((U8ApiInterfaceBase)u8STApiInterface).get_Util().GetDefaltVTID("24", "", "")); + DOMDocument domHead = voucherParameter.DomHead; + DOMDocument domBody = voucherParameter.DomBody; + + voucherParameter.DomHead.loadXML(ReadFile(AppDomain.CurrentDomain.BaseDirectory + "\\XMLDOM\\XMLDomHead01.xml")); + voucherParameter.DomBody.loadXML(ReadFile(AppDomain.CurrentDomain.BaseDirectory + "\\XMLDOM\\XMLDomBody01.xml")); + + + + + + + IXMLDOMElement iXMLDOMElement = domHead.createElement("z:row"); + iXMLDOMElement.setAttribute("id", "11"); //DomHead[0]["id"] = ""; //主关键字段,int类型 + iXMLDOMElement.setAttribute("bomfirst", "0"); //DomHead[0]["bomfirst"] = ""; //委外期初标志,string类型 + iXMLDOMElement.setAttribute("ccode", "211"); //DomHead[0]["ccode"] = ""; //入库单号,string类型 + iXMLDOMElement.setAttribute("ddate", puStoreIn.Date.ToShortDateString()); //DomHead[0]["ddate"] = ""; //入库日期,DateTime类型 + iXMLDOMElement.setAttribute("iverifystate", 1); //DomHead[0]["iverifystate"] = ""; //iverifystate,int类型 + iXMLDOMElement.setAttribute("iswfcontrolled", 1); //DomHead[0]["iswfcontrolled"] = ""; //iswfcontrolled,int类型 + //iXMLDOMElement.setAttribute("cbustype", "0"); //DomHead[0]["cbustype"] = ""; //业务类型,int类型 + //iXMLDOMElement.setAttribute("iexchrate", 1); //DomHead[0]["iexchrate"] = ""; //汇率,double类型 + //iXMLDOMElement.setAttribute("cexch_name", "人民币"); //DomHead[0]["cexch_name"] = ""; //币种,string类型 + //iXMLDOMElement.setAttribute("ufts", "asdasd"); //DomHead[0]["ufts"] = ""; //时间戳,string类型 + iXMLDOMElement.setAttribute("bpufirst", "0"); //DomHead[0]["bpufirst"] = ""; //采购期初标志,string类型 + + iXMLDOMElement.setAttribute("cvouchtype", "01");//DomHead[0]["cvouchtype"] = ""; //单据类型,string类型 + iXMLDOMElement.setAttribute("brdflag", 1); //DomHead[0]["brdflag"] = ""; //收发标志,int类型 + iXMLDOMElement.setAttribute("csource", puStoreIn.Source); //DomHead[0]["csource"] = ""; //单据来源,int类型 + iXMLDOMElement.setAttribute("cmaker", puStoreIn.Maker);//DomHead[0]["cmaker"] = ""; //制单人,string类型 + iXMLDOMElement.setAttribute("vt_id", "27"); iXMLDOMElement.setAttribute("editprop", "A"); iXMLDOMElement.setAttribute("cdepcode", puStoreIn.Depcode); iXMLDOMElement.setAttribute("cpersoncode", puStoreIn.PersonCode); iXMLDOMElement.setAttribute("crdcode", puStoreIn.RdCode); + iXMLDOMElement.setAttribute("cwhcode", "1"); + iXMLDOMElement.setAttribute("bisstqc", "0"); + iXMLDOMElement.setAttribute("bomfirst", "0"); + + + if (puStoreIn.Source == "采购到货单") + { + var Arrival = new Purchase.ArrivalDAL().GetModel(puStoreIn.SourceCode); + + //iXMLDOMElement.setAttribute("cvencode", puStoreIn.SupplierCode); //DomHead[0]["cvencode"] = ""; //供货单位编码,string类型 + //iXMLDOMElement.setAttribute("cvenabbname", puStoreIn.SupplierName);//DomHead[0]["cvenabbname"] = ""; //供货单位,string类型 + + iXMLDOMElement.setAttribute("cbustype", Arrival.SupplierCode); + iXMLDOMElement.setAttribute("iexchrate", Arrival.ExchRate); + iXMLDOMElement.setAttribute("cexch_name", Arrival.ExchName); + iXMLDOMElement.setAttribute("cvencode", Arrival.VenCode); + + iXMLDOMElement.setAttribute("carvcode", Arrival.ArrivalCode); + iXMLDOMElement.setAttribute("ipurarriveid", Arrival.Id); + iXMLDOMElement.setAttribute("darvdate", Arrival.Date); + iXMLDOMElement.setAttribute("itaxrate", Arrival.TaxRate); + iXMLDOMElement.setAttribute("itaxrate", Arrival.TaxRate); + iXMLDOMElement.setAttribute("cptcode", Arrival.PTCode); + + domHead.selectSingleNode("//rs:data").appendChild(iXMLDOMElement); + for (var n = 0; n < puStoreIn.PuStoreInDetails.Count; n++) + { + var detail = puStoreIn.PuStoreInDetails[n]; + var arrivalDetail = Arrival.ArrivalDetails.First(m => { return m.Id == detail.SorceDetailId; }); + + (domHead.selectSingleNode("//z:row") as IXMLDOMElement).setAttribute("cordercode", arrivalDetail.OrderCode); + (domHead.selectSingleNode("//z:row") as IXMLDOMElement).setAttribute("ipurorderid", arrivalDetail.PoId); + + iXMLDOMElement = domBody.createElement("z:row"); + iXMLDOMElement.setAttribute("cinvcode", detail.Invcode); + iXMLDOMElement.setAttribute("iquantity", detail.Quantity); + iXMLDOMElement.setAttribute("irowno", n); + iXMLDOMElement.setAttribute("cbvencode", "10001"); + iXMLDOMElement.setAttribute("cbatch", detail.Batch); + iXMLDOMElement.setAttribute("carvcode", "2"); + iXMLDOMElement.setAttribute("ipurarriveid", "222"); + iXMLDOMElement.setAttribute("darvdate", DateTime.Today.ToShortDateString()); + iXMLDOMElement.setAttribute("editprop", "A"); + iXMLDOMElement.setAttribute("cpoid", arrivalDetail.OrderCode); + iXMLDOMElement.setAttribute("iposid", arrivalDetail.posId); + domBody.selectSingleNode("//rs:data").appendChild(iXMLDOMElement); + } + + + } + + var str = voucherParameter.DomBody.xml; + Console.WriteLine(str); + U8LoginContext.Instance.AddRdVoucher("U8API/PuStoreIn/Add", voucherParameter); + + } + + + public void Loadd() + { + VoucherParameter rdVoucherParameter = null; + + + try + { + if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "XMLDOM")) + { + Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "XMLDOM"); + } + + + rdVoucherParameter = new VoucherParameter(); + rdVoucherParameter.VoucherType = "01"; + rdVoucherParameter.IsGetBlank = true; + U8LoginContext.Instance.LoadRdVoucher(rdVoucherParameter); + if (!rdVoucherParameter.ReturnValue) + { + + } + else + { + + WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead01.xml"); + WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody01.xml"); + + } + //if (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead08) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody08)) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "08"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载其他入库单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // } + // else + // { + // U8ApiCommonValue.XMLDomHead08 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody08 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead08.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody08.xml"); + // Log.WriteLog("加载其他入库单XML完成"); + // } + //} + //if (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead10) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody10)) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "10"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载产成品入库单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // } + // else + // { + // U8ApiCommonValue.XMLDomHead10 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody10 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead10.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody10.xml"); + // Log.WriteLog("加载产成品入库单XML完成"); + // } + //} + //if (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead11) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody11)) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "11"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载材料出库单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // } + // else + // { + // U8ApiCommonValue.XMLDomHead11 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody11 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead11.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody11.xml"); + // Log.WriteLog("加载材料出库单XML完成"); + // } + //} + //if (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead09) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody09)) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "09"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载其他出库单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // } + // else + // { + // U8ApiCommonValue.XMLDomHead09 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody09 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead09.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody09.xml"); + // Log.WriteLog("加载其他出库单XML完成"); + // } + //} + //if (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead32) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody32)) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "32"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载销售出库单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // } + // else + // { + // U8ApiCommonValue.XMLDomHead32 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody32 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead32.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody32.xml"); + // Log.WriteLog("加载销售出库单XML完成"); + // } + //} + //if (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead12) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody12)) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "12"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载调拨单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // } + // else + // { + // U8ApiCommonValue.XMLDomHead12 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody12 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead12.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody12.xml"); + // Log.WriteLog("加载调拨单XML完成"); + // } + //} + //if (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead18) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody18)) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "18"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载盘点单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // } + // else + // { + // U8ApiCommonValue.XMLDomHead18 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody18 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead18.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody18.xml"); + // Log.WriteLog("加载盘点单XML完成"); + // } + //} + //if ((U8ApiFactoryBase.get_U8APIType() == U8APIType.API_VOUCHERCO_INTERFACE || U8ApiFactoryBase.get_U8APIType() == U8APIType.API_BUSINESS_INTERFACE) && (string.IsNullOrEmpty(U8ApiCommonValue.XMLDomHead19) || string.IsNullOrEmpty(U8ApiCommonValue.XMLDomBody19))) + //{ + // rdVoucherParameter = new RdVoucherParameter(); + // rdVoucherParameter.VoucherType = "19"; + // rdVoucherParameter.IsGetBlank = true; + // u8STApiInterface.LoadRdVoucher(rdVoucherParameter); + // if (!rdVoucherParameter.ReturnValue) + // { + // Log.WriteLog("加载货位调整单XML失败,原因:" + rdVoucherParameter.ErrMsg); + // return; + // } + // U8ApiCommonValue.XMLDomHead19 = rdVoucherParameter.DomHead.xml; + // U8ApiCommonValue.XMLDomBody19 = rdVoucherParameter.DomBody.xml; + // FileUtil.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomHead19.xml"); + // FileUtil.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + "XMLDOM\\XMLDomBody19.xml"); + // Log.WriteLog("加载货位调整单XML完成"); + //} + } + catch (Exception ex) + { + + throw ex; + } + finally + { + + } } diff --git a/NX.ERP.U8/U8LoginContext.cs b/NX.ERP.U8/U8LoginContext.cs index 001e0ea..7b7ec70 100644 --- a/NX.ERP.U8/U8LoginContext.cs +++ b/NX.ERP.U8/U8LoginContext.cs @@ -135,14 +135,14 @@ namespace NX.ERP.U8 } - public void AddRdVoucher(VoucherParameter para) + public void AddRdVoucher(string URL,VoucherParameter para) { try { U8EnvContext u8EnvContext = new U8EnvContext(); u8EnvContext.U8Login =this.ClsLogin; - U8ApiAddress apiAddress = new U8ApiAddress(""); + U8ApiAddress apiAddress = new U8ApiAddress(URL); U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext); u8ApiBroker.AssignNormalValue("sVouchType", para.VoucherType); u8ApiBroker.AssignNormalValue("DomHead", para.DomHead); @@ -151,7 +151,8 @@ namespace NX.ERP.U8 { u8ApiBroker.AssignNormalValue("domPosition", para.DomPosition); } - u8ApiBroker.AssignNormalValue("cnnFrom", para.Connection); + + u8ApiBroker.AssignNormalValue("cnnFrom", null); if (para.DOMMsg != null) { u8ApiBroker.AssignNormalValue("domMsg", para.DOMMsg); @@ -207,7 +208,7 @@ namespace NX.ERP.U8 } else if (para.VoucherType.Equals("19")) { - // para.VoucherCode = base.Util.GetAdjustVoucherCode(para.VoucherId); + // para.VoucherCode = base.Util.GetAdjustVoucherCode(para.VoucherId); //if (base.Util.dbHelper.U8ExcuteNoneQuery("Update AdjustPVouchs Set cVouchCode = '" + para.VoucherCode + "' Where id = " + para.VoucherId) == 0) //{ // para.ErrMsg = "更新货位调整单子表单号失败!"; @@ -219,15 +220,94 @@ namespace NX.ERP.U8 //para.VoucherCode = base.Util.GetSTVoucherCode(para.VoucherId, para.VoucherType); } } + else + { + throw new Exception(para.ErrMsg); + } u8ApiBroker.Release(); } catch (Exception ex3) { - // Log.WriteLog(ex3); - throw new Exception("增加供应链库存单据失败!"); + + throw ex3; } } + public void LoadRdVoucher(VoucherParameter para) + { + try + { + U8EnvContext u8EnvContext = new U8EnvContext(); + u8EnvContext.U8Login = this.ClsLogin; + U8ApiAddress apiAddress = new U8ApiAddress("U8API/PuStoreIn/Load"); + U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext); + u8ApiBroker.AssignNormalValue("sVouchType", para.VoucherType); + u8ApiBroker.AssignNormalValue("sWhere", para.StrWhere); + u8ApiBroker.AssignNormalValue("domPos", new DOMDocumentClass()); + u8ApiBroker.AssignNormalValue("bGetBlank", para.IsGetBlank); + u8ApiBroker.AssignNormalValue("sBodyWhere_Order", para.SBodyWhere_Order); + if (!u8ApiBroker.Invoke()) + { + Exception exception = u8ApiBroker.GetException(); + if (exception != null) + { + if (exception is MomSysException) + { + MomSysException ex = exception as MomSysException; + + } + else if (exception is MomBizException) + { + MomBizException ex2 = exception as MomBizException; + + } + string exceptionString = u8ApiBroker.GetExceptionString(); + if (exceptionString.Length != 0) + { + + } + } + para.ReturnValue = false; + + u8ApiBroker.Release(); + return; + } + DOMDocument dOMDocument = u8ApiBroker.GetResult("DomHead") as DOMDocument; + if (dOMDocument != null) + { + para.DomHead = new DOMDocumentClass(); + para.DomHead.loadXML(dOMDocument.xml); + } + DOMDocument dOMDocument2 = u8ApiBroker.GetResult("domBody") as DOMDocument; + if (dOMDocument2 != null) + { + para.DomBody = new DOMDocumentClass(); + para.DomBody.loadXML(dOMDocument2.xml); + } + DOMDocument dOMDocument3 = u8ApiBroker.GetResult("domPos") as DOMDocument; + if (dOMDocument3 != null) + { + para.DomPosition = new DOMDocumentClass(); + para.DomPosition.loadXML(dOMDocument3.xml); + } + para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue()); + para.ErrMsg = u8ApiBroker.GetResult("errMsg") as string; + u8ApiBroker.Release(); + } + catch (Exception ex3) + { + + throw new Exception("装载供应链库存单据失败!"); + } + } + + + + + + + + } } diff --git a/NX.ERP.U8/VoucherParameter.cs b/NX.ERP.U8/VoucherParameter.cs index 6ee17f7..aff792d 100644 --- a/NX.ERP.U8/VoucherParameter.cs +++ b/NX.ERP.U8/VoucherParameter.cs @@ -1,5 +1,4 @@ -using ADODB; -using MSXML2; +using MSXML2; using System; using System.Collections.Generic; using System.Linq; @@ -9,7 +8,7 @@ namespace NX.ERP.U8 { public class VoucherParameter { - private string voucherType; + private string string_0; private DOMDocument domHead; @@ -19,7 +18,7 @@ namespace NX.ERP.U8 private string errMsg; - private string voucherId; + private string string_2; private DOMDocument domMsg; @@ -37,7 +36,6 @@ namespace NX.ERP.U8 private string voucherCode; - private ADODB.Connection connection; private bool returnValue; @@ -114,11 +112,11 @@ namespace NX.ERP.U8 { get { - return voucherType; + return string_0; } set { - voucherType = value; + string_0 = value; } } @@ -174,11 +172,11 @@ namespace NX.ERP.U8 { get { - return voucherId; + return string_2; } set { - voucherId = value; + string_2 = value; } } @@ -266,13 +264,12 @@ namespace NX.ERP.U8 } } - public Connection Connection { get => connection; set => connection = value; } - - public VoucherParameter() + public VoucherParameter() { isCheck = true; - isBeforCheckStock = true; + isBeforCheckStock = true; + } } }