材料出库单

This commit is contained in:
admin
2021-01-12 14:45:59 +08:00
parent e20107b10d
commit c130f3815d
17 changed files with 609 additions and 365 deletions

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.MOM
{
public class MoAllocate
{
private int id;
private int invCode;
private int qty;
private int modid;
public int Id { get => id; set => id = value; }
public int InvCode { get => invCode; set => invCode = value; }
public int Qty { get => qty; set => qty = value; }
public int ModId { get => modid; set => modid = value; }
}
}

View File

@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.MOM
{
public class MomDetail
{
private int id;
private double qty;
private int modid;
public ICollection<MoAllocate> moAllocates { get; set; } = new List<MoAllocate>();
public int Id { get => id; set => id = value; }
public double Qty { get => qty; set => qty = value; }
public int Modid { get => modid; set => modid = value; }
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.MOM
{
public class MomOrder
{
private int id;
private string code;
/// <summary>
///
/// </summary>
public ICollection<MomDetail> momDetails { get; set; } = new List<MomDetail>();
public int Id { get => id; set => id = value; }
public string Code { get => code; set => code = value; }
public ICollection<MoAllocate> moAllocates { get; set; } = new List<MoAllocate>();
}
}

View File

@@ -57,6 +57,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MOM\MoAllocate.cs" />
<Compile Include="MOM\MomDetail.cs" />
<Compile Include="MOM\MomOrder.cs" />
<Compile Include="Purchase\Arrival.cs" />
<Compile Include="Purchase\ArrivalDetail.cs" />
<Compile Include="Base\Bin.cs" />
@@ -67,6 +70,8 @@
<Compile Include="Base\Unit.cs" />
<Compile Include="Base\Warehouse.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Store\MaterielStoreOut.cs" />
<Compile Include="Store\MaterielStoreOutDetail.cs" />
<Compile Include="Store\PuStoreIn.cs" />
<Compile Include="Store\PuStoreInDetail.cs" />
</ItemGroup>

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Store
{
public class MaterielStoreOut
{
private int id;
private string code;
private string whcode;
private string proorderid;
private DateTime date;
private string sourceCode;
private string source;
private IList<MaterielStoreOutDetail> details;
public int Id { get => id; set => id = value; }
public string Code { get => code; set => code = value; }
public string Whcode { get => whcode; set => whcode = value; }
public string Proorderid { get => proorderid; set => proorderid = value; }
public string SourceCode { get => sourceCode; set => sourceCode = value; }
public string Source { get => source; set => source = value; }
public DateTime Date { get => date; set => date = value; }
public IList<MaterielStoreOutDetail> Details { get => details; set => details = value; }
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.Model.Store
{
public class MaterielStoreOutDetail
{
private double quantity;
private string binCode;
private string cinvcode;
public int sorceDetailId { get; set; }
public double Quantity { get => quantity; set => quantity = value; }
public string BinCode { get => binCode; set => binCode = value; }
public string Cinvcode { get => cinvcode; set => cinvcode = value; }
}
}

View File

@@ -33,6 +33,7 @@ namespace U8AppMain
this.操作ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.BtnReadExcel = new System.Windows.Forms.ToolStripMenuItem();
this.登录ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = 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();
@@ -42,7 +43,7 @@ namespace U8AppMain
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.材料出库单ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip1.SuspendLayout();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -69,7 +70,8 @@ namespace U8AppMain
this.操作ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.BtnReadExcel,
this.登录ToolStripMenuItem,
this.toolStripMenuItem2});
this.toolStripMenuItem2,
this.材料出库单ToolStripMenuItem});
this.操作ToolStripMenuItem.Name = "操作ToolStripMenuItem";
this.操作ToolStripMenuItem.Size = new System.Drawing.Size(45, 19);
this.操作ToolStripMenuItem.Text = "文件";
@@ -88,6 +90,13 @@ namespace U8AppMain
this.登录ToolStripMenuItem.Text = "登录";
this.登录ToolStripMenuItem.Click += new System.EventHandler(this.登录ToolStripMenuItem_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
this.toolStripMenuItem2.Text = "采购入库单";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
//
// 导入ToolStripMenuItem
//
this.导入ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -186,12 +195,12 @@ namespace U8AppMain
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// toolStripMenuItem2
// 材料出库单ToolStripMenuItem
//
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);
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);
//
// FrmMain
//
@@ -231,6 +240,7 @@ namespace U8AppMain
private System.Windows.Forms.ToolStripMenuItem 打印ToolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem 登录ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
private System.Windows.Forms.ToolStripMenuItem 材料出库单ToolStripMenuItem;
}
}

