diff --git a/NX.ERP.Model/NX.ERP.Model.csproj b/NX.ERP.Model/NX.ERP.Model.csproj index 558c514..0454f2c 100644 --- a/NX.ERP.Model/NX.ERP.Model.csproj +++ b/NX.ERP.Model/NX.ERP.Model.csproj @@ -70,6 +70,8 @@ + + diff --git a/NX.ERP.Model/Sale/DispatchList.cs b/NX.ERP.Model/Sale/DispatchList.cs new file mode 100644 index 0000000..7454d12 --- /dev/null +++ b/NX.ERP.Model/Sale/DispatchList.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Sale +{ + public class DispatchList + { + public int ID { get; set; } + public string Code { get; set; } + public DateTime Date { get; set; } + + public string CoCode { get; set; } + + public string CusCode { get; set; } + + + public ICollection Details { get; set; } = new List(); + + } +} diff --git a/NX.ERP.Model/Sale/DispatchListDetail.cs b/NX.ERP.Model/Sale/DispatchListDetail.cs new file mode 100644 index 0000000..cd8268d --- /dev/null +++ b/NX.ERP.Model/Sale/DispatchListDetail.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Sale +{ + public class DispatchListDetail + { + private int id; + private string invCode; + private double quantity; + private string invName; + + public int Id { get => id; set => id = value; } + public string InvCode { get => invCode; set => invCode = value; } + public double Quantity { get => quantity; set => quantity = value; } + public string InvName { get => invName; set => invName = value; } + } +} diff --git a/NX.ERP.U8/NX.ERP.U8.csproj b/NX.ERP.U8/NX.ERP.U8.csproj index e9d0b3d..55061b3 100644 --- a/NX.ERP.U8/NX.ERP.U8.csproj +++ b/NX.ERP.U8/NX.ERP.U8.csproj @@ -44,6 +44,7 @@ + diff --git a/NX.ERP.U8/Sale/DispatchListDAL.cs b/NX.ERP.U8/Sale/DispatchListDAL.cs new file mode 100644 index 0000000..80534ca --- /dev/null +++ b/NX.ERP.U8/Sale/DispatchListDAL.cs @@ -0,0 +1,74 @@ +using Dapper; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.U8.Sale +{ + public class DispatchListDAL + { + public IEnumerable GetList(string strWhere = "", object Params = null) + { + var strSql = @"select a.DLID as id ,a.cDLCode as Code ,b.AutoID as id ,b.cInvCode as InvCode ,b.cInvName as InvName,b.iQuantity AS Quantity + from DispatchList as a + left join DispatchLists as b on a.DLID = b.DLID"; + + using (var conn = new System.Data.SqlClient.SqlConnection(U8LoginContext.Instance.Constr4Net)) + { + var lookup = new Dictionary(); + // return conn.Query(strSQL,null); + var list = conn.Query(strSql, (Dispatch, DispatchDetail) => + { + if (!lookup.TryGetValue(Dispatch.ID, out var _Dispatch)) + { + lookup.Add(Dispatch.ID, Dispatch); + } + else + { + Dispatch = _Dispatch; + } + + Dispatch.Details.Add(DispatchDetail); + return Dispatch; + }, Params, null, true, "id", 10, System.Data.CommandType.Text); + return lookup.Values; + } + } + + /// + /// + /// + /// + /// + public Model.Sale.DispatchList GetModel(int id) + { + return this.GetList(" a.cDLCode=@id", new { id }).FirstOrDefault(); + } + + + + /// + /// + /// + /// + /// + public Model.Sale.DispatchList GetModel(string Code) + { + return this.GetList(" a.DLID=@Code", new { Code }).FirstOrDefault(); + } + + /// + /// + /// + /// + /// + public IEnumerable GetListByLastID(int ID) + { + return this.GetList(" a.DLID>=@ID ", new { ID }); + } + + + } + +} diff --git a/NX.ERP.U8/Store/SaleOutDAL.cs b/NX.ERP.U8/Store/SaleOutDAL.cs index 52c1776..b24a8e8 100644 --- a/NX.ERP.U8/Store/SaleOutDAL.cs +++ b/NX.ERP.U8/Store/SaleOutDAL.cs @@ -8,12 +8,15 @@ namespace NX.ERP.U8.Store public class SaleOutDAL : VoucherBase { public SaleOutDAL() : base("32", "U8API/saleout") - { - - + { + + } - + public string AddVoucher() + { + return ""; + } diff --git a/NX.ERP.WebAPi/Controllers/Sale/DispatchController.cs b/NX.ERP.WebAPi/Controllers/Sale/DispatchController.cs new file mode 100644 index 0000000..3bca96c --- /dev/null +++ b/NX.ERP.WebAPi/Controllers/Sale/DispatchController.cs @@ -0,0 +1,42 @@ +using NX.ERP.Model.Sale; +using NX.ERP.U8.Sale; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; + +namespace NX.ERP.WebAPi.Controllers.Sale +{ + public class DispatchController : ApiController + { + // GET api/values + [HttpGet] + public IEnumerable List() + { + var customerDAL = new DispatchListDAL(); + return customerDAL.GetList(); + } + + [HttpGet] + public Model.Sale.DispatchList Model(int id) + { + var customerDAL = new DispatchListDAL(); + return customerDAL.GetModel(id); + } + + [HttpGet] + public Model.Sale.DispatchList ModelByCode(string Code) + { + var customerDAL = new DispatchListDAL(); + return customerDAL.GetModel(Code); + } + [HttpGet] + public IEnumerable GetListByLastID(int Code) + { + var customerDAL = new DispatchListDAL(); + return customerDAL.GetListByLastID(Code); + } + + } +} \ 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 f184909..cb6db1f 100644 --- a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj +++ b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj @@ -147,6 +147,7 @@ +