public bool Guardar(SqlConnection cnBD, SqlTransaction trx, ControlStockGBE obe) { bool rpta = false; using (SqlCommand cmd = new SqlCommand("[dbo].[USP_ControlStock_Guardar]", cnBD)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Transaction = trx; cmd.Parameters.Add("@lolistado", SqlDbType.Structured).Value = CrearEstructura(obe.listado); cmd.Parameters.Add("@UsrCreador", SqlDbType.VarChar, 50).Value = obe.usuario; int counterMarker = 0; object objRes = cmd.ExecuteScalar(); int.TryParse(objRes.ToString(), out counterMarker); if (counterMarker > 0) { rpta = true; } else { rpta = false; } } return(rpta); }
public ControlStockGBE ListarProductos(string usuario, int idCliente, int idAlmacen, int idTienda) { ControlStockGBE loProducto = new ControlStockGBE(); using (SqlConnection con = new SqlConnection(strCnx)) { con.Open(); loProducto = oControlStockDA.ListaProductoXTienda(con, usuario, idCliente, idAlmacen, idTienda); } return(loProducto); }
public bool Guardar(ControlStockGBE obe) { bool rpta = false; SqlTransaction sqltrans; using (SqlConnection con = new SqlConnection(strCnx)) { con.Open(); sqltrans = con.BeginTransaction(); rpta = oControlStockDA.Guardar(con, sqltrans, obe); if (rpta) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(rpta); }
public IHttpActionResult GetDatosIniciales(string usuario, int idCliente, int idAlmacen, int idTienda) { try { ControlStockBL oControlStockBL = new ControlStockBL(idCliente); ControlStockGBE obe = oControlStockBL.ListarProductos(usuario, idCliente, idAlmacen, idTienda); if (obe != null && obe.listado.Count > 0) { return(Ok(Models.Util.GetBodyResponse(200, obe))); } else { return(Ok(Models.Util.GetBodyResponse(300, "No se encontraron registros."))); } } catch (Exception ex) { /*LogSA.GrabarLogError("SOL TR", user, "GetListarOrdOtrs", ex);*/ return(Ok(Models.Util.GetBodyResponse(400, ex.Message))); } }
public async Task <IHttpActionResult> Guardar(ControlStockGBE obe) { try { bool rpta = false; ControlStockBL oControlStockBL = new ControlStockBL(obe.idCliente); rpta = oControlStockBL.Guardar(obe); if (rpta) { return(Ok(Models.Util.GetBodyResponse(200, "OK"))); } else { return(Ok(Models.Util.GetBodyResponse(300, "Ocurrió un error al guardar información"))); } } catch (Exception ex) { //LogSA.GrabarLogError("SOL TR", model.user, "EditarTareas", ex); return(Ok(Models.Util.GetBodyResponse(400, ex.Message))); } }
public ControlStockGBE ListaProductoXTienda(SqlConnection cnBD, string usuario, int idCliente, int idAlmacen, int idTienda) { ControlStockGBE obeCS = new ControlStockGBE(); List <ControlStockBE> lobe = new List <ControlStockBE>(); ControlStockBE obe = new ControlStockBE(); List <ControlStockBEReporte> lobeR = new List <ControlStockBEReporte>(); ControlStockBEReporte obeR = new ControlStockBEReporte(); List <ReporteColumnas> loColumns = new List <ReporteColumnas>(); ReporteColumnas obeColumns = new ReporteColumnas(); using (SqlCommand cmd = new SqlCommand("[dbo].[USP_ControlStock_Productos]", cnBD)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Parameters.Add("@IdCliente", SqlDbType.Int).Value = idCliente; cmd.Parameters.Add("@IdAlmacen", SqlDbType.Int).Value = idAlmacen; cmd.Parameters.Add("@IdTienda", SqlDbType.Int).Value = idTienda; cmd.Parameters.Add("@UsrCreador", SqlDbType.VarChar, 50).Value = usuario; using (SqlDataReader drd = cmd.ExecuteReader()) { if (drd.HasRows) { int pos_IdProductoAlmacen = drd.GetOrdinal("IdProductoAlmacen"); int pos_IdAlmacen = drd.GetOrdinal("IdAlmacen"); int pos_IdTienda = drd.GetOrdinal("IdTienda"); int pos_IdProducto = drd.GetOrdinal("IdProducto"); int pos_CodProducto = drd.GetOrdinal("CodProducto"); int pos_NombreProducto = drd.GetOrdinal("NombreProducto"); int pos_idProductoBase = drd.GetOrdinal("idProductoBase"); int pos_StockTotal = drd.GetOrdinal("StockTotal"); int pos_Stock = drd.GetOrdinal("Stock"); int pos_Precio = drd.GetOrdinal("Precio"); int pos_PrecioBlister = drd.GetOrdinal("PrecioBlister"); int pos_IdTipo = drd.GetOrdinal("IdTipo"); int pos_DesTipo = drd.GetOrdinal("DesTipo"); int pos_CodProdLaboratorio = drd.GetOrdinal("CodProdLaboratorio"); int pos_DesProdLaboratorio = drd.GetOrdinal("DesProdLaboratorio"); int pos_CodProdTipoPresentacion = drd.GetOrdinal("CodProdTipoPresentacion"); int pos_DesProdTipoPresentacion = drd.GetOrdinal("DesProdTipoPresentacion"); int pos_RegistroSanitario = drd.GetOrdinal("RegistroSanitario"); int pos_Cantidad = drd.GetOrdinal("Cantidad"); int pos_CantidadCaja = drd.GetOrdinal("CantidadCaja"); int pos_PrecioCosto = drd.GetOrdinal("PrecioCosto"); int pos_FecVencimiento = drd.GetOrdinal("FecVencimiento"); int pos_DetalleStock = drd.GetOrdinal("DetalleStock"); int pos_StockN = drd.GetOrdinal("StockN"); int pos_PrecioN = drd.GetOrdinal("PrecioN"); int pos_PrecioBlisterN = drd.GetOrdinal("PrecioBlisterN"); int pos_RecetaMedica = drd.GetOrdinal("RecetaMedica"); int pos_Val1 = drd.GetOrdinal("Val1"); int pos_Val2 = drd.GetOrdinal("Val2"); int pos_Val3 = drd.GetOrdinal("Val3"); lobe = new List <ControlStockBE>(); while (drd.Read()) { obe = new ControlStockBE(); obe.IdProductoAlmacen = drd.GetInt64(pos_IdProductoAlmacen); obe.IdAlmacen = drd.GetInt32(pos_IdAlmacen); obe.IdTienda = drd.GetInt32(pos_IdTienda); obe.IdProducto = drd.GetInt32(pos_IdProducto); obe.CodProducto = drd.GetString(pos_CodProducto); obe.NombreProducto = drd.GetString(pos_NombreProducto); obe.idProductoBase = drd.GetInt32(pos_idProductoBase); obe.StockTotal = drd.GetInt32(pos_StockTotal); obe.Stock = drd.GetInt32(pos_Stock); obe.Precio = drd.GetDecimal(pos_Precio); obe.PrecioBlister = drd.GetDecimal(pos_PrecioBlister); obe.IdTipo = drd.GetInt32(pos_IdTipo); obe.DesTipo = drd.GetString(pos_DesTipo); obe.CodProdLaboratorio = drd.GetString(pos_CodProdLaboratorio); obe.DesProdLaboratorio = drd.GetString(pos_DesProdLaboratorio); obe.CodProdTipoPresentacion = drd.GetString(pos_CodProdTipoPresentacion); obe.DesProdTipoPresentacion = drd.GetString(pos_DesProdTipoPresentacion); obe.RegistroSanitario = drd.GetString(pos_RegistroSanitario); obe.Cantidad = drd.GetInt32(pos_Cantidad); obe.CantidadCaja = drd.GetInt32(pos_CantidadCaja); obe.PrecioCosto = drd.GetDecimal(pos_PrecioCosto); obe.FecVencimiento = drd.GetString(pos_FecVencimiento); obe.DetalleStock = drd.GetString(pos_DetalleStock); obe.StockN = drd.GetInt32(pos_StockN); obe.PrecioN = drd.GetDecimal(pos_PrecioN); obe.PrecioBlisterN = drd.GetDecimal(pos_PrecioBlisterN); obe.RecetaMedica = drd.GetString(pos_RecetaMedica); obe.Val1 = drd.GetBoolean(pos_Val1); obe.Val2 = drd.GetBoolean(pos_Val2); obe.Val3 = drd.GetBoolean(pos_Val3); lobe.Add(obe); } obeCS.listado = lobe; } drd.NextResult(); if (drd.HasRows) { int pos_IdProductoAlmacen = drd.GetOrdinal("IdProductoAlmacen"); int pos_IdAlmacen = drd.GetOrdinal("IdAlmacen"); int pos_IdTienda = drd.GetOrdinal("IdTienda"); int pos_IdProducto = drd.GetOrdinal("IdProducto"); int pos_CodProducto = drd.GetOrdinal("CodProducto"); int pos_NombreProducto = drd.GetOrdinal("NombreProducto"); int pos_StockTotal = drd.GetOrdinal("StockTotal"); int pos_IdTipo = drd.GetOrdinal("IdTipo"); int pos_DesTipo = drd.GetOrdinal("DesTipo"); int pos_CodProdLaboratorio = drd.GetOrdinal("CodProdLaboratorio"); int pos_DesProdLaboratorio = drd.GetOrdinal("DesProdLaboratorio"); int pos_CodProdTipoPresentacion = drd.GetOrdinal("CodProdTipoPresentacion"); int pos_DesProdTipoPresentacion = drd.GetOrdinal("DesProdTipoPresentacion"); int pos_RegistroSanitario = drd.GetOrdinal("RegistroSanitario"); int pos_Precio = drd.GetOrdinal("Precio"); int pos_PrecioBlister = drd.GetOrdinal("PrecioBlister"); int pos_PrecioCosto = drd.GetOrdinal("PrecioCosto"); int pos_FecVencimiento = drd.GetOrdinal("FecVencimiento"); lobeR = new List <ControlStockBEReporte>(); while (drd.Read()) { obeR = new ControlStockBEReporte(); obeR.IdProductoAlmacen = drd.GetInt64(pos_IdProductoAlmacen); obeR.IdAlmacen = drd.GetInt32(pos_IdAlmacen); obeR.IdTienda = drd.GetInt32(pos_IdTienda); obeR.IdProducto = drd.GetInt32(pos_IdProducto); obeR.CodProducto = drd.GetString(pos_CodProducto); obeR.NombreProducto = drd.GetString(pos_NombreProducto); obeR.StockTotal = drd.GetInt32(pos_StockTotal); obeR.IdTipo = drd.GetInt32(pos_IdTipo); obeR.DesTipo = drd.GetString(pos_DesTipo); obeR.CodProdLaboratorio = drd.GetString(pos_CodProdLaboratorio); obeR.DesProdLaboratorio = drd.GetString(pos_DesProdLaboratorio); obeR.CodProdTipoPresentacion = drd.GetString(pos_CodProdTipoPresentacion); obeR.DesProdTipoPresentacion = drd.GetString(pos_DesProdTipoPresentacion); obeR.RegistroSanitario = drd.GetString(pos_RegistroSanitario); obeR.Precio = drd.GetDecimal(pos_Precio); obeR.PrecioBlister = drd.GetDecimal(pos_PrecioBlister); obeR.PrecioCosto = drd.GetDecimal(pos_PrecioCosto); obeR.FecVencimiento = drd.GetString(pos_FecVencimiento); lobeR.Add(obeR); } obeCS.listadoReporte = lobeR; } drd.NextResult(); if (drd.HasRows) { #region ColumnasLista - columnas int pos_field = drd.GetOrdinal("field"); int pos_header = drd.GetOrdinal("header"); int pos_width = drd.GetOrdinal("width"); #endregion ColumnasLista - columnas loColumns = new List <ReporteColumnas>(); while (drd.Read()) { #region ColumnasLista - campos obeColumns = new ReporteColumnas(); obeColumns.field = drd.GetString(pos_field); obeColumns.header = drd.GetString(pos_header); obeColumns.width = drd.GetInt32(pos_width); loColumns.Add(obeColumns); #endregion ColumnasLista - campos } obeCS.columnas = loColumns; } } } return(obeCS); }