public ActionResult ObtenerPrecioArticulo(int CantidadIngresada, string Cantidad, int IdArticulo) { JObject resultado = null; double PrecioGenerado = 0; double ImporteGenerado = 0; double EngancheGenerado = 0; double BonificacionEnganche = 0; double Total = 0; int ImportePrueb = 0; double PrecioDeContado = 0; double Totalapagar3meses = 0; double Totalapagar6meses = 0; double Totalapagar9meses = 0; double Totalapagar12meses = 0; double ImporteAbono3Meses = 0; double ImporteAbono6Meses = 0; double ImporteAbono9Meses = 0; double ImporteAbono12Meses = 0; double ImporteAhorro3 = 0; double ImporteAhorro6 = 0; double ImporteAhorro9 = 0; double ImporteAhorro12 = 0; try { int Cantidadaux = 0; int.TryParse(Cantidad, out Cantidadaux); ListadoArticulosVenta listAux = ObtenerArticulolist("", IdArticulo); if (listAux != null && listAux.Count == 1) { ArticulosVenta entidad = new ArticulosVenta(); entidad = listAux.ElementAt(0); ConfiguracionVenta EntidadConfiguracion = ObtenerConfiguraciones(); //generacion de precio venta eh importe PrecioGenerado = entidad.Precio * (1 + (EntidadConfiguracion.TasaFinanciamiento * EntidadConfiguracion.PlazoMaximo) / 100); ImporteGenerado = PrecioGenerado * CantidadIngresada; EngancheGenerado = (EntidadConfiguracion.PorcentajeEnganche / 100.00) * ImporteGenerado; BonificacionEnganche = EngancheGenerado * ((EntidadConfiguracion.TasaFinanciamiento * EntidadConfiguracion.PlazoMaximo) / 100); Total = ImporteGenerado - EngancheGenerado - BonificacionEnganche; PrecioDeContado = Total / (1 + (EntidadConfiguracion.TasaFinanciamiento * EntidadConfiguracion.PlazoMaximo) / 100); Totalapagar3meses = PrecioDeContado * (1 + (EntidadConfiguracion.TasaFinanciamiento * 3) / 100); Totalapagar6meses = PrecioDeContado * (1 + (EntidadConfiguracion.TasaFinanciamiento * 6) / 100); Totalapagar9meses = PrecioDeContado * (1 + (EntidadConfiguracion.TasaFinanciamiento * 9) / 100); Totalapagar12meses = PrecioDeContado * (1 + (EntidadConfiguracion.TasaFinanciamiento * 12) / 100); ImporteAbono3Meses = Totalapagar3meses / 3; ImporteAbono6Meses = Totalapagar6meses / 6; ImporteAbono9Meses = Totalapagar9meses / 9; ImporteAbono12Meses = Totalapagar12meses / 12; ImporteAhorro3 = Total - Totalapagar3meses; ImporteAhorro6 = Total - Totalapagar6meses; ImporteAhorro9 = Total - Totalapagar9meses; ImporteAhorro12 = Total - Totalapagar12meses; int ExistenciaActualizar = Cantidadaux; // ActualizarExistencia(entidad.IdArticulo,ExistenciaActualizar); resultado = new JObject(new JProperty("Estatus", "Correcto") , new JProperty("PrecioGenerado", PrecioGenerado.ToString()) , new JProperty("ImporteGenerado", ImporteGenerado.ToString()) , new JProperty("EngancheGenerado", EngancheGenerado.ToString()) , new JProperty("BonificacionEnganche", BonificacionEnganche.ToString()) , new JProperty("TotalAdeudo", Total.ToString()) , new JProperty("PrecioContado", PrecioDeContado.ToString()) , new JProperty("Total3Meses", Totalapagar3meses.ToString()) , new JProperty("Total6Meses", Totalapagar6meses.ToString()) , new JProperty("Total9Meses", Totalapagar9meses.ToString()) , new JProperty("Total12Meses", Totalapagar12meses.ToString()) , new JProperty("ImporteAbono3Meses", ImporteAbono3Meses.ToString()) , new JProperty("ImporteAbono6Meses", ImporteAbono6Meses.ToString()) , new JProperty("ImporteAbono9Meses", ImporteAbono9Meses.ToString()) , new JProperty("ImporteAbono12Meses", ImporteAbono12Meses.ToString()) , new JProperty("ImporteAhorro3", ImporteAhorro3.ToString()) , new JProperty("ImporteAhorro6", ImporteAhorro6.ToString()) , new JProperty("ImporteAhorro9", ImporteAhorro9.ToString()) , new JProperty("ImporteAhorro12", ImporteAhorro12.ToString()) ); return(Json(resultado.ToString(), JsonRequestBehavior.AllowGet)); } } catch (Exception e) { throw; } resultado = new JObject(new JProperty("Estatus", "Error")); return(Json(resultado.ToString(), JsonRequestBehavior.AllowGet)); }
public ListadoArticulosVenta ObtenerArticulolist(string FiltroActual, int IdArticulo) { string textFilter = ""; StringBuilder consulta = new StringBuilder(); SqlConnection conexion = null; SqlCommand comando = null; SqlDataReader reader = null; try { conexion = Obtenerconexion(true); if (IdArticulo != 0) { consulta.AppendLine(" SELECT * FROM VTA_ARTICULOS "); consulta.AppendLine(" WHERE ID = @IDARTICULO "); } else { consulta.AppendLine("SELECT * FROM VTA_ARTICULOS "); consulta.AppendLine("WHERE "); consulta.AppendLine(" DESCRIPCION LIKE @FILTRO "); consulta.AppendLine("OR MODELO LIKE @FILTRO "); } comando = obtenercomando(conexion, consulta); if (FiltroActual != "") { comando.Parameters.Add("@FILTRO", SqlDbType.VarChar); comando.Parameters["@FILTRO"].Value = "%" + FiltroActual + "%"; } if (IdArticulo != 0) { comando.Parameters.Add("@IDARTICULO", SqlDbType.Int); comando.Parameters["@IDARTICULO"].Value = IdArticulo; } reader = comando.ExecuteReader(); listadoArticulosVenta = new ListadoArticulosVenta(); while (reader.Read()) { ArticulosVenta Entidad = new ArticulosVenta(); int i = 0; Entidad.IdArticulo = (reader[i] != DBNull.Value ? reader.GetInt32(i) : 0); i++; Entidad.Descripcion = (reader[i] != DBNull.Value ? reader.GetString(i) : string.Empty); i++; Entidad.Modelo = (reader[i] != DBNull.Value ? reader.GetString(i) : string.Empty); i++; Entidad.Precio = (reader[i] != DBNull.Value ? Convert.ToDouble(reader.GetDecimal(i)) : 0); i++; Entidad.Existencia = (reader[i] != DBNull.Value ? reader.GetInt32(i) : 0); i++; listadoArticulosVenta.Add(Entidad); } } catch (Exception e) { } return(listadoArticulosVenta); }