View File

@@ -9,6 +9,7 @@ using System.Windows.Forms;
using System.Xml.Serialization;
using System.IO;
using System.Configuration;
using NX.ERP.U8;
namespace U8AppMain
{
@@ -287,7 +288,7 @@ namespace U8AppMain
private void 登录ToolStripMenuItem_Click(object sender, EventArgs e)
{
//u8LoginContext = new NX.ERP.U8.U8LoginContext();
@@ -322,5 +323,38 @@ namespace U8AppMain
}
}); ; ;
}
private void 材料出库单ToolStripMenuItem_Click(object sender, EventArgs e)
{
//var a = new STVocher();
//a.AddVocher();
var a = new NX.ERP.U8.Store.MaterielStoreOutDAL();
a.AddMaterielStoreOut(new NX.ERP.Model.Store.MaterielStoreOut()
{
Id = 1111,
Code = "2222",
Source = "生产订单",
SourceCode = "SCDD210100009",
Whcode = "2",
Date = DateTime.Now,
Details = new List<NX.ERP.Model.Store.MaterielStoreOutDetail>()
{
new NX.ERP.Model.Store.MaterielStoreOutDetail()
{
BinCode="002070206",
Cinvcode="218174",
sorceDetailId=1000200145,
Quantity=1,
}
}
});
}
}
}

45
NX.ERP.U8/FileHelp.cs Normal file
View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace NX.ERP.U8
{
public class FileHelp
{
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;
}
}
}
}

