public async Task <ActionResult <OrdenDetalle> > Post(OrdenDetalle ordenDetalles) { myDbContext.OrdenDetalles.Add(ordenDetalles); await myDbContext.SaveChangesAsync(); return(CreatedAtAction(nameof(Get), new { id = ordenDetalles.Id }, ordenDetalles)); }
public void CrearOrden(Orden orden) { orden.OrdenFecha = DateTime.Now; orden.Estado = 1; orden.OrdenTotal = _shoppingCart.GetShoppingCartTotal(); _db.Orden.Add(orden); _db.SaveChanges(); var shoppingCartItems = _shoppingCart.GetShoppingCartItems(); foreach (var shoppingCartItem in shoppingCartItems) { var orderDetail = new OrdenDetalle { Cantidad = shoppingCartItem.Amount, Precio = shoppingCartItem.Articulo.Precio, articuloId = shoppingCartItem.Articulo.Id, OrdenId = orden.Id }; _db.OrdenDetalle.Add(orderDetail); } _db.SaveChanges(); }
private void BtnEliminar_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count > 0) { foreach (DataGridViewRow k in dataGridView.SelectedRows) { int idUnique = (int)k.Cells[4].Value; foreach (DataRow r in tabla.Rows) { if ((int)r[4] == idUnique) { if (existInOrdenActual(idUnique)) { OrdenDetalle detalle = new OrdenDetalle(); detalle.IdData = (int)r[4]; detalle.IdDataPaquete = (int)r[0]; detalle.Cobertura = (int)r[3]; detalleDeleted.Add(detalle.IdData, detalle); IndexDelete.Add(idUnique); IndexExist.Remove(idUnique); } r.Delete(); break; } } } } }
public async Task <IActionResult> Edit(int id, [Bind("ordenDetallID,idArticulo,cantidad,precio,precioTotal,ordenID")] OrdenDetalle ordenDetalle) { if (id != ordenDetalle.ordenDetallID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(ordenDetalle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrdenDetalleExists(ordenDetalle.ordenDetallID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["idArticulo"] = new SelectList(_context.Articulo, "idArticulo", "idArticulo", ordenDetalle.idArticulo); ViewData["ordenID"] = new SelectList(_context.Ordens, "ordenID", "ordenID", ordenDetalle.ordenID); return(View(ordenDetalle)); }
public static bool ExistenExamenes(OrdenDetalle ordenDetalle) { SqlConnection conexion = new SqlConnection(); conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion; SqlCommand comando = new SqlCommand(); comando.Connection = conexion; comando.CommandText = ProcGet.GET_EXAMENCAB_EXISTE; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@idOrdenDetalle", ordenDetalle.IdData); comando.Connection.Open(); SqlDataReader resultado = comando.ExecuteReader(); int count = 0; while (resultado.Read()) { count = Convert.ToInt32(resultado["num"]); } resultado.Close(); conexion.Close(); comando.Dispose(); return(count > 0); }
public ActionResult Crear(int id) { var nuevaOrdenDetalle = new OrdenDetalle(); nuevaOrdenDetalle.OrdenId = id; var productos = _productosBL.ObtenerProductosActivos(); ViewBag.ProductoId = new SelectList(productos, "Id", "Descripcion"); return(View(nuevaOrdenDetalle)); }
private void BtnRegistrar_Click(object sender, EventArgs e) { try { if (tabla.Rows.Count == 0) { throw new Exception("Listado de Examenes: La lista esta vacia."); } if (Perfil == null) { throw new Exception("Perfil: Se necesita un perfil de paciente."); } orden = new Orden(); orden.Boleta = CampBoleta.Text; orden.FechaRegistro = PickerTime.Value; orden.IdPaciente = Perfil.IdData; orden.UltimaModificacion = PickerTime.Value; orden.IdConsultorio = (int)ComboBoxConsultorio.SelectedValue; orden.IdMedico = (int)ComboBoxMedico.SelectedValue; if (Perfil.Sexo == Sexo.Mujer) { orden.EstadoPaciente = (CheckBoxGestante.Checked ? PacienteEstado.Gestante:PacienteEstado.Normal); } else { orden.EstadoPaciente = PacienteEstado.Normal; } Dictionary <int, OrdenDetalle> detalles = new Dictionary <int, OrdenDetalle>(); OrdenDetalle detalle = null; int i = 0; foreach (DataRow r in tabla.Rows) { detalle = new OrdenDetalle(); detalle.IdDataPaquete = (int)r[0]; detalle.Cobertura = (int)r[3]; detalles.Add(i, detalle); i++; } orden.Detalle = detalles; LogicaOrden enlaceOrden = new LogicaOrden(); enlaceOrden.AgregarOrden(orden); MessageBox.Show("Orden: Se han registrado correctamente los datos.", "Confirmación"); DeshabilitarFormulario(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Advertencia"); } }
public void AgregarProducto(Producto producto) { int nuevoCodigo = ListaOrdenDetalle.Count + 1; int cantidad = 1; OrdenDetalle o = new OrdenDetalle(nuevoCodigo, 1, producto); ListaOrdenDetalle.Add(o); Total += cantidad * producto.Precio; }
public ActionResult Crear(int id) { var nuevaOrdenDetalle = new OrdenDetalle(); nuevaOrdenDetalle.OrdenId = id; var beneficios = _beneficiosBL.ObtenerBeneficiosActivos(); ViewBag.Beneficioid = new SelectList(beneficios, "id", "descripcion"); return(View(nuevaOrdenDetalle)); }
public void agregarProducto(Producto producto) { Impuesto = 0.15; int nuevoCodigo = ListaOrdenDetalle.Count + 1; int cantidad = 1; OrdenDetalle oD = new OrdenDetalle(nuevoCodigo, 1, producto); ListaOrdenDetalle.Add(oD); Subtotal += cantidad * producto.Precio; Impuesto *= Subtotal; Total = Subtotal + Impuesto; }
public IActionResult Update(int IdDet, [FromBody] OrdenDetalle entity) { try { ordenDetalleBusiness.UpdateOrdenDetalle(IdDet, entity); return(Ok(true)); } catch (Exception) { throw; } }
public IActionResult Create([FromBody] OrdenDetalle entity) { try { ordenDetalleBusiness.Create(entity); return(Ok(true)); } catch (Exception) { throw; } }
public ActionResult Crear(int id) { var nuevaOrdenDetalle = new OrdenDetalle(); nuevaOrdenDetalle.OrdenId = id; var tienda = _tiendaBL.ObtenerTiendaActivos(); ViewBag.TiendaId = new SelectList(tienda, "Id", "Descripcion"); return(View(nuevaOrdenDetalle)); }
public void AgregarProducto(Producto producto) { int nuevoCodigo = ListaOrdenDetalle.Count + 1; int cantidad = 1; OrdenDetalle o = new OrdenDetalle(nuevoCodigo, 1, producto); ListaOrdenDetalle.Add(o); Subtotal += cantidad * producto.Precio; Impuesto = (cantidad * producto.Precio) * 0.15; Total = (cantidad * producto.Precio) + ((cantidad * producto.Precio) * 0.15); }
private List <OrdenDetalle> generarOrdenDetalles(string usuarioEmail) { IEnumerable <CarritoItem> itemsCarrito = obteneritemsDelCarrito(usuarioEmail); List <OrdenDetalle> itemsOrden = new List <OrdenDetalle>(); foreach (var item in itemsCarrito) { OrdenDetalle ordenDetalle = crearOrdenDetalle(item); itemsOrden.Add(ordenDetalle); db.CarritoItems.Remove(item); } return(itemsOrden); }
public async Task <IActionResult> Create([Bind("ordenDetallID,idArticulo,cantidad,precio,precioTotal,ordenID")] OrdenDetalle ordenDetalle) { if (ModelState.IsValid) { _context.Add(ordenDetalle); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["idArticulo"] = new SelectList(_context.Articulo, "idArticulo", "idArticulo", ordenDetalle.idArticulo); ViewData["ordenID"] = new SelectList(_context.Ordens, "ordenID", "ordenID", ordenDetalle.ordenID); return(View(ordenDetalle)); }
private void MasButton_Click(object sender, RoutedEventArgs e) { orden.OrdenDetalle.Add(new OrdenDetalle(Convert.ToInt32(OrdenIdTextBox.Text), Convert.ToInt32(ProductoIdTextBox.Text), Convert.ToInt32(CantidadtextBox.Text))); Actualizar(); OrdenDetalle ordenDetalle = new OrdenDetalle(); int cantidad = ordenDetalle.Cantidad; int id = ordenDetalle.ProductoId; ProductoBLL.Calculo(id, cantidad); CantidadtextBox.Clear(); ProductoIdTextBox.Clear(); CantidadtextBox.Focus(); }
public void AgregarProducto(Producto producto) { int nuevoCodigo = ListaOrdenDetalle.Count + 1; int cantidad = 1; OrdenDetalle o = new OrdenDetalle(nuevoCodigo, 1, producto); ListaOrdenDetalle.Add(o); //tarea------------------------------------------------------------------ SubTotal += (cantidad * producto.Precio); Impuesto = (SubTotal * 0.15); Total = (SubTotal + Impuesto); }
public void AgregarProducto(Producto producto) { int nuevoCodigo = ListaOrdenDetalle.Count + 1; int cantidad = 1; double isv = 0.15; OrdenDetalle o = new OrdenDetalle(nuevoCodigo, 1, producto); ListaOrdenDetalle.Add(o); SubTotal += cantidad * producto.Precio; Impuesto = SubTotal * isv; Total = SubTotal + Impuesto; }
public void AgregarProducto(Producto producto) { int nuevoCodigo = ListaOrdenDetalle.Count + 1; int cantidad = 1; this.Subtotal = producto.Precio * cantidad; this.Impuesto = this.Subtotal * 15 / 100; OrdenDetalle o = new OrdenDetalle(nuevoCodigo, 1, producto); ListaOrdenDetalle.Add(o); this.Total = Subtotal + Impuesto; }
public void Create(OrdenDetalle entity) { try { SiinErpContext context = new SiinErpContext(); context.OrdenesDetalles.Add(entity); context.SaveChanges(); } catch (Exception ex) { errorBusiness.Create("CreateOrdenCompraDetalle", ex.Message, null); throw; } }
public void DeleteOrdenDetalle(int IdOrdenDetalle) { try { SiinErpContext context = new SiinErpContext(); OrdenDetalle entity = context.OrdenesDetalles.Find(IdOrdenDetalle); context.OrdenesDetalles.Remove(entity); context.SaveChanges(); UpdateVrNetoOrden(entity.IdOrden); } catch (Exception ex) { errorBusiness.Create("DeleteOrdenCompraDetalle", ex.Message, null); throw; } }
public ActionResult Crear(OrdenDetalle ordenDetalle) { if (ModelState.IsValid) { if (ordenDetalle.ProductoId == 0) { ModelState.AddModelError("ProductoId", "Seleccione un producto"); return(View(ordenDetalle)); } _ordenBL.GuardarOrdenDetalle(ordenDetalle); return(RedirectToAction("Index", new { id = ordenDetalle.OrdenId })); } var productos = _productosBL.ObtenerProductos(); ViewBag.ProductoId = new SelectList("Id", "Descripcion"); return(View(ordenDetalle)); }
private List <Examen> GetExamenes(Dictionary <int, Examen> examenesOrden, OrdenDetalle ordenDetalle) { List <int> indices = new List <int>(); foreach (int key in examenesOrden.Keys) { if (examenesOrden[key].IdOrdenDetalle == ordenDetalle.IdData) { indices.Add(key); } } List <Examen> examenes = new List <Examen>(); foreach (int keySelected in indices) { examenes.Add(examenesOrden[keySelected]); examenesOrden.Remove(keySelected); } return(examenes); }
public void UpdateOrdenDetalle(int IdOrdenDetalle, OrdenDetalle entity) { try { SiinErpContext context = new SiinErpContext(); OrdenDetalle obDet = context.OrdenesDetalles.Find(IdOrdenDetalle); obDet.Cantidad = entity.Cantidad; obDet.VrUnitario = entity.VrUnitario; obDet.PcDscto = entity.PcDscto; obDet.Margen = entity.Margen; context.SaveChanges(); UpdateVrNetoOrden(entity.IdOrden); } catch (Exception ex) { errorBusiness.Create("UpdateOrdenCompraDetalle", ex.Message, null); throw; } }
public ActionResult Crear(OrdenDetalle ordenDetalle) { if (ModelState.IsValid) { if (ordenDetalle.Beneficioid == 0) { ModelState.AddModelError("Beneficioid", "Seleccione un Beneficio"); return(View(ordenDetalle)); } _ordenBL.GuardarOrdenDetalle(ordenDetalle); return(RedirectToAction("Index", new { id = ordenDetalle.OrdenId })); } var beneficios = _beneficiosBL.ObtenerBeneficiosActivos(); ViewBag.Beneficioid = new SelectList(beneficios, "id", "descripcion"); return(View(ordenDetalle)); }
public ActionResult Crear(OrdenDetalle ordenDetalle) { if (ModelState.IsValid) { if (ordenDetalle.TiendaId == 0) { ModelState.AddModelError("TiendaId", "Seleccione un Articulo"); return(View(ordenDetalle)); } _ordenBL.GuardarOrdenDetalle(ordenDetalle); return(RedirectToAction("Index", new { id = ordenDetalle.OrdenId })); } var tienda = _tiendaBL.ObtenerTiendaActivos(); ViewBag.TiendaId = new SelectList(tienda, "Id", "Descripcion"); return(View(ordenDetalle)); }
//OPERACIONES ORDEN DETALLE public Dictionary <int, OrdenDetalle> ObtenerOrdenDetalleByOrden(int idData) { Dictionary <int, OrdenDetalle> ordenDetalle = new Dictionary <int, OrdenDetalle>(); OrdenDetalle detalle = null; SqlConnection conexion = new SqlConnection(); SqlCommand comando = new SqlCommand(); try { conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion; comando.Connection = conexion; comando.CommandText = ProcGet.GET_ORDENDET_BYORDENCAB; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@idOrden", idData); comando.Connection.Open(); SqlDataReader resultado = comando.ExecuteReader(); while (resultado.Read()) { detalle = new OrdenDetalle(); detalle.IdData = Convert.ToInt32(resultado["id"]); detalle.IdDataPaquete = Convert.ToInt32(resultado["idPaquete"]); detalle.Cobertura = Convert.ToInt32(resultado["cobertura"]); ordenDetalle.Add(detalle.IdData, detalle); } resultado.Close(); } catch (SqlException e) { throw new Exception(e.Message); } finally { conexion.Close(); comando.Dispose(); } return(ordenDetalle); }
// GET: Compras/Details/5 public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var compra = await _context.Compra .Include(c => c.Cliente) .Include(c => c.FormaEnvio) .Include(c => c.FormaPago) .FirstOrDefaultAsync(m => m.compraID == id); if (compra == null) { return(NotFound()); } var compraview = new CompraView(); var OrdenDetalle = new OrdenDetalle(); var CompraDetalle = new CompraDetalle(); compraview.Compra = await _context.Compra .Include(o => o.Cliente) .Include(o => o.FormaEnvio) .Include(o => o.FormaPago) .FirstOrDefaultAsync(m => m.compraID == id); var data = _context.compraDetalles.Include(od => od.Compra).Include(od => od.Articulo).Where(od => od.compraID.Equals(id)).ToList(); compraview.Articulos = data; ViewData["formaPago"] = new SelectList(_context.Compra, "formaPago", "formaPago", CompraDetalle.compraID); ViewData["compra"] = new SelectList(_context.Compra, "compraID", "compraID", CompraDetalle.compraID); ViewData["Articuloo"] = new SelectList(_context.Articulo, "idArticulo", "Nombre"); return(View(compraview)); }
public bool?RegistrarOrden(OrdenRqst objOrden) { bool?respuesta; try { Orden newOrden = new Orden { EmpleadoId = objOrden.empleadoId, LugarPersonasId = objOrden.lugar_PersonaId, Estado = "Pendiente", //FechaEjecucion=objOrden.FechaEjecucion, FechaGeneracion = DateTime.Now }; context.Orden.Add(newOrden); OrdenDetalle newOrdenDetalle = new OrdenDetalle { Orden = newOrden, EjemplarId = objOrden.ejemplarId, Estado = "Pendiente", }; context.OrdenDetalle.Add(newOrdenDetalle); var precioServicio = context.Servicio.FirstOrDefault(e => e.ServicioId == objOrden.servicioId); OrdenServicio newOrdenService = new OrdenServicio { OrdenDetalle = newOrdenDetalle, Precio = precioServicio == null?0:precioServicio.Precio, ServicioId = objOrden.servicioId, }; context.OrdenServicio.Add(newOrdenService); context.SaveChanges(); respuesta = true; } catch { respuesta = null; } return(respuesta); }