添加导出到货单接口
This commit is contained in:
138
NX.ERP.U8/AdoHelper.cs
Normal file
138
NX.ERP.U8/AdoHelper.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,10 +36,12 @@
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AdoHelper.cs" />
|
||||
<Compile Include="Base\BinDAL.cs" />
|
||||
<Compile Include="Base\CustomerDAL.cs" />
|
||||
<Compile Include="Base\MaterielDAL.cs" />
|
||||
<Compile Include="Base\MaterielTypeDAL.cs" />
|
||||
<Compile Include="Purchase\ArrivalDAL.cs" />
|
||||
<Compile Include="STVocher.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Base\SupplierDAL.cs" />
|
||||
|
||||
42
NX.ERP.U8/Purchase/ArrivalDAL.cs
Normal file
42
NX.ERP.U8/Purchase/ArrivalDAL.cs
Normal file
@@ -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<Model.Purchase.Arrival> 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<int, Model.Purchase.Arrival>();
|
||||
// return conn.Query<Model.Purchase.Arrival>(strSQL,null);
|
||||
var list = conn.Query<Model.Purchase.Arrival, Model.Purchase.ArrivalDetail, Model.Purchase.Arrival>(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ADO.NET 链接字符串
|
||||
/// </summary>
|
||||
public string Constr4Net
|
||||
{
|
||||
get
|
||||
@@ -78,10 +75,10 @@ namespace NX.ERP.U8
|
||||
return this.ClsLogin.UFDataConnstringForNet;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ADO的链接字符串
|
||||
/// </summary>
|
||||
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"));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user