public FrmDocumentoRelacionado(DocumentoRelacionado documentoRelacionado)
        {
            InitializeComponent();
            _documentoRelacionado = documentoRelacionado;
            documentoRelacionadoBindingSource.DataSource = _documentoRelacionado;
            documentoRelacionadoBindingSource.ResetBindings(false);

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

            toolOk.Click += (s, e) =>
            {
                documentoRelacionadoBindingSource.EndEdit();
                DialogResult = DialogResult.OK;
            };

            toolCancel.Click += (s, e) => DialogResult = DialogResult.Cancel;
        }
Example #2
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;
            }
        }