protected override void SubmitAction()
        {
            this.Enabled = false;

            if (_producto == null)
            {
                PgMng.ShowInfoException(Library.Store.Resources.Messages.NO_PRODUCTO_SELECTED);

                _action_result = DialogResult.Ignore;
                return;
            }

            if ((_entity.CantidadKilos == 0) || (_entity.CantidadBultos == 0))
            {
                PgMng.ShowInfoException(Library.Store.Resources.Messages.NO_KILOS_BULTOS_SELECTED);

                _action_result = DialogResult.Ignore;
                return;
            }

            ProductoClienteInfo pci = _cliente.Productos.GetByProducto(_entity.OidProducto);

            if (pci != null)
            {
                if ((_entity.Precio < pci.Precio) && (pci.ETipoDescuento == ETipoDescuento.Precio))
                {
                    PgMng.ShowInfoException(Library.Invoice.Resources.Messages.PRECIO_VENTA_CLIENTE_INFERIOR);
                }
            }
            else if (_entity.Precio < _producto.PrecioVenta)
            {
                PgMng.ShowInfoException(Library.Invoice.Resources.Messages.PRECIO_VENTA_PRODUCTO_INFERIOR);
            }

            if (_entity.OidPartida != 0)
            {
                if (!_entity.FacturacionBulto)
                {
                    if (_partida.StockKilos - _entity.CantidadKilos < 0)
                    {
                        PgMng.ShowInfoException(Resources.Messages.STOCK_INSUFICIENTE + _partida.StockKilos.ToString());

                        _action_result = DialogResult.Ignore;
                        return;
                    }
                }
                else
                {
                    if (_partida.StockBultos - _entity.CantidadBultos < 0)
                    {
                        PgMng.ShowInfoException(Resources.Messages.BULTOS_INSUFICIENTES + _partida.StockBultos.ToString());
                        _action_result = DialogResult.Ignore;
                        return;
                    }
                }
            }

            if (_entity.Beneficio <= 0)
            {
                if (ProgressInfoMng.ShowQuestion(Resources.Messages.AVISO_PERDIDA) == DialogResult.No)
                {
                    _action_result = DialogResult.Ignore;
                    return;
                }
            }

            if (_entity.OidPartida != 0)
            {
                _partida.StockKilos  -= _entity.CantidadKilos;
                _partida.StockBultos -= _entity.CantidadBultos;
            }

            DoSubmitAction();

            _action_result = DialogResult.OK;
        }
        protected override void PrintAction()
        {
            PgMng.Reset(5, 1, Face.Resources.Messages.RETRIEVING_DATA, this);

            Library.Invoice.QueryConditions conditions = new Library.Invoice.QueryConditions();

            conditions.Cliente   = TodosCliente_CkB.Checked ? null : _cliente;
            conditions.Serie     = TodosSerie_CkB.Checked ? null : _serie;
            conditions.MedioPago = MedioPago_CB.SelectedValue != null ? (EMedioPago)(long)MedioPago_CB.SelectedValue : EMedioPago.Todos;
            conditions.FechaIni  = FInicial_DTP.Checked ? FInicial_DTP.Value : DateTime.MinValue;
            conditions.FechaFin  = FFinal_DTP.Checked ? FFinal_DTP.Value : DateTime.MaxValue;

            string filter = GetFilterValues();

            PgMng.Grow();

            OutputInvoiceList in_invoices = OutputInvoiceList.GetList(conditions, false);

            PgMng.Grow();
            ProductList products = ProductList.GetList(false);

            PgMng.Grow();
            ExpedienteList expedients = ExpedienteList.GetList(false);

            PgMng.FillUp();

            PgMng.Reset(in_invoices.Count + 2, 1, Face.Resources.Messages.RETRIEVING_DATA, this);

            Dictionary <long, ClientProductList> client_products = new Dictionary <long, ClientProductList>();

            foreach (OutputInvoiceInfo in_invoice in in_invoices)
            {
                in_invoice.LoadChilds(typeof(OutputInvoiceLine), false);

                decimal invoice_cost = 0;

                foreach (OutputInvoiceLineInfo line in in_invoice.ConceptoFacturas)
                {
                    ProductInfo product = products.GetItem(line.OidProducto);

                    if (product.BeneficioCero)
                    {
                        if (!client_products.ContainsKey(in_invoice.OidCliente))
                        {
                            client_products.Add(in_invoice.OidCliente, ClientProductList.GetByClientList(in_invoice.OidCliente, false));
#if TRACE
                            AppControllerBase.AppControler.Timer.Record("Productos del Cliente");
#endif
                        }
                        ProductoClienteInfo product_client = client_products[in_invoice.OidCliente].GetByProducto(line.OidProducto);

                        if (product_client != null)
                        {
                            invoice_cost += product_client.PrecioCompra;
                        }
                        else
                        {
                            invoice_cost += line.Subtotal;
                        }
                    }
                    else
                    {
                        if (line.OidPartida != 0)
                        {
                            ExpedientInfo expedient = expedients.GetItem(line.OidExpediente);

                            if (expedient != null)
                            {
                                if (expedient.Partidas == null)
                                {
                                    expedient.LoadExpenses(Estimated_CB.Checked);
#if TRACE
                                    AppControllerBase.AppControler.Timer.Record("Gastos del Expediente");
#endif
                                }

                                BatchInfo batch = expedient.Partidas.GetItem(line.OidPartida);
                                invoice_cost += line.CantidadKilos * batch.CosteNetoKg;
                            }
                            else
                            {
                                invoice_cost += line.CantidadKilos * product.PrecioCompra;
                            }
                        }
                        else
                        {
                            invoice_cost += (product != null) ? line.CantidadKilos * product.PrecioCompra : 0;
                        }
                    }
                }

                in_invoice.PrecioCoste = invoice_cost;
                in_invoice.Beneficio   = Decimal.Round(in_invoice.BaseImponible - in_invoice.PrecioCoste, 2);
                in_invoice.PBeneficio  = in_invoice.PrecioCoste != 0 ? Decimal.Round(((in_invoice.BaseImponible - in_invoice.PrecioCoste) * 100) / in_invoice.PrecioCoste, 2) : 0;

                PgMng.Grow();
            }

            client_products.Clear();

            PgMng.Grow(Face.Resources.Messages.BUILDING_REPORT);

            OutputInvoiceReportMng reportMng = new OutputInvoiceReportMng(AppContext.ActiveSchema, this.Text, filter);
            ReportClass            rpt       = reportMng.GetBenefitsReport(in_invoices);
            PgMng.FillUp();

            ShowReport(rpt);

            _action_result = DialogResult.Ignore;
        }
        protected override void SubmitAction()
        {
            if (_product == null)
            {
                PgMng.ShowInfoException(Library.Store.Resources.Messages.NO_PRODUCTO_SELECTED);

                _action_result = DialogResult.Ignore;
                return;
            }

            if ((_entity.CantidadKilos == 0) || (_entity.CantidadBultos == 0))
            {
                PgMng.ShowInfoException(Library.Store.Resources.Messages.NO_KILOS_BULTOS_SELECTED);

                _action_result = DialogResult.Ignore;
                return;
            }

            if (!_delivery.Rectificativo)
            {
                ProductoClienteInfo pci = (_delivery.EHolderType == ETipoEntidad.Cliente)
                                                                                                ? _client.Productos.GetByProducto(_entity.OidProducto)
                                                                                                : null;
                if (pci != null)
                {
                    if ((_entity.Precio < pci.Precio) && (pci.ETipoDescuento == ETipoDescuento.Precio))
                    {
                        PgMng.ShowInfoException(Library.Invoice.Resources.Messages.PRECIO_VENTA_CLIENTE_INFERIOR);
                    }
                }
                else if (_entity.Precio < _product.PrecioVenta)
                {
                    PgMng.ShowInfoException(Library.Invoice.Resources.Messages.PRECIO_VENTA_PRODUCTO_INFERIOR);
                }

                if (_entity.OidPartida != 0)
                {
                    if (!_entity.FacturacionBulto)
                    {
                        if (_batch.StockKilos - _entity.CantidadKilos < 0)
                        {
                            PgMng.ShowInfoException(Resources.Messages.STOCK_INSUFICIENTE + _batch.StockKilos.ToString());

                            _action_result = DialogResult.Ignore;
                            return;
                        }
                    }
                    else
                    {
                        if (_batch.StockBultos - _entity.CantidadBultos < 0)
                        {
                            PgMng.ShowInfoException(Resources.Messages.BULTOS_INSUFICIENTES + _batch.StockBultos.ToString());
                            _action_result = DialogResult.Ignore;
                            return;
                        }
                    }
                }

                if (_entity.Beneficio <= 0)
                {
                    if (ProgressInfoMng.ShowQuestion(Resources.Messages.AVISO_PERDIDA) == DialogResult.No)
                    {
                        _action_result = DialogResult.Ignore;
                        return;
                    }
                }

                if (_product.AvisarBeneficioMinimo &&
                    _entity.BeneficioKilo < (_product.PrecioCompra * _product.PBeneficioMinimo) / 100)
                {
                    if (ProgressInfoMng.ShowQuestion(Resources.Messages.AVISO_BENEFICIO_MINIMO) == DialogResult.No)
                    {
                        _action_result = DialogResult.Ignore;
                        return;
                    }
                }
            }
            else
            if (_entity.CantidadKilos > 0)
            {
                _entity.CantidadKilos = -_entity.CantidadKilos;
            }

            if (_entity.OidPartida != 0)
            {
                _batch.StockKilos  -= _entity.CantidadKilos;
                _batch.StockBultos -= _entity.CantidadBultos;
            }

            DoSubmitAction();

            _action_result = DialogResult.OK;
        }