diff --git a/NX.ERP.Model/NX.ERP.Model.csproj b/NX.ERP.Model/NX.ERP.Model.csproj index eb5b5f2..12d3302 100644 --- a/NX.ERP.Model/NX.ERP.Model.csproj +++ b/NX.ERP.Model/NX.ERP.Model.csproj @@ -66,6 +66,7 @@ + diff --git a/NX.ERP.Model/Request/ApVouch.cs b/NX.ERP.Model/Request/ApVouch.cs new file mode 100644 index 0000000..abdd589 --- /dev/null +++ b/NX.ERP.Model/Request/ApVouch.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Request +{ + public class ApVouch + { + public string DeptCode { get; set; } + public string DeptName { get; set; } + public string supplierCode { get; set; } + + public string Amount { get; set; } + + public string Digest { get; set; } + + public DateTime Date { get; set; } + + } +} diff --git a/NX.ERP.U8/AP/APVouch.cs b/NX.ERP.U8/AP/APVouch.cs index 1dcc450..9ea9305 100644 --- a/NX.ERP.U8/AP/APVouch.cs +++ b/NX.ERP.U8/AP/APVouch.cs @@ -14,7 +14,7 @@ namespace NX.ERP.U8.AP public APVouch() : base("应付单", "U8API/APVouch") { - + } protected override string AddUrl @@ -56,10 +56,10 @@ namespace NX.ERP.U8.AP u8EnvContext.U8Login = U8LoginContext.Instance.ClsLogin; U8ApiAddress apiAddress = new U8ApiAddress(this.LoadUrl); U8ApiBroker u8ApiBroker = new U8ApiBroker(apiAddress, u8EnvContext); - u8EnvContext.SetApiContext("VouchType",this.VoucherID); + u8EnvContext.SetApiContext("VouchType", this.VoucherID); + + u8ApiBroker.AssignNormalValue("linkid", ""); - u8ApiBroker.AssignNormalValue("linkid", "0"); - if (!u8ApiBroker.Invoke()) { Exception exception = u8ApiBroker.GetException(); @@ -95,7 +95,7 @@ namespace NX.ERP.U8.AP para.DomBody = new DOMDocumentClass(); para.DomBody.loadXML(dOMDocument2.xml); } - + para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue()); para.ErrMsg = u8ApiBroker.GetResult("xmlmsg") as string; u8ApiBroker.Release(); @@ -122,7 +122,7 @@ namespace NX.ERP.U8.AP u8ApiBroker.AssignNormalValue("ohead", para.DomHead); u8ApiBroker.AssignNormalValue("obody", para.DomBody); //给普通参数isadd赋值。此参数的数据类型为System.Boolean,此参数按值传递,表示true新增,false修改 - u8ApiBroker.AssignNormalValue("isadd",true); + u8ApiBroker.AssignNormalValue("isadd", true); if (para.DOMMsg != null) @@ -133,7 +133,7 @@ namespace NX.ERP.U8.AP { u8ApiBroker.AssignNormalValue("xmlmsg", new DOMDocumentClass()); } - + // u8ApiBroker.AssignNormalValue("bReMote", para.IsReMote); if (!u8ApiBroker.Invoke()) @@ -163,11 +163,20 @@ namespace NX.ERP.U8.AP } para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue()); - + para.ErrMsg = u8ApiBroker.GetResult("xmlmsg") as string; - + + + u8ApiBroker.Release(); + + if (!para.ReturnValue) + { + throw new Exception(para.ErrMsg); + } + + return ""; } catch (Exception err) @@ -183,7 +192,7 @@ namespace NX.ERP.U8.AP - public string AddVocher() + public string AddVocher(NX.ERP.Model.Request.ApVouch ApVouch) { VoucherParameter voucherParameter = new VoucherParameter @@ -197,15 +206,43 @@ namespace NX.ERP.U8.AP voucherParameter.DomHead.loadXML(HeadTemplate); voucherParameter.DomBody.loadXML(BodyTemplate); IXMLDOMElement headXml = domHead.createElement("z:row"); - - - + // headXml.setAttribute("cVenAbbName", "无锡市鑫奥"); + headXml.setAttribute("cDwCode", ApVouch.supplierCode); + headXml.setAttribute("dVouchDate",ApVouch.Date); + headXml.setAttribute("iExchRate", 1); + headXml.setAttribute("iAmount_f",ApVouch.Amount); + headXml.setAttribute("iRAmount", ApVouch.Amount); + headXml.setAttribute("cVouchType", "P0"); + headXml.setAttribute("cTypeName", "其他应付单"); + headXml.setAttribute("cCode", "220201"); + headXml.setAttribute("cexch_name", "人民币"); + headXml.setAttribute("VT_ID", 8056); + headXml.setAttribute("bd_c", false); + headXml.setAttribute("bStartFlag", false); + headXml.setAttribute("cVouchID", ""); + headXml.setAttribute("cFlag", "AP"); + headXml.setAttribute("cDeptCode", ApVouch.DeptCode); + headXml.setAttribute("cDigest", ApVouch.Digest); + headXml.setAttribute("cLink", ""); IXMLDOMElement bodyXml; + //for (var n = 0; n < storeIn.details.Count(); n++) //{ - //var detail = storeIn.details[n]; - bodyXml = domBody.createElement("z:row"); - + //var detail = storeIn.details[n]; + bodyXml = domBody.createElement("z:row"); + + bodyXml.setAttribute("cDeptCode", ApVouch.DeptCode); + bodyXml.setAttribute("cCode", ""); + bodyXml.setAttribute("iExchRate", 1); + bodyXml.setAttribute("cexch_name", "人民币"); + bodyXml.setAttribute("iAmount", ApVouch.Amount); + bodyXml.setAttribute("iAmount_f", ApVouch.Amount); + bodyXml.setAttribute("iAmt_s", 0); + bodyXml.setAttribute("cLink", ""); + headXml.setAttribute("cDwCode", ApVouch.supplierCode); + bodyXml.setAttribute("bd_c", true); + + domBody.selectSingleNode("//rs:data").appendChild(bodyXml); //} domHead.selectSingleNode("//rs:data").appendChild(headXml); var str = voucherParameter.DomBody.xml; @@ -216,7 +253,6 @@ namespace NX.ERP.U8.AP } catch (Exception err) { - throw err; } diff --git a/NX.ERP.WebAPi/Controllers/AP/APController.cs b/NX.ERP.WebAPi/Controllers/AP/APController.cs new file mode 100644 index 0000000..29658fa --- /dev/null +++ b/NX.ERP.WebAPi/Controllers/AP/APController.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; + +namespace NX.ERP.WebAPi.Controllers.AP +{ + public class APController : ApiController + { + + [Route("api/ap/add")] + [HttpPost] + public string AddVoucher(NX.ERP.Model.Request.ApVouch ApVouch) + { + var dal = new NX.ERP.U8.AP.APVouch(); + return dal.AddVocher(ApVouch); + } + + + } +} \ No newline at end of file diff --git a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj index 7c07d04..f41b012 100644 --- a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj +++ b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj @@ -52,6 +52,11 @@ AnyCPU + + False + True + ..\NX.ERP.U8\lib\ADODB.dll + ..\packages\Microsoft.Owin.4.1.1\lib\net45\Microsoft.Owin.dll @@ -152,6 +157,7 @@ + diff --git a/NX.ERP.WebAPi/Web.config b/NX.ERP.WebAPi/Web.config index 7415818..9238136 100644 --- a/NX.ERP.WebAPi/Web.config +++ b/NX.ERP.WebAPi/Web.config @@ -7,7 +7,7 @@ - + diff --git a/NX.ERP.Webapp/src/api/pmc.js b/NX.ERP.Webapp/src/api/pmc.js index 5222805..39da1da 100644 --- a/NX.ERP.Webapp/src/api/pmc.js +++ b/NX.ERP.Webapp/src/api/pmc.js @@ -17,3 +17,4 @@ export const getInventorybu=(info)=>{ export const getInventorypo=(info)=>{ return axios.post('/api/Pmc/InventoryPocode',info) } +