protected void btnModificar_Click(object sender, EventArgs e) { try { if (Session[LINEAS] == null) { Alerta("Necesita ingresar al menos un artículo"); return; } if (txtCliente.Text == "") { Alerta("Necesita ingresar un cliente"); return; } ((EntidadesCompartidas.Factura)Session[FACTURA]).Cliente = txtCliente.Text; ((EntidadesCompartidas.Factura)Session[FACTURA]).Lineas = (List<EntidadesCompartidas.LineaFactura>)Session[LINEAS]; Logica.ILogicaFactura lFactura = Logica.FabricaLogica.getLogicaFactura(); lFactura.ModificarFactura((EntidadesCompartidas.Factura)Session[FACTURA]); //Reseteamos los controles txtCliente.Text = ""; txtNroFactura.Text = ""; txtCantidad.Text = "1"; txtArtCodigo.Text = ""; Session[LINEAS] = null; btnModificar.Visible = false; btnEliminar2.Visible = false; btnGrabar.Visible = true; Alerta("Factura nro. " + ((EntidadesCompartidas.Factura)Session[FACTURA]).ID + " modificada correctamente"); Session[FACTURA] = null; CargarGrilla(); } catch (Exception ex) { Alerta("Modificar - Error: " + ex.Message); } }
protected void btnGrabar_Click(object sender, EventArgs e) { try { if (Session[LINEAS] == null) { Alerta("Necesita ingresar al menos un artículo"); return; } if (txtCliente.Text == "") { Alerta("Necesita ingresar un cliente"); return; } int id = 0; if (!(Int32.TryParse(txtNroFactura.Text, out id))) { Alerta("El id de factura debe ser un número"); return; } if (id <= 0) { Alerta("El id de factura debe ser mayor que 0"); return; } Logica.ILogicaFactura lFactura = Logica.FabricaLogica.getLogicaFactura(); EntidadesCompartidas.Factura facAux = lFactura.BuscarFactura(id); if (facAux != null) { Alerta("Ya existe una factura con ese Id"); return; } else { facAux = new EntidadesCompartidas.Factura(id, txtCliente.Text, DateTime.Now, (List<EntidadesCompartidas.LineaFactura>)Session[LINEAS]); } lFactura.AgregarFactura(facAux); //Reseteamos los controles txtCliente.Text = ""; txtNroFactura.Text = ""; txtCantidad.Text = "1"; txtArtCodigo.Text = ""; Session[LINEAS] = null; btnModificar.Visible = false; CargarGrilla(); Alerta("Factura generada correctamente"); } catch(Exception ex) { Alerta("Grabar - Error: " + ex.Message); } }