From 3ab387f51ac15f88d430b4a97212e19a590e749b Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 5 Jan 2021 16:49:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E5=87=BA=E5=88=B0?= =?UTF-8?q?=E8=B4=A7=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NX.ERP.Model/{Model => Base}/Bin.cs | 0 NX.ERP.Model/{Model => Base}/Customer.cs | 0 NX.ERP.Model/{Model => Base}/Materiel.cs | 0 NX.ERP.Model/{Model => Base}/MaterielType.cs | 0 NX.ERP.Model/{Model => Base}/Supplier.cs | 0 NX.ERP.Model/{Model => Base}/Unit.cs | 0 NX.ERP.Model/{Model => Base}/Warehouse.cs | 0 NX.ERP.Model/Model/Arrival.cs | 25 ---- NX.ERP.Model/Model/ArrivalDetail.cs | 12 -- NX.ERP.Model/NX.ERP.Model.csproj | 20 +-- NX.ERP.Model/Purchase/Arrival.cs | 25 ++++ NX.ERP.Model/Purchase/ArrivalDetail.cs | 31 ++++ NX.ERP.Model/Store/PuStoreIn.cs | 20 +++ NX.ERP.Model/Store/PuStoreInDetail.cs | 16 ++ NX.ERP.U8/AdoHelper.cs | 138 ++++++++++++++++++ NX.ERP.U8/NX.ERP.U8.csproj | 2 + NX.ERP.U8/Purchase/ArrivalDAL.cs | 42 ++++++ NX.ERP.U8/U8LoginContext.cs | 59 ++++---- .../Controllers/ArrivalController.cs | 22 +++ NX.ERP.WebAPi/NX.ERP.WebAPi.csproj | 1 + 20 files changed, 339 insertions(+), 74 deletions(-) rename NX.ERP.Model/{Model => Base}/Bin.cs (100%) rename NX.ERP.Model/{Model => Base}/Customer.cs (100%) rename NX.ERP.Model/{Model => Base}/Materiel.cs (100%) rename NX.ERP.Model/{Model => Base}/MaterielType.cs (100%) rename NX.ERP.Model/{Model => Base}/Supplier.cs (100%) rename NX.ERP.Model/{Model => Base}/Unit.cs (100%) rename NX.ERP.Model/{Model => Base}/Warehouse.cs (100%) delete mode 100644 NX.ERP.Model/Model/Arrival.cs delete mode 100644 NX.ERP.Model/Model/ArrivalDetail.cs create mode 100644 NX.ERP.Model/Purchase/Arrival.cs create mode 100644 NX.ERP.Model/Purchase/ArrivalDetail.cs create mode 100644 NX.ERP.Model/Store/PuStoreIn.cs create mode 100644 NX.ERP.Model/Store/PuStoreInDetail.cs create mode 100644 NX.ERP.U8/AdoHelper.cs create mode 100644 NX.ERP.U8/Purchase/ArrivalDAL.cs create mode 100644 NX.ERP.WebAPi/Controllers/ArrivalController.cs diff --git a/NX.ERP.Model/Model/Bin.cs b/NX.ERP.Model/Base/Bin.cs similarity index 100% rename from NX.ERP.Model/Model/Bin.cs rename to NX.ERP.Model/Base/Bin.cs diff --git a/NX.ERP.Model/Model/Customer.cs b/NX.ERP.Model/Base/Customer.cs similarity index 100% rename from NX.ERP.Model/Model/Customer.cs rename to NX.ERP.Model/Base/Customer.cs diff --git a/NX.ERP.Model/Model/Materiel.cs b/NX.ERP.Model/Base/Materiel.cs similarity index 100% rename from NX.ERP.Model/Model/Materiel.cs rename to NX.ERP.Model/Base/Materiel.cs diff --git a/NX.ERP.Model/Model/MaterielType.cs b/NX.ERP.Model/Base/MaterielType.cs similarity index 100% rename from NX.ERP.Model/Model/MaterielType.cs rename to NX.ERP.Model/Base/MaterielType.cs diff --git a/NX.ERP.Model/Model/Supplier.cs b/NX.ERP.Model/Base/Supplier.cs similarity index 100% rename from NX.ERP.Model/Model/Supplier.cs rename to NX.ERP.Model/Base/Supplier.cs diff --git a/NX.ERP.Model/Model/Unit.cs b/NX.ERP.Model/Base/Unit.cs similarity index 100% rename from NX.ERP.Model/Model/Unit.cs rename to NX.ERP.Model/Base/Unit.cs diff --git a/NX.ERP.Model/Model/Warehouse.cs b/NX.ERP.Model/Base/Warehouse.cs similarity index 100% rename from NX.ERP.Model/Model/Warehouse.cs rename to NX.ERP.Model/Base/Warehouse.cs diff --git a/NX.ERP.Model/Model/Arrival.cs b/NX.ERP.Model/Model/Arrival.cs deleted file mode 100644 index cae924a..0000000 --- a/NX.ERP.Model/Model/Arrival.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NX.ERP.Model -{ - /// - /// 到货单 - /// - public class Arrival - { - private int id; - private string arrivalCode; - private DateTime _date; - - - - - - - - - } -} diff --git a/NX.ERP.Model/Model/ArrivalDetail.cs b/NX.ERP.Model/Model/ArrivalDetail.cs deleted file mode 100644 index 520df88..0000000 --- a/NX.ERP.Model/Model/ArrivalDetail.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NX.ERP.Model.Model -{ - public class ArrivalDetail - { - public int Autoid; - } -} diff --git a/NX.ERP.Model/NX.ERP.Model.csproj b/NX.ERP.Model/NX.ERP.Model.csproj index 7c9a4bb..af1fd74 100644 --- a/NX.ERP.Model/NX.ERP.Model.csproj +++ b/NX.ERP.Model/NX.ERP.Model.csproj @@ -57,16 +57,18 @@ - - - - - - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/NX.ERP.Model/Purchase/Arrival.cs b/NX.ERP.Model/Purchase/Arrival.cs new file mode 100644 index 0000000..240cc6b --- /dev/null +++ b/NX.ERP.Model/Purchase/Arrival.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Purchase +{ + /// + /// 到货单 + /// + public class Arrival + { + private int id; + private string arrivalCode; + private DateTime _date; + private string supplierCode; + + private ICollection arrivalDetails = new List(); + public int Id { get => id; set => id = value; } + public string ArrivalCode { get => arrivalCode; set => arrivalCode = value; } + public DateTime Date { get => _date; set => _date = value; } + public ICollection ArrivalDetails { get => arrivalDetails; set => arrivalDetails = value; } + public string SupplierCode { get => supplierCode; set => supplierCode = value; } + } +} diff --git a/NX.ERP.Model/Purchase/ArrivalDetail.cs b/NX.ERP.Model/Purchase/ArrivalDetail.cs new file mode 100644 index 0000000..3065e47 --- /dev/null +++ b/NX.ERP.Model/Purchase/ArrivalDetail.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Purchase +{ + /// + /// 到货明细 + /// + public class ArrivalDetail + { + private int id; + private string materielCode; + public int Id { get => id; set => id = value; } + public int ArrivalID { get => arrivalID; set => arrivalID = value; } + public string MaterielCode { get => materielCode; set => materielCode = value; } + public string BatchNo { get => batchNo; set => batchNo = value; } + public string UnitCode { get => unitCode; set => unitCode = value; } + public decimal Quantity { get => quantity; set => quantity = value; } + /// + /// 审批状态2 说明已经审核过了 + /// + public int Iverifystateex { get => iverifystateex; set => iverifystateex = value; } + private int arrivalID; + private string batchNo; + private string unitCode; + private decimal quantity; + private int iverifystateex; + } +} diff --git a/NX.ERP.Model/Store/PuStoreIn.cs b/NX.ERP.Model/Store/PuStoreIn.cs new file mode 100644 index 0000000..81fd4b9 --- /dev/null +++ b/NX.ERP.Model/Store/PuStoreIn.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +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(); + + public ICollection PuStoreInDetails { get => puStoreInDetails; set => puStoreInDetails = value; } + } +} diff --git a/NX.ERP.Model/Store/PuStoreInDetail.cs b/NX.ERP.Model/Store/PuStoreInDetail.cs new file mode 100644 index 0000000..4e7eda9 --- /dev/null +++ b/NX.ERP.Model/Store/PuStoreInDetail.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.Model.Store +{ + public class PuStoreInDetail + { + private int id; + private int puStoreInId; + private string invcode; + private string unit; + private string quantity; + } +} diff --git a/NX.ERP.U8/AdoHelper.cs b/NX.ERP.U8/AdoHelper.cs new file mode 100644 index 0000000..ffc2824 --- /dev/null +++ b/NX.ERP.U8/AdoHelper.cs @@ -0,0 +1,138 @@ +using ADODB; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NX.ERP.U8 +{ + public class AdoHelper : IDisposable + { + private ADODB.Connection connection; + + public Connection Connection { get => connection; set => connection = value; } + + public void BeginTrans() + { + try + { + if (Connection != null) + { + Connection.BeginTrans(); + } + } + catch (Exception) + { + throw; + } + } + + public AdoHelper(string constr) + { + + if (!string.IsNullOrEmpty(constr)) + { + connection = new ConnectionClass(); + connection.ConnectionString = constr; + try + { + connection.Open(); + + } + catch (Exception err) + { + throw new Exception(err.Message); + } + } + else + { + throw new Exception("链接字符串为空"); + } + } + + + + + + + public Recordset U8ExcuteRecord(string strSQL) + { + try + { + return connection.Execute(strSQL, out object RecordsAffected); + } + catch (Exception) + { + throw; + } + } + + + public int ExcuteNoneQuery(string strSQL) + { + try + { + Connection.Execute(strSQL, out var RecordsAffected); + return (int)RecordsAffected; + } + catch (Exception) + { + throw; + } + } + + + + + public void RollbackTrans() + { + try + { + if (Connection != null) + { + Connection.RollbackTrans(); + } + } + catch (Exception) + { + throw; + } + } + + public void CommitTrans() + { + try + { + if (Connection != null) + { + Connection.CommitTrans(); + } + } + catch (Exception) + { + throw; + } + } + + + + public void Dispose() + { + try + { + if (Connection != null) + { + if (Connection.State == 1) + { + Connection.Close(); + } + Connection = null; + } + } + catch (Exception) + { + throw; + } + } + } +} diff --git a/NX.ERP.U8/NX.ERP.U8.csproj b/NX.ERP.U8/NX.ERP.U8.csproj index 8a6cdfa..a336244 100644 --- a/NX.ERP.U8/NX.ERP.U8.csproj +++ b/NX.ERP.U8/NX.ERP.U8.csproj @@ -36,10 +36,12 @@ true + + diff --git a/NX.ERP.U8/Purchase/ArrivalDAL.cs b/NX.ERP.U8/Purchase/ArrivalDAL.cs new file mode 100644 index 0000000..4d361ab --- /dev/null +++ b/NX.ERP.U8/Purchase/ArrivalDAL.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Dapper; +namespace NX.ERP.U8.Purchase +{ + public class ArrivalDAL + { + public IEnumerable GetList() + { + 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"; + var lookup = new Dictionary(); + // return conn.Query(strSQL,null); + var list = conn.Query(strSQL, (arrival, ArrivalDetail) => + { + if (!lookup.TryGetValue(arrival.Id, out var _arrival)) + { + lookup.Add(arrival.Id, arrival); + } else + { + arrival = _arrival; + } + + arrival.ArrivalDetails.Add(ArrivalDetail); + return arrival; + }, null, null, true, "id", 10, System.Data.CommandType.Text); + return lookup.Values; + } + } + } +} diff --git a/NX.ERP.U8/U8LoginContext.cs b/NX.ERP.U8/U8LoginContext.cs index 0b2f0ba..0cff17c 100644 --- a/NX.ERP.U8/U8LoginContext.cs +++ b/NX.ERP.U8/U8LoginContext.cs @@ -8,15 +8,11 @@ namespace NX.ERP.U8 { public class U8LoginContext : IDisposable { - - private static U8LoginContext _u8LoginContext; - public static U8LoginContext Instance { get { - if (_u8LoginContext == null) { _u8LoginContext = new U8LoginContext(); @@ -24,17 +20,21 @@ namespace NX.ERP.U8 return _u8LoginContext; } } - - private UFSoft.U8.Framework.Login.UI.clsLogin uiLogin; - private clsLogin _clslogin; + + public string cAcc_id + { + get + { + return this._clslogin.get_cAcc_Id(); + } + } + public U8LoginContext() { - //uiLogin = new UFSoft.U8.Framework.Login.UI.clsLogin(); } - public clsLogin ClsLogin { get @@ -55,7 +55,6 @@ namespace NX.ERP.U8 uiLogin.ShutDown(); uiLogin = null; } - } public string UserId { get; set; } = "003"; @@ -63,14 +62,12 @@ namespace NX.ERP.U8 public string Server { get; set; } = "192.168.0.250"; - public string AccID { get; set; } = "u8@889"; + public string AccID { get; set; } = "(default)@001"; public string Serial { get; set; } - - - - - + /// + /// ADO.NET 链接字符串 + /// public string Constr4Net { get @@ -78,10 +75,10 @@ namespace NX.ERP.U8 return this.ClsLogin.UFDataConnstringForNet; } } - - + /// + /// ADO的链接字符串 + /// public string Constr - { get { @@ -102,18 +99,24 @@ namespace NX.ERP.U8 } - - - - - - public void Login(bool showlogin = false) { - if (!UiLogin.login("DP", "wx998", "", "192.168.0.250", "2020-12-31", AccID, Serial, showlogin)) + if (showlogin) { - throw new Exception(UiLogin.ErrDescript); + if (!UiLogin.login("DP")) + { + throw new Exception(UiLogin.ErrDescript); + } } + else + { + + if (!UiLogin.login("DP", "wx999", "!@#qwe123", "192.168.0.168", DateTime.Today.ToString("yyyy-MM-dd"), AccID, Serial)) + { + throw new Exception(UiLogin.ErrDescript); + } + } + if (UiLogin.SubLogin("ST") == null) { @@ -126,7 +129,7 @@ namespace NX.ERP.U8 } _clslogin.set_TaskId(UiLogin.GetTaskID("ST")); - + } } } diff --git a/NX.ERP.WebAPi/Controllers/ArrivalController.cs b/NX.ERP.WebAPi/Controllers/ArrivalController.cs new file mode 100644 index 0000000..8a36ca0 --- /dev/null +++ b/NX.ERP.WebAPi/Controllers/ArrivalController.cs @@ -0,0 +1,22 @@ +using NX.ERP.U8.Purchase; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Http; + +namespace NX.ERP.WebAPi.Controllers +{ + public class ArrivalController : ApiController + { + // GET api/values + [HttpGet] + public IEnumerable List() + { + var customerDAL = new ArrivalDAL(); + return customerDAL.GetList(); + + } + + } +} \ 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 5670bb6..cda115b 100644 --- a/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj +++ b/NX.ERP.WebAPi/NX.ERP.WebAPi.csproj @@ -127,6 +127,7 @@ +