private void BtnGrabar_Click(object sender, EventArgs e)
        {
            if (ValidarDatos())
            {
                try
                {
                    var factura = new Factura
                    {
                        Fecha          = dtpFecha.Value,
                        Cliente        = (Cliente)cboCliente.SelectedItem,
                        TipoFactura    = (TipoFactura)cboTipoFact.SelectedItem,
                        FacturaDetalle = listaFacturaDetalle,
                        SubTotal       = double.Parse(txtSubtotal.Text),
                        Descuento      = double.Parse(txtDescuento.Text),
                        TipoTarjeta    = (TipoTarjeta)cboTipoTarjeta.SelectedItem,
                        Codigo         = int.Parse(txtCodigo.Text),
                        NroTarjeta     = int.Parse(txtNumero.Text),
                        // FormaPago = (FormaPago)cboForma.SelectedItem,
                    };

                    if (facturaService.ValidarDatos(factura))
                    {
                        facturaService.Crear(factura);

                        MessageBox.Show(string.Concat("La factura nro: ", factura.IdFactura, " se generó correctamente."), "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        InicializarFormulario();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error al registrar la factura! " + ex.Message + ex.StackTrace, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 2
0
        private void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                var factura = new Factura
                {
                    Fecha          = dtpFecha.Value,
                    NombreCliente  = txtNombreCliente.Text,
                    IdUsuario      = 1,
                    FacturaDetalle = listaFacturaDetalle,
                    SubTotal       = double.Parse(txtSubtotal.Text),
                    Descuento      = double.Parse(txtDescuento.Text)
                };

                if (facturaService.ValidarDatos(factura))
                {
                    facturaService.Crear(factura);

                    MessageBox.Show(string.Concat("La factura nro: ", factura.IdFactura, " se generó correctamente."), "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    InicializarFormulario();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al registrar la factura! " + ex.Message + ex.StackTrace, "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }