public async Task <IActionResult> Create([Bind("CodigoDetalle,NumeroFactura,CodigoProducto,Cantidad,Precio,Descuento")] DetalleFactura detalleFactura) { if (ModelState.IsValid) { _context.Add(detalleFactura); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(detalleFactura)); }
public async Task <IActionResult> Create([Bind("Id,FechaFactura,Cantidad")] DetalleFactura detalleFactura) { if (ModelState.IsValid) { _context.Add(detalleFactura); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(detalleFactura)); }
static DetalleFactura CargarDetalleFactura(IDataReader reader) { DetalleFactura detalleCreado = new DetalleFactura(); detalleCreado.FolioFactura = Convert.ToInt32(reader["Folio"]); detalleCreado.IdProducto = Convert.ToString(reader["IdProducto"]); detalleCreado.Cantidad = Convert.ToInt32(reader["Cantidad"]); detalleCreado.PrecioUnidad = Convert.ToDecimal(reader["PrecioUnidad"]); return(detalleCreado); }
public IHttpActionResult GetDetalleFactura(int id) { DetalleFactura detalleFactura = db.DetalleFactura.Find(id); if (detalleFactura == null) { return(NotFound()); } return(Ok(detalleFactura)); }
public ActionResult delete_Detalle(int id) { DetalleFactura detalle = db.DetalleFactura.ToList().Find(p => p.Id == id); if (detalle != null) { db.DetalleFactura.Remove(detalle); db.SaveChanges(); } return(Json(detalle, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "id,codigoFactura,codigoInventario,precio")] DetalleFactura detalleFactura) { if (ModelState.IsValid) { db.Entry(detalleFactura).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.codigoFactura = new SelectList(db.Factura, "id", "numeroSerie", detalleFactura.codigoFactura); ViewBag.codigoInventario = new SelectList(db.Inventario, "id", "id", detalleFactura.codigoInventario); return(View(detalleFactura)); }
public IHttpActionResult PostDetalleFactura(DetalleFactura detalleFactura) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.DetalleFactura.Add(detalleFactura); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = detalleFactura.IdDetalleFactura }, detalleFactura)); }
public ActionResult Create([Bind(Include = "Cantidad,Sku,NombreProducto,Precio,Total")] DetalleFactura detalleFactura) { if (ModelState.IsValid) { db.DetalleFactura.Add(detalleFactura); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdFactura = new SelectList(db.Factura, "IdFactura", "NumFactura", detalleFactura.IdFactura); return(View(detalleFactura)); }
public ActionResult Edit([Bind(Include = "IdDetalle,IdFactura,IdProducto,Cantidad,Precio")] DetalleFactura detalleFactura) { if (ModelState.IsValid) { db.Entry(detalleFactura).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.IdFactura = new SelectList(db.Factura, "IdFactura", "NombreTienda", detalleFactura.IdFactura); ViewBag.IdProducto = new SelectList(db.Producto, "IdProducto", "Nombre", detalleFactura.IdProducto); return(View(detalleFactura)); }
public void AgregarDetalleFactura(DetalleFactura pDetalleFactura) { try { miContexto.DetalleFactura.Add(pDetalleFactura); miContexto.SaveChanges(); } catch (Exception ex) { throw ex; } }
/// <summary> /// Crea detalle de factura por cada producto, creando la relacion entre el encabezado y el detalle. /// </summary> /// <returns></returns> public DetalleFactura CrearDetalleFactura(DetalleFactura _detalle) { try { return(detalleFactura.Add(_detalle)); } catch (Exception _ex) { log.RegistrarErrorLog((int)ModuloSistema.Facturacion, _ex.Message, _ex.Source + " : " + _ex.StackTrace); return(null); } }
public async Task <IActionResult> Create([Bind("Id,Cantidad,ITBIs,Valor,IdArticulo,IdFactura")] DetalleFactura detalleFactura) { if (ModelState.IsValid) { _context.Add(detalleFactura); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdArticulo"] = new SelectList(_context.Articulo, "Id", "Descripcion", detalleFactura.IdArticulo); ViewData["IdFactura"] = new SelectList(_context.Factura, "Id", "Id", detalleFactura.IdFactura); return(View(detalleFactura)); }
public static void InsertarDFactura(DetalleFactura dFactura, Datos datos) { string insercion = "INSERT INTO FacturasDetalle (id_factura, numero_orden, id_producto, id_proyecto, id_ciclo_prueba, precio, borrado) VALUES (" + dFactura.Id_factura.ToString() + ", " + dFactura.Numero_orden.ToString() + ", " + ((dFactura.Id_producto == -1) ? "NULL" : dFactura.Id_producto.ToString()) + ", " + ((dFactura.Id_proyecto == -1) ? "NULL" : dFactura.Id_proyecto.ToString()) + ", " + ((dFactura.Id_ciclo_prueba == -1) ? "NULL" : dFactura.Id_ciclo_prueba.ToString()) + ", " + dFactura.Precio.ToString() + ", 0)"; datos.EjecutarSQLConTransaccion(insercion); }
public DetalleFactura Save(int numeroFactura, int codigoProducto, int cantidad, decimal precio, decimal descuento) { DetalleFactura nuevo = new DetalleFactura(); nuevo.NumeroFactura = numeroFactura; nuevo.CodigoProducto = codigoProducto; nuevo.Cantidad = cantidad; nuevo.Precio = precio; nuevo.Descuento = descuento; db.DetalleFacturas.Add(nuevo); db.SaveChanges(); return(nuevo); }
private void cargarDatos() { try { int folio = IntegerExtensions.ParseInt(txtFolio.Text); dgvListado.DataSource = DetalleFactura.traerTodos(folio); dgvListado.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void EliminarDetalleFactura(int pNumeroDetalleFactura) { try { detalle = miContexto.DetalleFactura.First(DetalleFactura => DetalleFactura.NumeroDetalle == pNumeroDetalleFactura); miContexto.DetalleFactura.Remove(detalle); miContexto.SaveChanges(); } catch (Exception ex) { throw ex; } }
public async Task <IActionResult> Create([Bind("DetFacturaId,FacturaId,CancionId,PrecioUnidad,Cantidad")] DetalleFactura detalleFactura) { if (ModelState.IsValid) { _context.Add(detalleFactura); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CancionId"] = new SelectList(_context.Canciones, "CancionId", "CancionId", detalleFactura.CancionId); ViewData["FacturaId"] = new SelectList(_context.Facturas, "FacturaId", "FacturaId", detalleFactura.FacturaId); return(View(detalleFactura)); }
public static void Insert(DetalleFactura det, SqlConnection cn, SqlTransaction tran, int idFac) { Acceso ac = new Acceso(); //SqlConnection conexion = new SqlConnection(ac.getCadenaConexion()); SqlCommand cmd = new SqlCommand("sp_Insertar_detalle_factura", cn); cmd.Parameters.AddWithValue("@idFactura", idFac); if (det.producto != null) { cmd.Parameters.AddWithValue("@idProducto", det.producto.idProducto); } if (det.detPedido != null) { cmd.Parameters.AddWithValue("@idPedido", det.detPedido.pedido.idPedido); } cmd.Parameters.AddWithValue("@subtotal", det.subTotal); // es el precio cmd.Parameters.AddWithValue("@cantidad", det.cantidad); if (det.detPedido != null) { cmd.Parameters.AddWithValue("@idProductoPedido", det.detPedido.producto.idProducto); } cmd.Parameters.AddWithValue("@iva", det.iva); try { cmd.Connection = cn; cmd.Transaction = tran; cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); //if (det.producto != null) //{ // ProductoDAO.UpdateStockActualYDisponible(det, cn, tran); //} if (det.detPedido != null) { ProductoDAO.UpdateStockReservadoYActualdePedidoEntregado(det.detPedido, det.detPedido.pedido.idPedido, 7); } } catch (ArgumentException ex) { throw new ApplicationException(ex.Message); } catch (SqlException ex) { throw new ApplicationException("Error en BD: " + ex.Message); } }
public async Task <Response> PostDetalleFactura([FromBody] DetalleFactura detalleFactura) { try { if (!ModelState.IsValid) { return(new Response { IsSuccess = false, Message = Mensaje.ModeloInvalido }); } var respuesta = Existe(detalleFactura); if (!respuesta.IsSuccess) { db.DetalleFactura.Add(detalleFactura); await db.SaveChangesAsync(); return(new Response { IsSuccess = true, Message = Mensaje.Satisfactorio }); } return(new Response { IsSuccess = false, Message = Mensaje.ExisteRegistro }); } catch (Exception ex) { await GuardarLogService.SaveLogEntry(new LogEntryTranfer { ApplicationName = Convert.ToString(Aplicacion.SwRm), ExceptionTrace = ex, Message = Mensaje.Excepcion, LogCategoryParametre = Convert.ToString(LogCategoryParameter.Critical), LogLevelShortName = Convert.ToString(LogLevelParameter.ERR), UserName = "", }); return(new Response { IsSuccess = false, Message = Mensaje.Error, }); } }
public JsonResult ConfirmarOrden(int direccionEntrega) { int tipo = 0; string mensaje = ""; int orden = 0; using (var db = new VentaArticulosCreditoEntities()) { try { var user = (Usuario)Session["usuario"]; var carrito = db.Carrito.Include("Inventario.Articulo").Where(c => c.codigoUsuario == user.codigo).ToList(); var correlativo = new CorrelativoFactura(Guid.NewGuid().ToString()); int posicion = 1; //Creo el códio de la factura db.CorrelativoFactura.Add(correlativo); db.SaveChanges(); //Creo el encabezado de la factura var factura = new Factura(correlativo.correlativo, DateTime.Now, user.codigo, 0, direccionEntrega); db.Factura.Add(factura); db.SaveChanges(); foreach (var car in carrito) { //Creo detalle por cada posición del carrito var detalle = new DetalleFactura(posicion, correlativo.correlativo, (decimal)car.Inventario.precioVenta, (int)car.cantidad, car.Inventario.Articulo.codigo); db.DetalleFactura.Add(detalle); db.SaveChanges(); //Recupero el inventario de la posición y le resto la cantidad ordenada var inventario = car.Inventario; inventario.cantidad -= car.cantidad; db.Entry(inventario).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); //Elimino la posición del carrito db.Carrito.Remove(car); db.SaveChanges(); posicion += 1; } orden = correlativo.correlativo; //Envío correo MailController().SendConfirmOrder(user, ref tipo, ref mensaje, orden); }catch (Exception ex) { mensaje = "Error al confirmar orden"; } } return(Json(new { tipo = tipo, mensaje = mensaje, orden = orden }, JsonRequestBehavior.AllowGet)); }
public void Delete(int IdClase) { using (var db = new Data()) { DetalleFactura query = (from x in db.DetalleFactura where x.Id == IdClase select x).FirstOrDefault <DetalleFactura>(); if (query != null) { db.DetalleFactura.Remove(query); db.SaveChanges(); } } }
public bool Existe(string factura) { bool resp = false; using (var db = new Data()) { DetalleFactura Edo = (from x in db.DetalleFactura where x.Factura == factura select x).FirstOrDefault(); if (Edo != null) { resp = true; } } return(resp); }
//Obtener public DetalleFacturaEntidad ObtenerDetalleFactura(int idDetalle) { DataSet ds = DetalleFactura.SeleccionarDetalleFactura(idDetalle); DetalleFacturaEntidad dte = new DetalleFacturaEntidad(); foreach (DataRow row in ds.Tables[0].Rows) { dte.idDetalle = Convert.ToInt16(row["idDetalle"]); dte.nombre = row["nombre"].ToString(); dte.descripcion = row["descripcion"].ToString(); dte.precio = Convert.ToInt16(row["Precio"]); } return(dte); }
static public Int32 ActualizarDetalleFactura(DetalleFactura obj) { Int32 affectedRows = 0; try { } catch (Exception ex) { throw ex; } return(affectedRows); }
public ActionResult DetalleVenta(VentaViewModel venta) { DetalleFactura detalle = new DetalleFactura(); detalle.id_factura = venta.id_factura; detalle.id_producto = venta.id_producto; detalle.cantidad = venta.cantidad; detalle.precio = _db.Producto.FirstOrDefault(x => x.id_producto == venta.id_producto).precio; _db.DetalleFactura.Add(detalle); _db.SaveChanges(); return(RedirectToAction("DetalleVenta", new { id = detalle.id_factura })); }
// GET: DetalleFacturas/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DetalleFactura detalleFactura = db.DetalleFacturas.Find(id); if (detalleFactura == null) { return(HttpNotFound()); } return(View(detalleFactura)); }
public IHttpActionResult DeleteDetalleFactura(int id) { DetalleFactura detalleFactura = db.DetalleFacturas.Find(id); if (detalleFactura == null) { return(NotFound()); } db.DetalleFacturas.Remove(detalleFactura); db.SaveChanges(); return(Ok(detalleFactura)); }
public async Task <bool> EditAsync(DetalleFactura factura) { try { detalleFacturarepository.Update(factura); await detalleFacturarepository.SaveChangesAsync(); } catch (Exception) { return(false); } return(true); }
public ActionResult FinalizarCompra() { List <CarritoItem> compras = (List <CarritoItem>)Session["carrito"]; if (compras != null && compras.Count > 0) { //venta /CREAMOS LA FACTURA Factura nuevafactura = new Factura(); nuevafactura.FechaCreado = DateTime.Now; nuevafactura.Total_Venta = compras.Sum(x => x.Producto.PrecioUnitario * x.Cantidad); usuario = User.Identity.Name; //UserManager nuevafactura.Nombre_Usuario = usuario; db.Facturas.Add(nuevafactura); db.SaveChanges(); //factura creada ///GUARDAMOS LOS DETALLES DetalleFactura nueva = new DetalleFactura(); foreach (var item in Session["carrito"] as List <Proyecto1_LA.Models.CarritoItem> ) { nueva.Nombre = item.Producto.Nombre; nueva.PrecioVenta = item.Producto.PrecioUnitario; nueva.Cantidad = item.Cantidad; nueva.FechaCreado = DateTime.Now; nueva.NombreUsuario = usuario; nueva.idFactura = nuevafactura.idFactura; db.DetalleFacturas.Add(nueva); db.SaveChanges(); //AQUI REsTAMO LA CANTIDAD DEL PRODUCTOS Producto nuevopro = new Producto(); // nuevopro.Categorias = item.Producto.Categorias; // nuevopro.SubCategorias = item.Producto.SubCategorias; nuevopro.Nombre = item.Producto.Nombre; nuevopro.FechaCreado = item.Producto.FechaCreado; nuevopro.idCategoria = item.Producto.idCategoria; nuevopro.Descripcion = item.Producto.Descripcion; nuevopro.PrecioUnitario = item.Producto.PrecioUnitario; nuevopro.idProducto = item.Producto.idProducto; nuevopro.idSubCategoria = item.Producto.idSubCategoria; nuevopro.Cantidad = item.Producto.Cantidad - item.Cantidad; db.Entry(nuevopro).State = EntityState.Modified; db.SaveChanges(); } } return(View()); }
public void ModificarDetalelFactura(DetalleFactura pDetalleFactura) { try { detalle = miContexto.DetalleFactura.Single(DetalleFactura => DetalleFactura.NumeroFactura == pDetalleFactura.NumeroFactura); detalle.NumeroCasa = pDetalleFactura.NumeroCasa; detalle.Descripcion = pDetalleFactura.Descripcion; detalle.Total = pDetalleFactura.Total; miContexto.SaveChanges(); } catch (Exception ex) { throw ex; } }
private void btnAgregar_Click(object sender, EventArgs e) { errorProvider1.Clear(); if (txtCod_Factura.Text == string.Empty) { errorProvider1.SetError(txtCod_Factura, "Debe agregar un codigo"); } if (txtPrecio.Text == string.Empty) { errorProvider1.SetError(txtPrecio, "Debe ingresar el precio"); } if (txtCantidad.Text == string.Empty) { errorProvider1.SetError(txtCantidad, "Debe ingresar una cantidad"); } if (txtValor_Total.Text == string.Empty) { errorProvider1.SetError(txtValor_Total, "Debe calcular el valor"); } else { DetalleFactura fac = new DetalleFactura(); fac.CodFactura = Convert.ToInt32(txtCod_Factura.Text); fac.NombreProducto = cbProducto.Text; fac.Precio = Convert.ToInt32(txtPrecio.Text); fac.Cantidad = Convert.ToInt32(txtCantidad.Text); fac.ValorTotal = Convert.ToInt32(txtValor_Total.Text); Productos.Add(fac); dgFactura.DataSource = null; dgFactura.DataSource = Productos; dgFactura.Columns[0].Visible = false; txtCod_Factura.Text = ""; txtPrecio.Text = ""; txtCantidad.Text = ""; txtValor_Total.Text = ""; decimal total = 0; foreach (DataGridViewRow row in dgFactura.Rows) { total += Convert.ToDecimal(row.Cells["ValorTotal"].Value); } txtTotal.Text = Convert.ToString(total); txtTotal.Refresh(); } }
protected void btn_agregar_Click(object sender, EventArgs e) { try { List<DetalleFactura> detallef = new List<DetalleFactura>(); if (Session["S_DetalleFac"] != null) detallef = (List<DetalleFactura>)Session["S_DetalleFac"]; if (!ExisteServicio(int.Parse(ddl_motivo.SelectedValue), detallef)) { DetalleFactura df = new DetalleFactura(); //int idservicio = int.Parse(ddl_motivo.SelectedValue); df.id = int.Parse(ddl_motivo.SelectedValue); df.descripcion = ddl_motivo.SelectedItem.Text; Negocio.serviciosNegocio dc = new Negocio.serviciosNegocio(); df.precio = (int)dc.BuscarServicio(df.id).Precio; df.cantidad = int.Parse(tb_cantidad.Text); df.importe = df.precio * df.cantidad; //Calculando el total de la factura ------------------ /*decimal Total = 0; if (lb_Total.Text != "") Total = decimal.Parse(lb_Total.Text) + df.importe; else Total = df.importe; lb_Total.Text = Total.ToString(); lb_TotalFac.Text = Total.ToString("C"); //--- Termina el calculo ----------------------------*/ Label1.Visible = true; lb_total.Visible = true; lb_moneda.Visible = true; //lb_moneda.Text = "C$"; //Calculando el total de la factura ------------------ int totalfact = 0; if (lb_total.Text != "") totalfact = int.Parse(lb_total.Text) + df.importe; else totalfact = df.importe; lb_total.Text = totalfact.ToString(); lb_moneda.Text = totalfact.ToString("C"); //--- Termina el calculo ----------------------------*/ detallef.Add(df); /*int totalfact = 0; lb_total.Text = detallef.Sum(dep => dep.precio).ToString(); totalfact = int.Parse(lb_total.Text); lb_moneda.Text = totalfact.ToString("C");*/ /*Label2.Text = (from x in detallef select x.importe).Sum().ToString("C"); //----*/ Session.Add("S_DetalleFac", detallef); gv_detalle.DataSource = detallef; gv_detalle.DataBind(); btn_facturar.Enabled = true; btn_cancelar.Enabled = true; ddl_paciente.Enabled = false; ddl_motivo.SelectedIndex = 0; tb_cantidad.Text = ""; } else { cv_informacion.IsValid = false; cv_informacion.ErrorMessage = "El servicio ya esta incluido en la lista!!!"; } } catch (Exception err) { //MANEJAMOS EL ERROR cv_informacion.IsValid = false; cv_informacion.ErrorMessage = "Error al agregar el servicio al detalle, " + err.Message; } }