protected override void RefreshMainData()
        {
            _albaranes = InputDeliveryList.GetListByFactura(true, _entity.Oid).GetListInfo();
            PgMng.Grow();

            base.RefreshMainData();
        }
        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();
                }
            }
        }
        protected override void EliminarAlbaranAction()
        {
            if (Entity.AlbaranesFacturas.Count == 0)
            {
                return;
            }

            InputDeliverySelectForm form = new InputDeliverySelectForm(this, InputDeliveryList.GetList(_albaranes));

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                List <InputDeliveryInfo> results = form.Selected as List <InputDeliveryInfo>;

                foreach (InputDeliveryInfo item in results)
                {
                    _entity.Extract(item);
                    _albaranes.Remove(item);
                }
            }

            if (_entity.AlbaranesFacturas.Count == 0)
            {
                Serie_BT.Enabled = true;
            }

            Datos.ResetBindings(false);
            RefreshLineas();
        }
Ejemplo n.º 4
0
        public InputDeliverySelectForm(Form parent, InputDeliveryList lista)
            : base(true, parent, ETipoAlbaranes.Todos, ETipoAcreedor.Todos, lista)
        {
            InitializeComponent();
            _view_mode = molView.Select;

            _action_result = DialogResult.Cancel;
        }
        public override void UpdateList()
        {
            switch (_current_action)
            {
            case molAction.Add:
            case molAction.Copy:
                if (_entity == null)
                {
                    return;
                }
                if (List.GetItem(_entity.Oid) != null)
                {
                    return;
                }
                List.AddItem(_entity.GetInfo(false));
                if (FilterType == IFilterType.Filter)
                {
                    InputDeliveryList listA = InputDeliveryList.GetList(_filter_results);
                    listA.AddItem(_entity.GetInfo(false));
                    _filter_results = listA.GetSortedList();
                }
                break;

            case molAction.Edit:
            case molAction.Lock:
            case molAction.Unlock:
                if (_entity == null)
                {
                    return;
                }
                ActiveItem.CopyFrom(_entity);
                break;

            case molAction.Delete:
                if (ActiveItem == null)
                {
                    return;
                }
                List.RemoveItem(ActiveOID);
                if (FilterType == IFilterType.Filter)
                {
                    InputDeliveryList listD = InputDeliveryList.GetList(_filter_results);
                    listD.RemoveItem(ActiveOID);
                    _filter_results = listD.GetSortedList();
                }
                break;
            }

            RefreshSources();
            if (_entity != null)
            {
                Select(_entity.Oid);
            }
            _entity = null;
        }
        protected override void RefreshMainData()
        {
            PgMng.Grow(string.Empty, "InputDelivery");

            _selectedOid = ActiveOID;

            switch (DataType)
            {
            case EntityMngFormTypeData.Default:
                switch (_tipo)
                {
                case ETipoAlbaranes.Todos:
                    if (moleQule.Common.ModulePrincipal.GetUseActiveYear())
                    {
                        List = InputDeliveryList.GetList(false, _tipo_acreedor, moleQule.Common.ModulePrincipal.GetActiveYear().Year);
                    }
                    else
                    {
                        List = InputDeliveryList.GetList(false);
                    }
                    break;

                case ETipoAlbaranes.Facturados:
                    if (moleQule.Common.ModulePrincipal.GetUseActiveYear())
                    {
                        List = InputDeliveryList.GetFacturados(false, _tipo_acreedor, moleQule.Common.ModulePrincipal.GetActiveYear().Year);
                    }
                    else
                    {
                        List = InputDeliveryList.GetFacturados(false);
                    }
                    break;

                case ETipoAlbaranes.NoFacturados:
                    if (moleQule.Common.ModulePrincipal.GetUseActiveYear())
                    {
                        List = InputDeliveryList.GetNoFacturados(true, _tipo_acreedor, _oid_cliente, _oid_serie, moleQule.Common.ModulePrincipal.GetActiveYear().Year);
                    }
                    else
                    {
                        List = InputDeliveryList.GetNoFacturados(true, _tipo_acreedor, _oid_cliente, _oid_serie);
                    }
                    break;
                }
                break;

            case EntityMngFormTypeData.ByParameter:
                _sorted_list = List.GetSortedList();
                break;
            }
            PgMng.Grow(string.Empty, "Lista de AlbaranProveedores");
        }
        public InputDeliveryMngForm(bool is_modal, Form parent, ETipoAlbaranes tipo, ETipoAcreedor tipo_acreedor, InputDeliveryList lista)
            : base(is_modal, parent, lista)
        {
            InitializeComponent();
            SetView(molView.Normal);

            // Parche para poder abrir el formulario en modo diseño y no perder la configuracion de columnas
            DatosLocal_BS    = Datos;
            Tabla.DataSource = DatosLocal_BS;

            SetMainDataGridView(Tabla);
            Datos.DataSource = InputDeliveryList.NewList().GetSortedList();
            SortProperty     = Fecha.DataPropertyName;
            SortDirection    = ListSortDirection.Descending;

            _tipo          = tipo;
            _tipo_acreedor = tipo_acreedor;

            this.Text = Resources.Labels.ALBARAN_TODOS;
        }
        public override void PrintList()
        {
            PgMng.Reset(4, 1, Face.Resources.Messages.LOADING_DATA, this);

            ProviderBaseList acreedores = ProviderBaseList.GetList(false);

            PgMng.Grow();

            SerieList series = SerieList.GetList(false);

            PgMng.Grow();

            InputDeliveryReportMng rptMng = new InputDeliveryReportMng(AppContext.ActiveSchema, Text, FilterValues);

            AlbaranRecibidoListRpt report = rptMng.GetListReport(InputDeliveryList.GetList(Datos.DataSource as IList <InputDeliveryInfo>),
                                                                 series,
                                                                 acreedores);

            PgMng.FillUp();

            ShowReport(report);
        }
        protected bool AddAlbaran()
        {
            if (_entity.OidSerie == 0)
            {
                PgMng.ShowInfoException(Resources.Messages.NO_SERIE_SELECTED);
                return(false);
            }

            InputDeliveryList list = null;

            list = InputDeliveryList.GetNoFacturados(false, _entity);

            //Quitamos de la lista los ya añadidos
            List <InputDeliveryInfo> lista = new List <InputDeliveryInfo>();

            foreach (InputDeliveryInfo item in list)
            {
                if (_entity.AlbaranesFacturas.GetItemByAlbaran(item.Oid) == null)
                {
                    lista.Add(item);
                }
            }

            InputDeliveryList lista_completa = InputDeliveryList.GetListByAcreedor(false, _entity.ETipoAcreedor, _entity.OidAcreedor);

            //Añadimos a lista los eliminados
            foreach (AlbaranFacturaProveedor item in _albaranes_factura)
            {
                if (_entity.AlbaranesFacturas.GetItemByAlbaran(item.OidAlbaran) == null)
                {
                    lista.Add(lista_completa.GetItem(item.OidAlbaran));
                }
            }

            InputDeliverySelectForm form = new InputDeliverySelectForm(this, InputDeliveryList.GetList(lista));

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                _results = form.Selected as List <InputDeliveryInfo>;

                if (_entity.Rectificativa && (_results.Count > 1))
                {
                    PgMng.ShowInfoException("No es posible asignar varios albaranes a una factura rectificativa.");
                    return(false);
                }

                foreach (InputDeliveryInfo item in _results)
                {
                    if (item.OidAcreedor != _results[0].OidAcreedor)
                    {
                        PgMng.ShowInfoException("No es posible asignar albaranes de acreedores distintos a una misma Factura.");
                        return(false);
                    }
                }

                /*foreach (InputDeliveryInfo item in _results)
                 * {
                 *  if (item.PIRPF != _results[0].PIRPF)
                 *  {
                 *      PgMng.ShowInfoException(Resources.Messages.ALBARANES_CON_IRPF_DISTINTO);
                 *      return false;
                 *  }
                 * }*/

                _back_job = BackJob.AddAlbaran;
                //PgMng.StartBackJob(this);

                DoAddAlbaran(null);

                if (Result == BGResult.OK)
                {
                    Serie_BT.Enabled = false;
                    Datos.ResetBindings(false);
                }
            }

            return(false);
        }