public FrmDetalleDocumento(DetalleDocumento detalle, DocumentoElectronico documento)
        {
            InitializeComponent();
            _detalle   = detalle;
            _documento = documento;

            detalleDocumentoBindingSource.DataSource = detalle;
            detalleDocumentoBindingSource.ResetBindings(false);

            Load += (s, e) =>
            {
                using (var ctx = new OpenInvoicePeruDb())
                {
                    tipoImpuestoBindingSource.DataSource = ctx.TipoImpuestos.ToList();
                    tipoImpuestoBindingSource.ResetBindings(false);

                    tipoPrecioBindingSource.DataSource = ctx.TipoPrecios.ToList();
                    tipoPrecioBindingSource.ResetBindings(false);
                }
            };
            decimal sumar = 0;

            sumar = documento.Items.Count() + 1;
            idNumericUpDown.Value = (sumar);
        }
예제 #2
0
        private void btnDuplicar_Click(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                var registro = detallesBindingSource.Current as DetalleDocumento;
                if (registro == null)
                {
                    throw new ArgumentNullException(nameof(registro));
                }

                var copia = new DetalleDocumento
                {
                    Id                = registro.Id,
                    Cantidad          = registro.Cantidad,
                    CodigoItem        = registro.CodigoItem,
                    Descripcion       = registro.Descripcion,
                    PrecioUnitario    = registro.PrecioUnitario,
                    PrecioReferencial = registro.PrecioReferencial,
                    UnidadMedida      = registro.UnidadMedida,
                    Impuesto          = registro.Impuesto,
                    ImpuestoSelectivo = registro.ImpuestoSelectivo,
                    TipoImpuesto      = registro.TipoImpuesto,
                    TipoPrecio        = registro.TipoPrecio,
                    TotalVenta        = registro.TotalVenta,
                    Suma              = registro.Suma,
                    OtroImpuesto      = registro.OtroImpuesto
                };

                copia.Id = copia.Id + 1;
                _documento.Items.Add(copia);

                CalcularTotales();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
예제 #3
0
        private void btnAgregar_Click_1(object sender, EventArgs e)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                switch (tbPaginas.SelectedIndex)
                {
                case 0:
                    var detalle = new DetalleDocumento();

                    using (var frm = new FrmDetalleDocumento(detalle, _documento))
                    {
                        if (frm.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }

                        _documento.Items.Add(detalle);

                        CalcularTotales();
                    }
                    break;

                case 1:
                    var datoAdicional = new DatoAdicional();
                    using (var frm = new FrmDatosAdicionales(datoAdicional))
                    {
                        if (frm.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }

                        _documento.DatoAdicionales.Add(datoAdicional);
                    }
                    break;

                case 2:
                    var documentoRelacionado = new DocumentoRelacionado();
                    using (var frm = new FrmDocumentoRelacionado(documentoRelacionado))
                    {
                        if (frm.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }

                        _documento.Relacionados.Add(documentoRelacionado);
                    }
                    break;

                case 3:
                    var discrepancia = new Discrepancia();
                    using (var frm = new FrmDiscrepancia(discrepancia, _documento.TipoDocumento))
                    {
                        if (frm.ShowDialog(this) != DialogResult.OK)
                        {
                            return;
                        }

                        _documento.Discrepancias.Add(discrepancia);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                documentoElectronicoBindingSource.ResetBindings(false);
                Cursor.Current = Cursors.Default;
            }
        }