77
NX.ERP.U8/FormatHelp.cs Normal file
View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NX.ERP.U8
{
public class FormatHelp
{
public static void GetUnitPriceByTaxCost(double iQuan, double itaxcost, double itaxrate, double iExchRate, out double iprice, out double itaxprice, out double isum)
{
try
{
var info = new NX.ERP.U8.Account.Accinformation();
iprice = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iExchRate * iQuan);
itaxprice = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iExchRate * iQuan * (itaxrate / 100.0));
isum = info.FormatMoney(itaxcost * iExchRate * iQuan);
}
catch (Exception)
{
throw;
}
}
public static void GetOriPriceByTaxCost(double iQuan, double itaxcost, double itaxrate, out double iorimoney, out double ioritaxprice, out double iorisum, out double iunitcost)
{
try
{
var info = new Account.Accinformation();
iorimoney = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iQuan);
ioritaxprice = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iQuan * (itaxrate / 100.0));
iorisum = info.FormatMoney(itaxcost * iQuan);
iunitcost = info.FormatUPrice(itaxcost / (1.0 + itaxrate / 100.0));
}
catch (Exception)
{
throw;
}
}
public static void GetOriPriceByCost(double iQuan, double iunitcost, double itaxrate, out double iorimoney, out double ioritaxprice, out double iorisum, out double itaxcost)
{
try
{
var info = new Account.Accinformation();
iorimoney = info.FormatMoney(iunitcost * iQuan);
ioritaxprice = info.FormatMoney(iunitcost * iQuan * (itaxrate / 100.0));
iorisum = info.FormatMoney(iunitcost * (1.0 + itaxrate / 100.0) * iQuan);
itaxcost = info.FormatUPrice(iunitcost * (1.0 + itaxrate / 100.0));
}
catch (Exception)
{
throw;
}
}
public static void GetUnitPriceByCost(double iQuan, double iunitcost, double itaxrate, double iExchRate, out double iprice, out double itaxprice, out double isum)
{
try
{
var info = new NX.ERP.U8.Account.Accinformation();
iprice = info.FormatMoney(iunitcost * iExchRate * iQuan);
itaxprice = info.FormatMoney(iunitcost * iExchRate * iQuan * (itaxrate / 100.0));
isum = info.FormatMoney(iunitcost * iExchRate * (1.0 + itaxrate / 100.0) * iQuan);
}
catch (Exception)
{
throw;
}
}
}
}

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Dapper;
namespace NX.ERP.U8.Mom
{
public class MomOrderDetailDAL
{
public IEnumerable<Model.MOM.MomOrder> GetList(string strWhere = "", object param = null)
{
using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net))
{
string strSQL = @"select a.MoId as id,a.moCode as Code,a.*,b.MoDId as id ,b.*,c.AllocateId as id ,c.* from mom_order as a
left join mom_orderdetail as b on a.MoId=b.MoId
left join mom_moallocate as c on b.MoDId=c.MoDId
";
if (!string.IsNullOrEmpty(strWhere))
{
strSQL += $" where {strWhere} ";
}
var lookupDetail = new Dictionary<int, Model.MOM.MomDetail>();
var lookupOrder = new Dictionary<int, Model.MOM.MomOrder>();
// return conn.Query<Model.Purchase.Arrival>(strSQL,null);
var list = conn.Query<Model.MOM.MomOrder, Model.MOM.MomDetail, Model.MOM.MoAllocate, Model.MOM.MomOrder>(strSQL, (Order, OrderDetail, MoAllocate) =>
{
if (!lookupOrder.TryGetValue(Order.Id, out var _order))
{
lookupOrder.Add(Order.Id, Order);
}
else
{
Order = _order;
}
if (!lookupDetail.TryGetValue(OrderDetail.Id, out var momDetail))
{
lookupDetail.Add(OrderDetail.Id, OrderDetail);
Order.momDetails.Add(OrderDetail);
}
else
{
OrderDetail = momDetail;
}
Order.moAllocates.Add(MoAllocate);
OrderDetail.moAllocates.Add(MoAllocate);
return Order;
}, param, null, true, "id", 10, System.Data.CommandType.Text);
return lookupOrder.Values;
}
}
public Model.MOM.MomOrder GetModel(string Code)
{
return this.GetList("a.moCode=@Code", new { Code }).FirstOrDefault();
}
}
}

View File

@@ -41,8 +41,13 @@
<Compile Include="Base\CustomerDAL.cs" />
<Compile Include="Base\MaterielDAL.cs" />
<Compile Include="Base\MaterielTypeDAL.cs" />
<Compile Include="FileHelp.cs" />
<Compile Include="FormatHelp.cs" />
<Compile Include="Mom\MomOrderDetailDAL.cs" />
<Compile Include="Purchase\ArrivalDAL.cs" />
<Compile Include="Store\MaterielStoreOutDAL.cs" />
<Compile Include="Store\PuStoreInDAL.cs" />
<Compile Include="Store\VoucherBase.cs" />
<Compile Include="STVocher.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Base\SupplierDAL.cs" />

View File

@@ -0,0 +1,134 @@
using MSXML2;
using NX.ERP.Model.Store;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UFIDA.U8.U8APIFramework;
using UFIDA.U8.U8APIFramework.Parameter;
using UFIDA.U8.U8MOMAPIFramework;
namespace NX.ERP.U8.Store
{
public class MaterielStoreOutDAL : VoucherBase
{
public MaterielStoreOutDAL() : base("11")
{
}
public void AddMaterielStoreOut(MaterielStoreOut storeOut)
{
VoucherParameter voucherParameter = new VoucherParameter
{
VoucherType = this.VoucherID,
DomHead = new DOMDocumentClass(),
DomBody = new DOMDocumentClass()
};
DOMDocument domHead = voucherParameter.DomHead;
DOMDocument domBody = voucherParameter.DomBody;
voucherParameter.DomHead.loadXML(HeadTemplate);
voucherParameter.DomBody.loadXML(BodyTemplate);
IXMLDOMElement headXml = domHead.createElement("z:row");
//headXml.setAttribute("id", storeOut.Id);
headXml.setAttribute("ccode", storeOut.Code); //DomHead[0]["ccode"] = ""; //入库单号,string类型
headXml.setAttribute("ddate", storeOut.Date.ToShortDateString()); //DomHead[0]["ddate"] = ""; //入库日期,DateTime类型
headXml.setAttribute("bpufirst", "0");
headXml.setAttribute("bisstqc", "0");
headXml.setAttribute("bomfirst", "0");
headXml.setAttribute("biafirst", "0");
headXml.setAttribute("brdflag", 0);
headXml.setAttribute("cmaker", "");
headXml.setAttribute("cvouchtype", this.VoucherID);
headXml.setAttribute("vt_id", "65");
headXml.setAttribute("editprop", "A");
headXml.setAttribute("cdepcode", "1");
headXml.setAttribute("crdcode", "201");
headXml.setAttribute("cpersoncode", "it");
headXml.setAttribute("cwhcode", storeOut.Whcode);
headXml.setAttribute("csource", storeOut.Source);
if (storeOut.Source == "生产订单")
{
headXml.setAttribute("cbustype", "领料");
var Order = new Mom.MomOrderDetailDAL().GetModel(storeOut.SourceCode);
headXml.setAttribute("iproorderid", Order.Id);
headXml.setAttribute("cmpocode", Order.Code);
headXml.setAttribute("cpspcode", "904008");
headXml.setAttribute("crdname", "材料出库");
headXml.setAttribute("cdepcode", "24");
headXml.setAttribute("cdepname", "研发LA组");
IXMLDOMElement bodyXml;
for (var n = 0; n < storeOut.Details.Count(); n++)
{
var detail = storeOut.Details[n];
var alllocate = Order.moAllocates.First(m => { return m.Id == detail.sorceDetailId; });
var moomDetail = Order.momDetails.First(m => { return m.Id == alllocate.ModId; });
bodyXml = domBody.createElement("z:row");
bodyXml.setAttribute("autoid", n);
bodyXml.setAttribute("cinvcode", detail.Cinvcode);
bodyXml.setAttribute("iquantity", detail.Quantity);
bodyXml.setAttribute("irowno", n+1);
bodyXml.setAttribute("cbatch", "");
bodyXml.setAttribute("cvmivencode", "");
bodyXml.setAttribute("cposition", detail.BinCode);
bodyXml.setAttribute("editprop", "A");
bodyXml.setAttribute("innum", 10);
bodyXml.setAttribute("autoid", storeOut.Id);
bodyXml.setAttribute("id", storeOut.Id);
bodyXml.setAttribute("impoids", detail.sorceDetailId);
bodyXml.setAttribute("cmocode", Order.Code);
bodyXml.setAttribute("invcode", "904008");
bodyXml.setAttribute("cwhcode", storeOut.Whcode);
bodyXml.setAttribute("imoseq", 1);
bodyXml.setAttribute("ipesotype", "7");
bodyXml.setAttribute("cpesocode", "");
bodyXml.setAttribute("ipesodid", "");
bodyXml.setAttribute("ipesoseq", "");
bodyXml.setAttribute("isotype", "");
bodyXml.setAttribute("csocode", "");
bodyXml.setAttribute("isodid", "");
bodyXml.setAttribute("isoseq", "");
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
}
}
domHead.selectSingleNode("//rs:data").appendChild(headXml);
try
{
U8LoginContext.Instance.AddRdVoucher("U8API/MaterialOut/Add", voucherParameter);
}
catch (Exception err)
{
throw err;
}
}
}
}

