Beispiel #1
0
    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);
        }
    }
Beispiel #2
0
    protected void bntBuscarFactura_Click(object sender, EventArgs e)
    {
        try
        {
            Session[FACTURA] = null;
            Session[LINEAS] = null;

            btnEliminar2.Visible = false;
            btnModificar.Visible = false;
            btnGrabar.Visible = true;
           // btnAgregar.Visible = true;
            txtCliente.Text = "";

            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; }

            EntidadesCompartidas.Factura facAux = Logica.FabricaLogica.getLogicaFactura().BuscarFactura(Convert.ToInt32(txtNroFactura.Text));

            if (facAux == null) { Alerta("No se encontro la factura"); return; }

            txtCliente.Text = facAux.Cliente;
            btnEliminar2.Visible = true;
            btnModificar.Visible = true;
            btnGrabar.Visible = false;
           // btnAgregar.Visible = false;

            Session[FACTURA] = facAux;
            Session[LINEAS] = facAux.Lineas;
        }
        catch (Exception ex)
        {
            Alerta("Error: " + ex.Message);
        }
        finally
        {
            CargarGrilla();
        }
    }