protected async void btnAgregar_Click(object sender, EventArgs e) { if (ValidarInsertar()) { Models.Factura facturaIngresado = new Models.Factura(); Models.Factura factura = new Models.Factura() { PAG_CODIGO = Convert.ToInt32(drpCodigoPago.SelectedValue.ToString()), FAC_COMPROBANTE = txtFacComprobante.Text, FAC_ESTADO = drpDisponibilidad.SelectedValue.ToString() }; facturaIngresado = await facturaManager.Ingresar(factura, VG.usuarioActual.CadenaToken); if (facturaIngresado != null) { lblStatus.Text = "Factura ingresada correctamente"; lblStatus.ForeColor = Color.Green; lblStatus.Visible = true; InicializarControles(); } else { lblStatus.Text = "Hubo un error al ingresar la factura"; lblStatus.ForeColor = Color.Maroon; lblStatus.Visible = true; } } }
public IActionResult Editar(int id) { //Con esto se lista Models.Factura factura = _dbContext.Factura.Find(id); if (factura == null) { return(RedirectToAction("Index")); } factura.Pagos = _dbContext.Pago.ToList(); return(View("Editar")); }
public IActionResult CambiarEstado(int id) { //Con esto se lista Models.Factura factura = _dbContext.Factura.Find(id); if (factura == null) { return(RedirectToAction("Index")); } factura.Estado = !factura.Estado; _dbContext.Update(factura); _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public IActionResult Guardar(Models.Factura factura) { if (!ModelState.IsValid) { factura.Pagos = _dbContext.Pago.ToList(); return(View(factura.NumFactura == 0 ? "Crear" : "Editar", factura)); } else { _dbContext.Update(factura); } _dbContext.Add(factura); _dbContext.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(Models.Factura pFactura) { try { if (ModelState.IsValid) { var FacturaModificar = Mapper.Map <DATOS.Factura>(pFactura); Factura.ActualizarFactura(FacturaModificar); return(RedirectToAction("Index")); } else { return(View()); } } catch { return(View()); } }
public ActionResult Create(Models.Factura pFactura) { try { if (ModelState.IsValid) { var FacturaInsertar = Mapper.Map <DATOS.Factura>(pFactura); Factura.InsertarFactura(FacturaInsertar); return(RedirectToAction("Index")); } else { return(View()); } } catch { return(View()); } }
protected async void grdFacturas_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblCode = (Label)grdFacturas.Rows[e.RowIndex].Cells[0].FindControl("lblCodigoFactura"); string facCodigoPago = (grdFacturas.Rows[e.RowIndex].FindControl("drpCodigoPagoEdit") as DropDownList).Text.Trim(); string facComprobante = (grdFacturas.Rows[e.RowIndex].FindControl("txtFacComprobanteEdit") as TextBox).Text; string facEstado = (grdFacturas.Rows[e.RowIndex].FindControl("drpDisponibilidadEdit") as DropDownList).Text; if (ValidarModificar(facCodigoPago, facComprobante, facEstado)) { Models.Factura facturaModificado = new Models.Factura(); Models.Factura factura = new Models.Factura() { FAC_CODIGO = Convert.ToInt32(lblCode.Text), PAG_CODIGO = Convert.ToInt32(facCodigoPago), FAC_COMPROBANTE = facComprobante, FAC_ESTADO = facEstado }; facturaModificado = await facturaManager.Actualizar(factura, VG.usuarioActual.CadenaToken); if (facturaModificado != null) { lblStatus.Text = "Factura modificada correctamente"; lblStatus.ForeColor = Color.Green; lblStatus.Visible = true; InicializarControles(); } else { lblStatus.Text = "Hubo un error al modificar la factura"; lblStatus.ForeColor = Color.Maroon; lblStatus.Visible = true; } grdFacturas.EditIndex = -1; InicializarControles(); } }
public IActionResult Crear() { Models.Factura Factura = new Models.Factura(); Factura.Pagos = _dbContext.Pago.ToList(); return(View(Factura)); }
/// <summary> /// Constructor de mapeo con entidad modelo /// </summary> /// <param name="factura"></param> public Factura(Models.Factura factura) { Fecha = Convert.ToDateTime(factura.Fecha); Fecha_Vencimiento = Convert.ToDateTime(factura.Fecha_Vencimiento); Monto = factura.Monto; }