public int Actualizar(DetallesFormulasModel Objeto) { int res; try { using (SqlConnection con = new SqlConnection(conexion)) { using (SqlCommand cmd = new SqlCommand("spDetallesFormulasGuardar", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IdDetalle", SqlDbType.Int).Value = Objeto.IdDetalle; cmd.Parameters.Add("@IdFormula", SqlDbType.Int).Value = Objeto.IdFormula; cmd.Parameters.Add("@IdInsumo", SqlDbType.Int).Value = Objeto.IdInsumo; cmd.Parameters.Add("@CantidadInsumo", SqlDbType.Decimal).Value = Objeto.CantidadInsumo; cmd.Parameters.Add("@UnidadMedidaInsumo", SqlDbType.NVarChar).Value = Objeto.UnidadMedidaInsumo; cmd.Parameters.Add("@CostoInsumo", SqlDbType.Decimal).Value = Objeto.CostoInsumo; cmd.Parameters.Add("@IdUsuario", SqlDbType.Int).Value = Objeto.IdUsuario; cmd.Parameters.Add("@DetalleAccion", SqlDbType.NVarChar).Value = "A"; con.Open(); res = Convert.ToInt32(cmd.ExecuteScalar()); con.Close(); } } } catch (Exception ex) { throw new Exception("Error: " + ex.Message); } return(res); }
public int CambiarPrecios(DetallesFormulasModel Objeto) { int res; try { using (SqlConnection con = new SqlConnection(conexion)) { using (SqlCommand cmd = new SqlCommand("spCambiarPreciosFormulas", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@IdDetalle", SqlDbType.Int).Value = Objeto.IdDetalle; cmd.Parameters.Add("@IdFormula", SqlDbType.Int).Value = Objeto.IdFormula; cmd.Parameters.Add("@Precio", SqlDbType.Decimal).Value = Objeto.Precio; con.Open(); res = Convert.ToInt32(cmd.ExecuteScalar()); con.Close(); } } } catch (Exception ex) { throw new Exception("Error: " + ex.Message); } return(res); }
DetallesFormulasModel CreaObjetoDetalleFormula(int i, int idFormula, DataTable Detalle, double dolar, int IdUsuario) { DetallesFormulasModel _DetallesFormula = new DetallesFormulasModel(); _DetallesFormula.IdDetalle = 0; _DetallesFormula.IdFormula = idFormula; _DetallesFormula.IdInsumo = Convert.ToInt32(Detalle.Rows[i]["IdInsumo"]); _DetallesFormula.CantidadInsumo = Convert.ToDecimal(Detalle.Rows[i]["CantidadInsumo"]); _DetallesFormula.UnidadMedidaInsumo = (Detalle.Rows[i]["UnidadMedidaInsumo"].ToString()); _DetallesFormula.IdUsuario = IdUsuario; if (Convert.ToInt32(Detalle.Rows[i]["IdMoneda"]) == 2) { _DetallesFormula.CostoInsumo = calculaPrecio(Convert.ToString(Detalle.Rows[i]["UnidadMedida"]), Convert.ToDouble(Detalle.Rows[i]["PrecioUnitario"]), Convert.ToDouble(Detalle.Rows[i]["CantidadInsumo"]), Convert.ToString(Detalle.Rows[i]["UnidadMedidaInsumo"]), dolar); } else { _DetallesFormula.CostoInsumo = Convert.ToDecimal(Detalle.Rows[i]["CostoInsumo"]); } return(_DetallesFormula); }
public int ActualizarPrecios(DetallesFormulasModel Parametro) { try { return(cdDetallesFormula.CambiarPrecios(Parametro)); } catch (Exception er) { throw new Exception(er.Message); } }
public int Guardar(DetallesFormulasModel Objeto) { int res; try { res = cdDetallesFormula.Guardar(Objeto); } catch (Exception) { res = 0; } return(res); }