View File

@@ -10,110 +10,11 @@ using UFIDA.U8.U8MOMAPIFramework;
namespace NX.ERP.U8.Store
{
public class PuStoreInDAL
public class PuStoreInDAL : VoucherBase
{
public static string ReadFile(string strFileName)
public PuStoreInDAL() : base("01")
{
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;
}
}
public virtual void GetUnitPriceByTaxCost(double iQuan, double itaxcost, double itaxrate, double iExchRate, out double iprice, out double itaxprice, out double isum)
{
try
{
var info = new NX.ERP.U8.Account.Accinformation();
iprice = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iExchRate * iQuan);
itaxprice = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iExchRate * iQuan * (itaxrate / 100.0));
isum = info.FormatMoney(itaxcost * iExchRate * iQuan);
}
catch (Exception)
{
throw;
}
}
public virtual void GetOriPriceByTaxCost(double iQuan, double itaxcost, double itaxrate, out double iorimoney, out double ioritaxprice, out double iorisum, out double iunitcost)
{
try
{
var info = new Account.Accinformation();
iorimoney = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iQuan);
ioritaxprice = info.FormatMoney(itaxcost / (1.0 + itaxrate / 100.0) * iQuan * (itaxrate / 100.0));
iorisum = info.FormatMoney(itaxcost * iQuan);
iunitcost = info.FormatUPrice(itaxcost / (1.0 + itaxrate / 100.0));
}
catch (Exception)
{
throw;
}
}
public virtual void GetOriPriceByCost(double iQuan, double iunitcost, double itaxrate, out double iorimoney, out double ioritaxprice, out double iorisum, out double itaxcost)
{
try
{
var info = new Account.Accinformation();
iorimoney = info.FormatMoney(iunitcost * iQuan);
ioritaxprice = info.FormatMoney(iunitcost * iQuan * (itaxrate / 100.0));
iorisum = info.FormatMoney(iunitcost * (1.0 + itaxrate / 100.0) * iQuan);
itaxcost = info.FormatUPrice(iunitcost * (1.0 + itaxrate / 100.0));
}
catch (Exception)
{
throw;
}
}
public virtual void GetUnitPriceByCost(double iQuan, double iunitcost, double itaxrate, double iExchRate, out double iprice, out double itaxprice, out double isum)
{
try
{
var info = new NX.ERP.U8.Account.Accinformation();
iprice = info.FormatMoney(iunitcost * iExchRate * iQuan);
itaxprice = info.FormatMoney(iunitcost * iExchRate * iQuan * (itaxrate / 100.0));
isum = info.FormatMoney(iunitcost * iExchRate * (1.0 + itaxrate / 100.0) * iQuan);
}
catch (Exception)
{
throw;
}
}
/// <summary>
/// 保存一个采购到货单
/// </summary>
@@ -121,17 +22,18 @@ namespace NX.ERP.U8.Store
public void AddPuStoreIn(Model.Store.PuStoreIn puStoreIn)
{
VoucherParameter voucherParameter = new VoucherParameter();
voucherParameter.VoucherType = "01";
voucherParameter.DomHead = new DOMDocumentClass();
voucherParameter.DomBody = new DOMDocumentClass();
VoucherParameter voucherParameter = new VoucherParameter
{
VoucherType = this.VoucherID,
DomHead = new DOMDocumentClass(),
DomBody = new DOMDocumentClass()
};
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"));
voucherParameter.DomHead.loadXML(HeadTemplate);
voucherParameter.DomBody.loadXML(BodyTemplate);
IXMLDOMElement headXml = domHead.createElement("z:row");
headXml.setAttribute("cvouchtype", "01");//DomHead[0]["cvouchtype"] = ""; //单据类型,string类型
headXml.setAttribute("cvouchtype", this.VoucherID);//DomHead[0]["cvouchtype"] = ""; //单据类型,string类型
headXml.setAttribute("id", puStoreIn.Id); //DomHead[0]["id"] = ""; //主关键字段,int类型
headXml.setAttribute("bomfirst", "0"); //DomHead[0]["bomfirst"] = ""; //委外期初标志,string类型
headXml.setAttribute("ccode", puStoreIn.Code); //DomHead[0]["ccode"] = ""; //入库单号,string类型
@@ -152,10 +54,6 @@ namespace NX.ERP.U8.Store
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类型
headXml.setAttribute("cbustype", Arrival.BusType);
headXml.setAttribute("iexchrate", Arrival.ExchRate);
headXml.setAttribute("cexch_name", Arrival.ExchName);
@@ -164,10 +62,8 @@ namespace NX.ERP.U8.Store
headXml.setAttribute("ipurarriveid", Arrival.Id);
headXml.setAttribute("darvdate", Arrival.Date);
headXml.setAttribute("itaxrate", Arrival.TaxRate);
headXml.setAttribute("cptcode", Arrival.PTCode);
domHead.selectSingleNode("//rs:data").appendChild(headXml);
IXMLDOMElement bodyXml;
for (var n = 0; n < puStoreIn.PuStoreInDetails.Count; n++)
{
@@ -193,68 +89,23 @@ namespace NX.ERP.U8.Store
bodyXml.setAttribute("iposid", arrivalDetail.posId);
bodyXml.setAttribute("itaxrate", Arrival.TaxRate);
var info = new Account.Accinformation();
double iprice2;
double itaxprice2;
double isum2;
GetUnitPriceByCost(detail.Quantity, arrivalDetail.oricost, Arrival.TaxRate, Arrival.ExchRate, out iprice2, out itaxprice2, out isum2);
FormatHelp.GetUnitPriceByCost(detail.Quantity, arrivalDetail.oricost, Arrival.TaxRate, Arrival.ExchRate, out double iprice2, out double itaxprice2, out double isum2);
bodyXml.setAttribute("iunitcost", arrivalDetail.cost);
bodyXml.setAttribute("iprice", iprice2);
bodyXml.setAttribute("facost", arrivalDetail.cost);
bodyXml.setAttribute("iaprice", iprice2);
bodyXml.setAttribute("itaxprice", itaxprice2);
bodyXml.setAttribute("isum", isum2);
//double price;
//double taxprice;
//double sum;
//GetUnitPriceByCost(detail.Quantity, arrivalDetail.cost, Arrival.TaxRate, Arrival.ExchRate, out price, out taxprice, out sum);
//bodyXml.setAttribute("iunitcost", arrivalDetail.cost); //本币单价,double类型
//bodyXml.setAttribute("iprice", price); //本币金额,double类型
//bodyXml.setAttribute("facost", arrivalDetail.cost); //暂估单价,double类型
//bodyXml.setAttribute("itaxprice", taxprice);//本币税额,double类型
//bodyXml.setAttribute("isum", sum);//本币价税合计,double类型
double iorimoney2;
double ioritaxprice2;
double iorisum2;
double iunitcost2;
GetOriPriceByCost(detail.Quantity, arrivalDetail.oricost, Arrival.TaxRate, out iorimoney2, out ioritaxprice2, out iorisum2, out iunitcost2);
FormatHelp.GetOriPriceByCost(detail.Quantity, arrivalDetail.oricost, Arrival.TaxRate, out double iorimoney2, out double ioritaxprice2, out double iorisum2, out double iunitcost2);
bodyXml.setAttribute("ioricost", arrivalDetail.oricost);
bodyXml.setAttribute("ioritaxcost", arrivalDetail.oritaxcost);
bodyXml.setAttribute("iorimoney", iorimoney2);
bodyXml.setAttribute("ioritaxprice", ioritaxprice2);
bodyXml.setAttribute("iorisum", iorisum2);
//var iorisum = info.FormatMoney(arrivalDetail.oricost * (1.00 + (Arrival.TaxRate / 100.0)) * detail.Quantity);
//var ioritaxprice = info.FormatMoney(arrivalDetail.oricost * (Arrival.TaxRate / 100.0) * detail.Quantity);
//var iorimoney = info.FormatMoney(arrivalDetail.oricost * detail.Quantity);
//var oritaxcost = info.FormatMoney(arrivalDetail.oricost * (1.00 + (Arrival.TaxRate / 100.0)));
//double money;
//double taxcost;
//GetOriPriceByCost(detail.Quantity, arrivalDetail.oricost, Arrival.TaxRate, out money, out taxprice, out sum, out taxcost);
//bodyXml.setAttribute("ioricost", arrivalDetail.oricost);
//bodyXml.setAttribute("ioritaxcost", arrivalDetail.oritaxcost);
//bodyXml.setAttribute("iorimoney", money);
//bodyXml.setAttribute("ioritaxprice", taxprice);
//bodyXml.setAttribute("iorisum", sum);
domBody.selectSingleNode("//rs:data").appendChild(bodyXml);
}
}
domHead.selectSingleNode("//rs:data").appendChild(headXml);
var str = voucherParameter.DomBody.xml;
Console.WriteLine(str);
try
@@ -271,196 +122,6 @@ namespace NX.ERP.U8.Store
}
public void LoadTemplate()
{
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
{
}
}
}
}

