public virtual void CrearFacturaAction()
        {
            InputDeliverySelectForm form = new InputDeliverySelectForm(this, InputDeliveryList.GetNoFacturados(true));

            form.ShowDialog(this);

            if (form.DialogResult == DialogResult.OK)
            {
                try
                {
                    PgMng.Reset(4, 1, Resources.Messages.GENERANDO_FACTURAS, this);
                    List <InputDeliveryInfo> deliveries = form.Selected as List <InputDeliveryInfo>;
                    PgMng.Grow();

                    InputInvoices invoices = InputInvoices.NewList();
                    invoices.NewItems(deliveries);
                    PgMng.Grow();

                    invoices.Save();
                    invoices.CloseSession();

                    _selected      = deliveries;
                    _action_result = DialogResult.OK;
                }
                catch (Exception ex)
                {
                    PgMng.ShowInfoException(ex);
                }
                finally
                {
                    PgMng.FillUp();
                    RefreshList();
                }
            }
        }
        public static void RellenaAlbaranesEnFacturas()
        {
            Library.Store.QueryConditions conditions = new Library.Store.QueryConditions
            {
                FechaIni = DateAndTime.FirstDay(2010),
                FechaFin = DateAndTime.LastDay(2010)
            };

            InputInvoices list_p = InputInvoices.GetList(conditions, false);

            foreach (InputInvoice item in list_p)
            {
                item.LoadChilds(typeof(AlbaranFacturaProveedor), false);
                item.SetAlbaranes();
            }

            list_p.Save();
            list_p.CloseSession();
        }
        public virtual void ExportInputInvoices()
        {
            InputInvoices invoices = null;

            try
            {
                _store_conditions.Orders.Clear();
                _store_conditions.Orders.NewOrder("Acreedor", System.ComponentModel.ListSortDirection.Ascending, typeof(InputInvoice));
                _store_conditions.Orders.NewOrder("Fecha", System.ComponentModel.ListSortDirection.Ascending, typeof(InputInvoice));

                _input_invoices = InputInvoiceList.GetList(_store_conditions, true);
                _providers      = (_providers == null) ? ProviderBaseList.GetList(false) : _providers;

                foreach (InputInvoiceInfo item in _input_invoices)
                {
                    LineaRegistro lr = _registry.LineaRegistros.NewItem(_registry, item);

                    BuildInputInvoiceAccountingEntry(item, lr);
                    BuildTaxBookSoportadoAccountingEntry(item);

                    _accounting_entry++;
                }

                //Cambiamos el estado de las facturas contabilizadas
                invoices = InputInvoices.GetList(_store_conditions, false);

                foreach (InputInvoice item in invoices)
                {
                    item.LoadChilds(typeof(InputInvoiceLine), false);
                }

                foreach (InputInvoice item in invoices)
                {
                    if (item.EEstado == EEstado.Anulado)
                    {
                        continue;
                    }

                    if (item.EEstado != EEstado.Exportado)
                    {
                        item.EEstado = EEstado.Exportado;
                    }
                }

                invoices.Save();
            }
            catch (iQException ex)
            {
                _registry = null;
                throw ex;
            }
            catch (Exception ex)
            {
                _registry = null;
                throw ex;
            }
            finally
            {
                if (invoices != null)
                {
                    invoices.CloseSession();
                }
            }
        }