public ActionResult AgregarArticulo(int idFactura, FacturasAgregarArticuloModel model) { if (ModelState.IsValid) { var articulo = context.Articulos.Find(model.ArticuloId); var factura = context.Facturas.Find(idFactura); var detalle = new FacturaDetalle(); detalle.FacturaId = idFactura; detalle.ArticuloId = articulo.Id; detalle.Cantidad = model.Cantidad; detalle.Monto = detalle.Cantidad * articulo.Precio; factura.MontoNeto = factura.MontoNeto + detalle.Monto; factura.MontoTotal = factura.MontoTotal + detalle.Monto; context.FacturaDetalles.Add(detalle); context.SaveChanges(); return(RedirectToAction("Details", new { id = idFactura })); } var articulos = context.Articulos; model.ListaArticulos = new SelectList(articulos, "Id", "Nombre"); return(View(model)); }
public async Task <IActionResult> Edit(int id, [Bind("IdFacturaDet,IdFactura,IdProducto,CantidadProducto,ValorUnitario,Descuento")] FacturaDetalle facturaDetalle) { if (id != facturaDetalle.IdFacturaDet) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(facturaDetalle); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FacturaDetalleExists(facturaDetalle.IdFacturaDet)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Descuento"] = new SelectList(_context.DetalleParametro, "IdDetParametro", "IdDetParametro", facturaDetalle.Descuento); ViewData["IdFactura"] = new SelectList(_context.FacturaCabecera, "IdFactura", "IdFactura", facturaDetalle.IdFactura); ViewData["IdProducto"] = new SelectList(_context.Producto, "IdProducto", "IdProducto", facturaDetalle.IdProducto); return(View(facturaDetalle)); }
public static bool Guardar(FacturaDetalle factura) { MySqlDataAdapter dater = new MySqlDataAdapter(); bool estado = true; try { var Id = FacturacionBLL.Buscar(); var IDfactura = Id.ElementAt(Id.Count() - 1); dater.InsertCommand = new MySqlCommand("insert into FacturaDetalles (Id,FacturaId,ProductoId,Cantidad,Precio,Descripcion) values ('" + factura.Id + "','" + factura.FacturaId + "','" + factura.ProductoId + "','" + factura.Cantidad + "','" + factura.Precio + "','" + factura.Descripcion + "')", ConexionGlobal.ConexionGlobalDb.RetornarConexion()); dater.InsertCommand.Connection = ConexionGlobal.ConexionGlobalDb.RetornarConexion(); dater.InsertCommand.ExecuteNonQuery(); } catch (Exception) { estado = false; throw; } return(estado); }
private void EliminarDetalle_Click(object sender, EventArgs e) { var result = MessageBox.Show("Desea Eliminar el detalle seleccionado?", " ", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { if (RowSelected >= 0) { Monto -= FacturacionBLL.RecalcularImporte(facturas.Detalle, RowSelected); MontotextBox.Text = Monto.ToString(); Arreglar = true; FacturaDetalle factura = facturas.Detalle.ElementAt(RowSelected); Detalle.Add(new FacturaDetalle(factura.Id, factura.FacturaId, factura.ProductoId, factura.Cantidad, factura.Precio, factura.Descripcion, factura.Importe)); facturas.Detalle.RemoveAt(RowSelected); FacturadataGridView.DataSource = null; FacturadataGridView.DataSource = facturas.Detalle; RowSelected = -1; if (paso) { AsignarDevuelta(); } MessageBox.Show("Eliminado!"); } } }
public static void ArreglarProductoDetalle(FacturaDetalle bill) { var producto = BLL.ProductoBLL.Buscar(bill.ProductoId); producto.Cantidad += bill.Cantidad; BLL.ProductoBLL.Modificar(producto); }
public async Task <ActionResult <FacturaDetalle> > PostFacturaDetalle(FacturaDetalle facturaDetalle) { _context.FacturaDetalle.Add(facturaDetalle); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFacturaDetalle", new { id = facturaDetalle.Id }, facturaDetalle)); }
public static List <FacturaDetalle> GetListFacturaDetalle(int facturaID) { List <FacturaDetalle> theList = new List <FacturaDetalle>(); FacturaDetalle theData = null; try { FacturaDetalleDSTableAdapters.FacturaDetalleTableAdapter localAdapter = new FacturaDetalleDSTableAdapters.FacturaDetalleTableAdapter(); FacturaDetalleDS.FacturaDetalleDataTable table = localAdapter.GetFacturaDetalleByFactID(facturaID); if (table != null && table.Rows.Count > 0) { foreach (var row in table) { theData = FillRecord(row); theList.Add(theData); } } } catch (Exception) { throw; } return(theList); }
public async Task <ActionResult <FacturaDetalle> > PostFacturaDetalle(FacturaDetalle item) { _context.DetallesFactura.Add(item); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetFacturaDetalle), new { id = item.Id }, item)); }
public void RemoverFacturaDetalle(Factura factura, FacturaDetalle facturaDetalle) { if (factura != null && facturaDetalle != null) { factura.FacturaDetalle.Remove(facturaDetalle); } }
protected void btnGuardarDetalle_Click(object sender, EventArgs e) { if (txtIdDetalle.Value == "0") { FacturaDetalle detalleNuevo = new FacturaDetalle(); detalleNuevo.Habilitado = true; detalleNuevo.ID_Factura = Convert.ToInt32(Request.QueryString["id"]); detalleNuevo.ID_Servicio = Convert.ToInt32(ddlServicio.SelectedValue); detalleNuevo.Cantidad = Convert.ToInt32(txtCantidad.Text); detalleNuevo.SubTotal = Convert.ToDouble(txtSubTotalDetalle.Text); db.FacturaDetalles.InsertOnSubmit(detalleNuevo); } else { var detalle = (from det in db.FacturaDetalles where det.ID_FacturaDetalle == Convert.ToInt32(txtIdDetalle.Value) select det).Single(); detalle.ID_Servicio = Convert.ToInt32(ddlServicio.SelectedValue); detalle.Cantidad = Convert.ToInt32(txtCantidad.Text); detalle.SubTotal = Convert.ToDouble(txtSubTotalDetalle.Text); } db.SubmitChanges(); grdDetalles.DataBind(); formDetalle.Visible = false; actualizarSubTotal(); }
public ActionResult ComprarProduct(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Inventario inventario = db.Inventario.Find(id); if (inventario == null) { return(HttpNotFound()); } var pi = Session["ProductI"] as List <Inventario>; pi.Add(inventario); var fv = Session["FacturaI"] as FacturaView; FacturaDetalle fd = new FacturaDetalle(); Productos p = db.Productos.Find(inventario.codigoProducto); fd.Descripcion = p.descripcionProducto; fd.codigoInventario = inventario.id; fd.Nombre = p.nombreProducto; fd.precio = inventario.precioVenta; fv.factList.Add(fd); return(RedirectToAction("AddProduct")); }
//Programación de los Botones protected void agregarLinkButton_Click(object sender, EventArgs e) { List <FacturaDetalle> detalles = new List <FacturaDetalle>(); if (IsValid) { DateTime date = DateTime.Now.Date; int cantidad = Utils.ToInt(cantidadTextBox.Text); int precio = Utils.ToInt(precioTextBox.Text); int importe = Utils.ToInt(importeTextBox.Text); int productoId = Utils.ToIntObjetos(productoDropDownList.SelectedValue); string descripcion = Metodos.Descripcion(productoId); if (detalleGridView.Rows.Count != 0) { facturita.Detalle = (List <FacturaDetalle>)ViewState["Detalle"]; } FacturaDetalle detalle = new FacturaDetalle(); facturita.Detalle.Add(new FacturaDetalle(0, detalle.FacturaId, productoId, descripcion, cantidad, precio, importe)); ViewState["Detalle"] = facturita.Detalle; detalleGridView.DataSource = ViewState["Detalle"]; detalleGridView.DataBind(); LlenaValores(); } }
protected void gvDetalle_RowCommand(object sender, GridViewCommandEventArgs e) { var RowIndex = ((GridViewRow)((Control)e.CommandSource).NamingContainer).RowIndex; switch (e.CommandName) { case "Guardar": var detalle = new FacturaDetalle { CentroCosto = ((TextBox)gvDetalle.Rows[RowIndex].Cells[0].Controls[0]).Text, Item = ((TextBox)gvDetalle.Rows[RowIndex].Cells[1].Controls[0]).Text, Descripcion = ((TextBox)gvDetalle.Rows[RowIndex].Cells[2].Controls[0]).Text, Codigo = ((TextBox)gvDetalle.Rows[RowIndex].Cells[3].Controls[0]).Text, Cuotas = int.Parse(((TextBox)gvDetalle.Rows[RowIndex].Cells[4].Controls[0]).Text), Unidad = int.Parse(((TextBox)gvDetalle.Rows[RowIndex].Cells[5].Controls[0]).Text), PrecioUnitario = double.Parse(((TextBox)gvDetalle.Rows[RowIndex].Cells[6].Controls[0]).Text), PrecioTotal = double.Parse(((TextBox)gvDetalle.Rows[RowIndex].Cells[7].Controls[0]).Text), }; var old = Factura.Detalles.First(x => x.Identificador == gvDetalle.DataKeys[RowIndex]["Identificador"].ToString()); var index = Factura.Detalles.IndexOf(old); Factura.Detalles[index] = detalle; gvDetalle.EditIndex = -1; gvDetalle.DataBind(); break; case "Editar": gvDetalle.EditIndex = RowIndex; gvDetalle.DataBind(); break; } cargarGrilla(0); }
public async Task <IActionResult> PutFacturaDetalle(int id, FacturaDetalle facturaDetalle) { if (id != facturaDetalle.Id) { return(BadRequest()); } _context.Entry(facturaDetalle).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FacturaDetalleExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
/// <summary> /// Obtiene los datos registrados de un detalle de factura /// </summary> /// <param name="idFacturaDetalle">ID del detalle</param> /// <returns></returns> public FacturaDetalle GetFacturaDetalle(long idFacturaDetalle) { using (controlagricolaContext context = new controlagricolaContext()) { FacturaDetalle facturaDetalleEntidad = context.FacturaDetalle.Find(idFacturaDetalle); return(facturaDetalleEntidad); } }
public ActionResult DeleteConfirmed(int iddetalle, int idfactura) { FacturaDetalle facturaDetalle = db.FacturaDetalles.Find(iddetalle, idfactura); db.FacturaDetalles.Remove(facturaDetalle); db.SaveChanges(); return(RedirectToAction("Index")); }
public void MapearDetalleEntidad(FacturaDetalle entidadOrigen, FacturaDetalle entidadDestino) { entidadDestino.Concepto = entidadOrigen.Concepto; entidadDestino.Cantidad = entidadOrigen.Cantidad; entidadDestino.ValorUnidad = entidadOrigen.ValorUnidad; entidadDestino.Subtotal = entidadOrigen.Subtotal; entidadDestino.Estado = entidadOrigen.Estado; }
public static void DescontarProducto(FacturaDetalle item, FacturaDetalle ite) { var producto = ProductoBLL.Buscar(item.ProductoId); producto.Cantidad += ite.Cantidad; producto.Cantidad -= item.Cantidad; ProductoBLL.Modificar(producto); }
public static decimal RecalcularImporte(List<FacturaDetalle> list, int row) { decimal monto = 0; FacturaDetalle factura = list.ElementAt(row); factura.Importe = factura.Cantidad * factura.Precio; monto = factura.Importe; return monto; }
public void AgregarFacturaDetalle(Factura factura) { if (factura != null) { var nuevoDetalle = new FacturaDetalle(); factura.FacturaDetalle.Add(nuevoDetalle); } }
protected void AgregarButton_Click(object sender, EventArgs e) { EfectivoNumeric.Enabled = true; int producto = Convert.ToInt32(ArticuloDropDownList.SelectedValue); var productoBuscado = BLL.ProductoBLL.Buscar(producto); if (Convert.ToInt32(CantidadTextBox.Text) < productoBuscado.Cantidad || Convert.ToInt32(CantidadTextBox.Text) == productoBuscado.Cantidad) { if (FacturaDetalleGridView.Rows.Count != 0) { billes.BillDetalle = (List <FacturaDetalle>)ViewState["Detalle"]; } if (FacturaDropDownList.Text != Condicion) { if (billes.BillDetalle.Exists(x => x.ProductoId.Equals(Convert.ToInt32(ArticuloDropDownList.SelectedValue)))) { var articulo = billes.BillDetalle.Where(x => x.ProductoId.Equals(Convert.ToInt32(ArticuloDropDownList.SelectedValue))); } if (((FacturaDetalle)ViewState["ModificarArticuo"]).Id != 0) { billes.BillDetalle.Add(new FacturaDetalle(((FacturaDetalle)ViewState["ModificarArticuo"]).Id, Convert.ToInt32(FacturaDropDownList.SelectedValue), Convert.ToInt32(ArticuloDropDownList.SelectedValue), Convert.ToInt32(CantidadTextBox.Text), Convert.ToDecimal(PrecioArticuloTextBox.Text), ArticuloDropDownList.SelectedItem.Text, Convert.ToDecimal(ImporteTextBox.Text))); } else { billes.BillDetalle.Add(new FacturaDetalle(0, Convert.ToInt32(FacturaDropDownList.SelectedValue), Convert.ToInt32(ArticuloDropDownList.SelectedValue), Convert.ToInt32(CantidadTextBox.Text), Convert.ToDecimal(PrecioArticuloTextBox.Text), ArticuloDropDownList.SelectedItem.Text, Convert.ToDecimal(ImporteTextBox.Text))); } ViewState["ModificarArticuo"] = new FacturaDetalle(); } else { billes.BillDetalle.Add(new FacturaDetalle(0, 0, Convert.ToInt32(ArticuloDropDownList.SelectedValue), Convert.ToInt32(CantidadTextBox.Text), Convert.ToDecimal(PrecioArticuloTextBox.Text), ArticuloDropDownList.SelectedItem.Text, Convert.ToDecimal(ImporteTextBox.Text))); } ViewState["Detalle"] = billes.BillDetalle; //Monto CalcularMonto(); FacturaDetalleGridView.DataSource = ViewState["Detalle"]; FacturaDetalleGridView.DataBind(); Disable(); if (FormadePagoDropDownList.Text.Equals("Contado") && ((List <FacturaDetalle>)ViewState["Detalle"]).Count > 0) { EfectivoNumeric.Enabled = true; } else { EfectivoNumeric.Enabled = false; } } else { ScriptManager.RegisterStartupScript(this, typeof(Page), "toastr_message", script: "toastr['error']('No se puede Agregar cantidad mayor que existencia, Existencia = " + productoBuscado.Cantidad + "');", addScriptTags: true); } }
public ActionResult GuardarFactura(string Fecha, string importe, string Total, string IdCliente, List <FacturaDetalle> detalles) { string mensaje = ""; decimal iva = 16; int codigoCliente = 0; decimal imp = 0; decimal total = 0; DateTime fecha = new DateTime(); if (string.IsNullOrEmpty(Fecha) || string.IsNullOrEmpty(importe) || string.IsNullOrEmpty(Total) || string.IsNullOrEmpty(IdCliente)) { if (string.IsNullOrEmpty(Fecha)) { mensaje = "ERROR EN EL CAMPO FECHA"; } if (string.IsNullOrEmpty(importe)) { mensaje = "ERROR EN EL IMPORTE"; } if (string.IsNullOrEmpty(Total)) { mensaje = "ERROR EN EL CAMPO TOTAL"; } if (string.IsNullOrEmpty(IdCliente)) { mensaje = "ERROR CON EL CODIGO DEL CLIENTE"; } } else { fecha = Convert.ToDateTime(Fecha); codigoCliente = Convert.ToInt32(IdCliente); total = Convert.ToDecimal(Total); imp = Convert.ToDecimal(importe); Factura factura = new Factura(fecha, imp, total, codigoCliente, iva); try { db.Factura.Add(factura); db.SaveChanges(); foreach (var data in detalles) { int idJuego = Convert.ToInt32(data.IdJuego.ToString()); byte cantidad = Convert.ToByte(data.CantidadFacturada.ToString()); FacturaDetalle detalle = new FacturaDetalle(getSecuencial(factura.IdFactura), factura.IdFactura, idJuego, cantidad); db.FacturaDetalle.Add(detalle); } mensaje = "Factura guardada con éxito..."; } catch (Exception e) { mensaje = "Error al registrar la factura"; } } return(Json(mensaje)); }
/// <summary> /// Marca como "Cancelado" el detalle de una factura /// </summary> /// <param name="idFacturaDetalle"></param> public void DeleteFacturaDetalle(long idFacturaDetalle) { using (controlagricolaContext context = new controlagricolaContext()) { FacturaDetalle detalleEntidad = context.FacturaDetalle.Find(idFacturaDetalle); detalleEntidad.Estado = "CAN"; context.SaveChanges(); } }
//Detalle para el Detalle. public static FacturaDetalle Detalle(int IdLista) { Repositorio <FacturaDetalle> repositorio = new Repositorio <FacturaDetalle>(); FacturaDetalle detalle = new FacturaDetalle(); int id = IdLista; detalle = repositorio.Buscar(id); return(detalle); }
private void BtnVerVentas_Click(object sender, EventArgs e) { FrmConsultarVentas consultarVentas = new FrmConsultarVentas { Text = "Listado de Ventas [Usuario: " + nombreUsuario + "]" }; consultarVentas.ShowDialog(); facturaNueva = consultarVentas.FacturaNueva; if (facturaNueva != null) { btnGenerarVenta.Enabled = false; btnAnularVenta.Enabled = true; btnCancelar.Enabled = true; CargarInforme("INFORME", false, true); txtNumeroVenta.Text = facturaNueva.NumeroFactura; txtFechaRegistrada.Text = facturaNueva.FechaCreacion.ToString("dd-MM-yyyy"); clienteNuevo = Cliente.ObtenerCliente(facturaNueva.Cliente.Cuit); txtCUIT.Text = clienteNuevo.Cuit; txtRazonSocial.Text = clienteNuevo.Razon_social; txtCalle.Text = clienteNuevo.Calle; txtNumero.Text = clienteNuevo.Numero.ToString(); cboBarrios.SelectedIndex = clienteNuevo.BarrioAsociado.Id_barrio - 1; dgvVentas.Rows.Clear(); IList <FacturaDetalle> listaFacturaDetalles = FacturaDetalle.ObtenerListaFacturaDetalle(facturaNueva.NumeroFactura); for (int i = 0; i < listaFacturaDetalles.Count; i++) { dgvVentas.Rows.Add ( listaFacturaDetalles[i].ProyectoAsociado.Descripcion, listaFacturaDetalles[i].CantidadLicencias.ToString(), "$" + Convert.ToString(Convert.ToInt32(listaFacturaDetalles[i].Precio.ToString()) / Convert.ToInt32(listaFacturaDetalles[i].CantidadLicencias.ToString())), "$" + listaFacturaDetalles[i].Precio.ToString() ); } dgvVentas.ClearSelection(); ControlCampos(false); btnGenerarVenta.Enabled = false; btnAnularVenta.Enabled = true; btnGenerarFactura.Enabled = true; btnGuardar.Enabled = false; btnCancelar.Enabled = true; } }
public static List <FacturaDetalle> Editar(List <FacturaDetalle> list, FacturaDetalle factura) { foreach (var item in list) { if (item.Id == factura.Id) { item.Cantidad = factura.Cantidad; } } return(list); }
public static void ArreglarProducto(FacturaDetalle bill) { foreach (var items in ProductoBLL.Buscar()) { if (items.Idproducto == bill.ProductoId) { items.Cantidad += bill.Cantidad; ProductoBLL.Modificar(items); } } }
//descuenta al producto de una lista public static void DescontarProducto(FacturaDetalle item, FacturaDetalle ite) { var producto = ProductoBLL.Buscar(item.ProductoId.ToString()); foreach (var items in producto) { items.Cantidad += ite.Cantidad; items.Cantidad -= item.Cantidad; ProductoBLL.Modificar(items); } }
public async Task <FacturaDetalle> updateFacturaDetalle(int key, FacturaDetalle prmFactura) { var facturaAntiguo = _context.FacturaDetalles.Find(key); facturaAntiguo.ProductoId = prmFactura.ProductoId == null ? facturaAntiguo.ProductoId : prmFactura.ProductoId; facturaAntiguo.Cantidad = prmFactura.Cantidad == null ? facturaAntiguo.Cantidad : prmFactura.Cantidad; _context.FacturaDetalles.Update(facturaAntiguo); _context.SaveChanges(); return(prmFactura); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { fechaTextBox.Text = DateTime.Now.ToString("yyyy-MM-dd"); LlenaCombo(); ViewState["FacturaDetalle"] = new FacturaDetalle(); ViewState["Detalle"] = new Factura().Detalle; LlenaReport(); } }