View File

@@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace NX.ERP.U8.Store
{
public abstract class VoucherBase
{
private string voucherID;
protected string VoucherID
{
get
{
return this.voucherID;
}
}
public VoucherBase(string voucherID)
{
this.voucherID = voucherID;
}
protected string HeadTemplate
{
get
{
return this.GetHeadTemplate();
}
}
protected string BodyTemplate
{
get
{
return this.GetBodyTemplate();
}
}
private string GetHeadTemplate()
{
var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomHead{this.voucherID}.xml");
if (strTemlate == string.Empty)
{
this.LoadTemplate();
strTemlate = GetHeadTemplate();
}
return strTemlate;
}
private string GetBodyTemplate()
{
var strTemlate = FileHelp.ReadFile(AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomBody{this.voucherID}.xml");
if (strTemlate == string.Empty)
{
this.LoadTemplate();
strTemlate = GetBodyTemplate();
}
return strTemlate;
}
public void LoadTemplate()
{
VoucherParameter rdVoucherParameter = null;
try
{
if (!Directory.Exists(AppDomain.CurrentDomain.BaseDirectory + "XMLDOM"))
{
Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + "XMLDOM");
}
rdVoucherParameter = new VoucherParameter();
rdVoucherParameter.VoucherType =this.VoucherID;
rdVoucherParameter.IsGetBlank = true;
U8LoginContext.Instance.LoadRdVoucher(rdVoucherParameter);
if (rdVoucherParameter.ReturnValue)
{
FileHelp.WriteFile(rdVoucherParameter.DomHead.xml, AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomHead{this.voucherID}.xml");
FileHelp.WriteFile(rdVoucherParameter.DomBody.xml, AppDomain.CurrentDomain.BaseDirectory + $"XMLDOM\\XMLDomBody{this.voucherID}.xml");
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
}
}

View File

@@ -234,6 +234,7 @@ namespace NX.ERP.U8
}
para.ReturnValue = Convert.ToBoolean(u8ApiBroker.GetReturnValue());
para.DOMMsg = u8ApiBroker.GetResult("domMsg") as DOMDocument;
para.ErrMsg = u8ApiBroker.GetResult("errMsg") as string;
if (para.ReturnValue)
{

View File

@@ -267,8 +267,8 @@ namespace NX.ERP.U8
public VoucherParameter()
{
isCheck = true;
isBeforCheckStock = true;
isCheck = false;
isBeforCheckStock = false;
}
}