Commit inicial: ITCA_API_SAP_WMS (.NET Core 3.1)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
2b82744eb8
168 files changed
+11066
No files matched your search
@@ -0,0 +1,35 @@
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData.Correlativo
|
||||
{
|
||||
public class HelperCorrelativo
|
||||
{
|
||||
public static string Get(string Serie)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
string Cuenta = "";
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"SELECT \"U_SYP_NDCD\" FROM \"{LocalData.Schema}\".\"@SYP_NUMDOC\" WHERE \"Code\" = '07' AND \"U_SYP_NDSD\" = ?", con);
|
||||
cmd.Parameters.Add("Serie", HanaDbType.VarChar).Value = Serie ?? "";
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
Cuenta = (dt.Rows[x]["U_SYP_NDCD"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_SYP_NDCD"]) : string.Empty;
|
||||
}
|
||||
|
||||
return Cuenta;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using Sap.Data.Hana;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData
|
||||
{
|
||||
public class HelperDB
|
||||
{
|
||||
public static void SET(string query)
|
||||
{
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand
|
||||
{
|
||||
CommandText = query,
|
||||
Connection = con,
|
||||
CommandType = CommandType.Text
|
||||
};
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using Net.Business.Entities.ServicesLayer.HR;
|
||||
using Net.Business.Entities.ServicesLayer.Items;
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData.HojaRuta
|
||||
{
|
||||
public class HelperHojaRuta
|
||||
{
|
||||
public static List<HojaRutaDetailsEntities> Get(int DocEntry)
|
||||
{
|
||||
List<HojaRutaDetailsEntities> ListaStock = new List<HojaRutaDetailsEntities>();
|
||||
DataTable dt = new DataTable();
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"CALL\"{LocalData.Schema}\".\"ITC_GetDataDetalleHR\"(?)", con);
|
||||
cmd.Parameters.Add("DocEntry", HanaDbType.VarChar).Value = DocEntry.ToString();
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
ListaStock.Add(new HojaRutaDetailsEntities()
|
||||
{
|
||||
U_ARD_PHR_DIRDESP = (dt.Rows[x]["U_ARD_PHR_DIRDESP"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_DIRDESP"]) : string.Empty,
|
||||
U_ARD_PHR_FEENPED = (dt.Rows[x]["U_ARD_PHR_FEENPED"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["U_ARD_PHR_FEENPED"]) : DateTime.Now,
|
||||
U_ARD_PHR_FORPAG = (dt.Rows[x]["U_ARD_PHR_FORPAG"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_FORPAG"]) : string.Empty,
|
||||
U_ARD_PHR_MONED = (dt.Rows[x]["U_ARD_PHR_MONED"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_MONED"]) : string.Empty,
|
||||
U_ARD_PHR_NOMCLI = (dt.Rows[x]["U_ARD_PHR_NOMCLI"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_NOMCLI"]) : string.Empty,
|
||||
U_ARD_PHR_NROFACT = (dt.Rows[x]["U_ARD_PHR_NROFACT"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_NROFACT"]) : string.Empty,
|
||||
U_ARD_PHR_NROGRE = (dt.Rows[x]["U_ARD_PHR_NROGRE"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_NROGRE"]) : string.Empty,
|
||||
U_ARD_PHR_NROPED = (dt.Rows[x]["U_ARD_PHR_NROPED"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_NROPED"]) : string.Empty,
|
||||
U_ARD_PHR_RUCCLI = (dt.Rows[x]["U_ARD_PHR_RUCCLI"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_RUCCLI"]) : string.Empty,
|
||||
U_ARD_PHR_TERRIT = (dt.Rows[x]["U_ARD_PHR_TERRIT"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_TERRIT"]) : string.Empty,
|
||||
U_ARD_PHR_TOTALPD = (dt.Rows[x]["U_ARD_PHR_TOTALPD"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["U_ARD_PHR_TOTALPD"]) : 0,
|
||||
U_ARD_PHR_ZONA = (dt.Rows[x]["U_ARD_PHR_ZONA"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ARD_PHR_ZONA"]) : string.Empty,
|
||||
U_ARD_TOTALFC = (dt.Rows[x]["U_ARD_TOTALFC"] != DBNull.Value) ? Convert.ToDecimal(dt.Rows[x]["U_ARD_TOTALFC"]) : 0,
|
||||
U_ITC_PHR_NOMVEN = (dt.Rows[x]["U_ITC_PHR_NOMVEN"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ITC_PHR_NOMVEN"]) : string.Empty,
|
||||
U_MSV_PKH_CGUI = (dt.Rows[x]["U_MSV_PKH_CGUI"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_MSV_PKH_CGUI"]) : string.Empty,
|
||||
U_MSV_PKH_DCPE = (dt.Rows[x]["U_MSV_PKH_DCPE"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_MSV_PKH_DCPE"]) : string.Empty,
|
||||
U_MSV_PKH_DGRE = (dt.Rows[x]["U_MSV_PKH_DGRE"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_MSV_PKH_DGRE"]) : string.Empty,
|
||||
U_MSV_PKH_DORV = (dt.Rows[x]["U_MSV_PKH_DORV"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_MSV_PKH_DORV"]) : string.Empty,
|
||||
U_MSV_PKH_PEOV = (dt.Rows[x]["U_MSV_PKH_PEOV"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["U_MSV_PKH_PEOV"]) : 0,
|
||||
U_MSV_PKH_APLG = (dt.Rows[x]["U_MSV_PKH_APLG"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_MSV_PKH_APLG"]) : string.Empty,
|
||||
});
|
||||
}
|
||||
|
||||
return ListaStock;
|
||||
}
|
||||
|
||||
|
||||
public static List<BE_ItemStock> GetConsolidado(string ItemCode, string FromWarehouseCode)
|
||||
{
|
||||
List<BE_ItemStock> ListaStock = new List<BE_ItemStock>();
|
||||
DataTable dt = new DataTable();
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"CALL\"{LocalData.Schema}\".\"ITCA_WMS_SAP_GetStockConsolidado\"(?, ?)", con);
|
||||
cmd.Parameters.Add("ItemCode", HanaDbType.VarChar).Value = ItemCode ?? "";
|
||||
cmd.Parameters.Add("FromWarehouseCode", HanaDbType.VarChar).Value = FromWarehouseCode ?? "";
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
ListaStock.Add(new BE_ItemStock()
|
||||
{
|
||||
BinCode = (dt.Rows[x]["BinCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["BinCode"]) : string.Empty,
|
||||
DistNumber = (dt.Rows[x]["DistNumber"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DistNumber"]) : string.Empty,
|
||||
ExpDate = (dt.Rows[x]["ExpDate"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["ExpDate"]) : DateTime.Now,
|
||||
ItemCode = (dt.Rows[x]["ItemCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["ItemCode"]) : string.Empty,
|
||||
ItemName = (dt.Rows[x]["ItemName"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["ItemName"]) : string.Empty,
|
||||
OnHandQty = (dt.Rows[x]["OnHandQty"] != DBNull.Value) ? Convert.ToDouble(dt.Rows[x]["OnHandQty"]) : 0,
|
||||
WhsCode = (dt.Rows[x]["WhsCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["WhsCode"]) : string.Empty,
|
||||
WhsName = (dt.Rows[x]["WhsName"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["WhsName"]) : string.Empty,
|
||||
AvgPrice = (dt.Rows[x]["AvgPrice"] != DBNull.Value) ? Convert.ToDouble(dt.Rows[x]["AvgPrice"]) : 0,
|
||||
});
|
||||
}
|
||||
|
||||
return ListaStock;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData.Inventario
|
||||
{
|
||||
public class HelperInventario
|
||||
{
|
||||
public static string Get(string TipoMovimiento)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
string Cuenta = "";
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"CALL\"{LocalData.Schema}\".\"ITCA_GetAccountCode_TipoEntradaSalida\"(?)", con);
|
||||
cmd.Parameters.Add("TipoMovimiento", HanaDbType.VarChar).Value = TipoMovimiento ?? "";
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
Cuenta = (dt.Rows[x]["U_Cuenta"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_Cuenta"]) : string.Empty;
|
||||
}
|
||||
|
||||
return Cuenta;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData.Invoices
|
||||
{
|
||||
public class HelperInvoice
|
||||
{
|
||||
public static int Get(string DocNum)
|
||||
{
|
||||
DataTable dt = new DataTable();
|
||||
int DocEntry = 0;
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"CALL\"{LocalData.Schema}\".\"ITCA_WMS_SAP_GetEntradaPorImportacion\"(?)", con);
|
||||
cmd.Parameters.Add("DocNum", HanaDbType.VarChar).Value = DocNum ?? "";
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
DocEntry = (dt.Rows[x]["DocEntry"] != DBNull.Value) ? Convert.ToInt32(dt.Rows[x]["DocEntry"]) : 0;
|
||||
}
|
||||
|
||||
return DocEntry;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
using Net.Business.Entities.WMS.ProcesoPicking;
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData.HelperProcesoPermitido
|
||||
{
|
||||
public class HelperProcesoPermitido
|
||||
{
|
||||
public static int Get(string Proceso, int IdEstado, string Endpoint, out List<BE_ProcesoPicking> ListaProceso)
|
||||
{
|
||||
List<BE_ProcesoPicking> list = new List<BE_ProcesoPicking>();
|
||||
DataTable dt = new DataTable();
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"SELECT * FROM \"{LocalData.Schema}\".\"@ITCA_PROWMS\" WHERE \"U_ITCA_PROCESO\" = ? AND \"U_ITCA_ESTADO\" = ? AND \"U_ITCA_ENDPOINT\" = ?", con);
|
||||
cmd.Parameters.Add("Proceso", HanaDbType.VarChar).Value = (Proceso ?? "").ToUpper();
|
||||
cmd.Parameters.Add("IdEstado", HanaDbType.VarChar).Value = IdEstado.ToString();
|
||||
cmd.Parameters.Add("Endpoint", HanaDbType.VarChar).Value = Endpoint ?? "";
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
list.Add(new BE_ProcesoPicking()
|
||||
{
|
||||
Code = (dt.Rows[x]["Code"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Code"]) : string.Empty,
|
||||
U_ITCA_ESTADO = (dt.Rows[x]["U_ITCA_ESTADO"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ITCA_ESTADO"]) : string.Empty,
|
||||
U_ITCA_GNRPROC = (dt.Rows[x]["U_ITCA_GNRPROC"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ITCA_GNRPROC"]) : string.Empty,
|
||||
U_ITCA_PROCESO = (dt.Rows[x]["U_ITCA_PROCESO"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ITCA_PROCESO"]) : string.Empty,
|
||||
});
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
ListaProceso = list;
|
||||
return dt.Rows.Count;
|
||||
}
|
||||
|
||||
public static string GetMotivoAlmacen(string CodEstado, out bool Reproceso, out string MotivoNotaCredito, out string DescripcionMotivo)
|
||||
{
|
||||
string Almacen = "";
|
||||
Reproceso = false;
|
||||
MotivoNotaCredito = "";
|
||||
DescripcionMotivo = "";
|
||||
DataTable dt = new DataTable();
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"SELECT * FROM \"{LocalData.Schema}\".\"@SYP_MOTIVOS\" WHERE \"Code\" = ?", con);
|
||||
cmd.Parameters.Add("Code", HanaDbType.VarChar).Value = (CodEstado ?? "").ToUpper();
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
Reproceso = (dt.Rows[x]["U_ITC_WMS_RPG"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ITC_WMS_RPG"]) == "Y" : false;
|
||||
Almacen = (dt.Rows[x]["U_ITC_WMS_WHS"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_ITC_WMS_WHS"]) : string.Empty;
|
||||
MotivoNotaCredito = (dt.Rows[x]["U_SYP_CODMO"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["U_SYP_CODMO"]) : string.Empty;
|
||||
DescripcionMotivo = (dt.Rows[x]["Name"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["Name"]) : string.Empty;
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
return Almacen;
|
||||
}
|
||||
|
||||
public static int? ConvertTimeToSeconds(string timeString)
|
||||
{
|
||||
string[] parts = timeString.Split(':');
|
||||
if (parts.Length != 3)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
int hours = int.Parse(parts[0]);
|
||||
int minutes = int.Parse(parts[1]);
|
||||
int seconds = int.Parse(parts[2]);
|
||||
|
||||
return (hours * 3600) + (minutes * 60) + seconds;
|
||||
}
|
||||
|
||||
public static int? ConvertTimeToInteger(string timeString)
|
||||
{
|
||||
// Split the time string into hours and minutes
|
||||
string[] parts = timeString.Split(':');
|
||||
if (parts.Length == 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
int hours = int.Parse(parts[0]);
|
||||
int minutes = int.Parse(parts[1]);
|
||||
|
||||
// Combine hours and minutes into a single integer (e.g., 10:30 becomes 1030)
|
||||
int result = (hours * 100) + minutes;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
using Sap.Data.Hana;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData.HelperProcesoPermitido
|
||||
{
|
||||
public class HelperProcesoPiciking
|
||||
{
|
||||
public static void Set(string Proceso, int IdEstado, int DocEntry, string CodMotivo, string Code)
|
||||
{
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand();
|
||||
// Parametrizado (antes interpolaba el string directo - SQL injection
|
||||
// real, ver docs/PORTE_FUNCIONALIDAD_NUEVA.md hallazgo #6): Proceso y
|
||||
// CodMotivo vienen del body del request HTTP sin validar.
|
||||
cmd.CommandText = $"CALL \"{LocalData.Schema}\".\"ITCA_WMS_SAP_SetProcesoPicking\"(?, ?, ?, ?, ?, ?, ?)";
|
||||
cmd.Parameters.Add("Proceso", HanaDbType.VarChar).Value = Proceso;
|
||||
cmd.Parameters.Add("IdEstado", HanaDbType.Integer).Value = IdEstado;
|
||||
cmd.Parameters.Add("DocEntry", HanaDbType.Integer).Value = DocEntry;
|
||||
cmd.Parameters.Add("HoraInicio", HanaDbType.VarChar).Value = "";
|
||||
cmd.Parameters.Add("HoraFin", HanaDbType.VarChar).Value = "";
|
||||
cmd.Parameters.Add("CodMotivo", HanaDbType.VarChar).Value = CodMotivo;
|
||||
cmd.Parameters.Add("Code", HanaDbType.VarChar).Value = Code;
|
||||
cmd.CommandType = System.Data.CommandType.Text;
|
||||
cmd.Connection = con;
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void Set(string Proceso, int IdEstado, int DocEntry, int? HoraInicio, int? HoraFin, string CodMotivo, string Code)
|
||||
{
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand();
|
||||
// Ver nota de parametrizacion en la sobrecarga de arriba.
|
||||
cmd.CommandText = $"CALL \"{LocalData.Schema}\".\"ITCA_WMS_SAP_SetProcesoPicking\"(?, ?, ?, ?, ?, ?, ?)";
|
||||
cmd.Parameters.Add("Proceso", HanaDbType.VarChar).Value = Proceso;
|
||||
cmd.Parameters.Add("IdEstado", HanaDbType.Integer).Value = IdEstado;
|
||||
cmd.Parameters.Add("DocEntry", HanaDbType.Integer).Value = DocEntry;
|
||||
cmd.Parameters.Add("HoraInicio", HanaDbType.VarChar).Value = HoraInicio?.ToString() ?? "";
|
||||
cmd.Parameters.Add("HoraFin", HanaDbType.VarChar).Value = HoraFin?.ToString() ?? "";
|
||||
cmd.Parameters.Add("CodMotivo", HanaDbType.VarChar).Value = CodMotivo;
|
||||
cmd.Parameters.Add("Code", HanaDbType.VarChar).Value = Code;
|
||||
cmd.CommandType = System.Data.CommandType.Text;
|
||||
cmd.Connection = con;
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using Net.Business.Entities.ServicesLayer.Items;
|
||||
using Sap.Data.Hana;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
|
||||
namespace Net.Data.HelperData.Stock
|
||||
{
|
||||
public class HelperStock
|
||||
{
|
||||
public static List<BE_ItemStock> Get(string ItemCode, string FromWarehouseCode)
|
||||
{
|
||||
List<BE_ItemStock> ListaStock = new List<BE_ItemStock>();
|
||||
DataTable dt = new DataTable();
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"CALL\"{LocalData.Schema}\".\"ITCA_WMS_SAP_GetStock\"(?, ?)", con);
|
||||
cmd.Parameters.Add("ItemCode", HanaDbType.VarChar).Value = ItemCode ?? "";
|
||||
cmd.Parameters.Add("FromWarehouseCode", HanaDbType.VarChar).Value = FromWarehouseCode ?? "";
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
ListaStock.Add(new BE_ItemStock()
|
||||
{
|
||||
BinCode = (dt.Rows[x]["BinCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["BinCode"]) : string.Empty,
|
||||
DistNumber = (dt.Rows[x]["DistNumber"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DistNumber"]) : string.Empty,
|
||||
ExpDate = (dt.Rows[x]["ExpDate"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["ExpDate"]) : DateTime.Now,
|
||||
ItemCode = (dt.Rows[x]["ItemCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["ItemCode"]) : string.Empty,
|
||||
ItemName = (dt.Rows[x]["ItemName"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["ItemName"]) : string.Empty,
|
||||
OnHandQty = (dt.Rows[x]["OnHandQty"] != DBNull.Value) ? Convert.ToDouble(dt.Rows[x]["OnHandQty"]) : 0,
|
||||
WhsCode = (dt.Rows[x]["WhsCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["WhsCode"]) : string.Empty,
|
||||
WhsName = (dt.Rows[x]["WhsName"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["WhsName"]) : string.Empty,
|
||||
});
|
||||
}
|
||||
|
||||
return ListaStock;
|
||||
}
|
||||
|
||||
|
||||
public static List<BE_ItemStock> GetConsolidado(string ItemCode, string FromWarehouseCode)
|
||||
{
|
||||
List<BE_ItemStock> ListaStock = new List<BE_ItemStock>();
|
||||
DataTable dt = new DataTable();
|
||||
using (HanaConnection con = new HanaConnection(LocalData.ConnectionString))
|
||||
{
|
||||
con.Open();
|
||||
HanaCommand cmd = new HanaCommand($"CALL\"{LocalData.Schema}\".\"ITCA_WMS_SAP_GetStockConsolidado\"(?, ?)", con);
|
||||
cmd.Parameters.Add("ItemCode", HanaDbType.VarChar).Value = ItemCode ?? "";
|
||||
cmd.Parameters.Add("FromWarehouseCode", HanaDbType.VarChar).Value = FromWarehouseCode ?? "";
|
||||
HanaDataAdapter da = new HanaDataAdapter(cmd);
|
||||
if (da != null)
|
||||
{
|
||||
da.Fill(dt);
|
||||
}
|
||||
con.Close();
|
||||
}
|
||||
|
||||
for (int x = 0; x < dt.Rows.Count; x++)
|
||||
{
|
||||
ListaStock.Add(new BE_ItemStock()
|
||||
{
|
||||
BinCode = (dt.Rows[x]["BinCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["BinCode"]) : string.Empty,
|
||||
DistNumber = (dt.Rows[x]["DistNumber"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["DistNumber"]) : string.Empty,
|
||||
ExpDate = (dt.Rows[x]["ExpDate"] != DBNull.Value) ? Convert.ToDateTime(dt.Rows[x]["ExpDate"]) : DateTime.Now,
|
||||
ItemCode = (dt.Rows[x]["ItemCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["ItemCode"]) : string.Empty,
|
||||
ItemName = (dt.Rows[x]["ItemName"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["ItemName"]) : string.Empty,
|
||||
OnHandQty = (dt.Rows[x]["OnHandQty"] != DBNull.Value) ? Convert.ToDouble(dt.Rows[x]["OnHandQty"]) : 0,
|
||||
WhsCode = (dt.Rows[x]["WhsCode"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["WhsCode"]) : string.Empty,
|
||||
WhsName = (dt.Rows[x]["WhsName"] != DBNull.Value) ? Convert.ToString(dt.Rows[x]["WhsName"]) : string.Empty,
|
||||
AvgPrice = (dt.Rows[x]["AvgPrice"] != DBNull.Value) ? Convert.ToDouble(dt.Rows[x]["AvgPrice"]) : 0,
|
||||
});
|
||||
}
|
||||
|
||||
return ListaStock;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user