Example #1
0
        protected override void GetFormSourceData(long oid, object[] parameters)
        {
            ETipoEntidad holder_type = (ETipoEntidad)parameters[0];

            _entity = OutputDelivery.Get(oid, holder_type);
            _entity.BeginEdit();
        }
Example #2
0
        internal void Update(OutputDelivery parent)
        {
            try
            {
                this.RaiseListChangedEvents = false;

                SessionCode = parent.SessionCode;

                // update (thus deleting) any deleted child objects
                foreach (AlbaranTicket obj in DeletedList)
                {
                    obj.DeleteSelf(parent);
                }

                // now that they are deleted, remove them from memory too
                DeletedList.Clear();

                // add/update any current child objects
                foreach (AlbaranTicket obj in this)
                {
                    if (obj.IsNew)
                    {
                        obj.Insert(parent);
                    }
                    else
                    {
                        obj.Update(parent);
                    }
                }
            }
            finally
            {
                this.RaiseListChangedEvents = true;
            }
        }
        protected override bool SaveObject()
        {
            this.Datos.RaiseListChangedEvents = false;

            // do the save
            try
            {
                PgMng.Reset(6, 1, Library.Store.Resources.Messages.ACTUALIZANDO_STOCKS, this);

                OutputDelivery temp = _entity.Clone();
                temp.ApplyEdit();
                PgMng.Grow();

                _entity = temp.Save();
                _entity.ApplyEdit();
                PgMng.Grow();

                return(true);
            }
            catch (Exception ex)
            {
                CleanCache();
                PgMng.ShowInfoException(ex);
                return(false);
            }
            finally
            {
                this.Datos.RaiseListChangedEvents = true;
                PgMng.FillUp();
            }
        }
Example #4
0
        internal void DeleteSelf(OutputDelivery parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }

            try
            {
                SessionCode = parent.SessionCode;
                Session().Delete(Session().Get <OutputDeliveryInvoiceRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
Example #5
0
        internal void Update(OutputInvoice parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            this.OidFactura = parent.Oid;

            ValidationRules.CheckRules();

            if (!IsValid)
            {
                throw new iQValidationException(Library.Resources.Messages.GENERIC_VALIDATION_ERROR);
            }

            SessionCode = parent.SessionCode;
            OutputInvoiceLineRecord obj = Session().Get <OutputInvoiceLineRecord>(Oid);

            obj.CopyValues(Base.Record);
            Session().Update(obj);

            if (OidPartida == 0)
            {
                OutputDeliveries albaranes = OutputDeliveries.GetList(parent.GetAlbaranes(), true, true, parent.SessionCode);

                OutputDeliveryLine concepto = null;
                OutputDelivery     albaran  = null;

                foreach (OutputDelivery item in albaranes)
                {
                    albaran = item;

                    foreach (OutputDeliveryLine ca in item.Conceptos)
                    {
                        if (ca.Oid == OidConceptoAlbaran)
                        {
                            concepto = ca;
                            break;
                        }
                    }

                    if (concepto != null)
                    {
                        break;
                    }
                }

                if (concepto != null)
                {
                    concepto.CopyFrom(this);
                    albaran.CalculateTotal();
                }
            }

            MarkOld();
        }
 protected override void ApplyAuthorizationRules()
 {
     Tabla.Visible         = OutputDelivery.CanGetObject();
     Add_Button.Enabled    = OutputDelivery.CanAddObject();
     Edit_Button.Enabled   = OutputDelivery.CanEditObject();
     Delete_Button.Enabled = OutputDelivery.CanDeleteObject();
     Print_Button.Enabled  = OutputDelivery.CanGetObject();
     View_Button.Enabled   = OutputDelivery.CanGetObject();
 }
        protected override void GetFormSourceData(object[] parameters)
        {
            if (parameters[0] == null)
            {
                ETipoEntidad holder_type = (ETipoEntidad)parameters[1];

                _entity = OutputDelivery.New(holder_type);
                _entity.BeginEdit();

                switch (holder_type)
                {
                case ETipoEntidad.Cliente:
                {
                    if (parameters.Length >= 3)
                    {
                        _delivery_type = (ETipoAlbaranes)parameters[2];

                        if (_delivery_type == ETipoAlbaranes.Agrupados)
                        {
                            _entity.Contado = true;
                            _entity.GetNewCode(ETipoEntidad.Cliente, ETipoAlbaranes.Agrupados);
                            _entity.EMedioPago = EMedioPago.Efectivo;
                        }
                    }
                }
                break;

                case ETipoEntidad.WorkReport:
                {
                    //Se ha pasado como parametro en el constructor
                    if (parameters.Length >= 3)
                    {
                        _work_report = (WorkReportInfo)parameters[2];
                    }
                    //Venimos de un parte de trabajo y esta en cache
                    else if (Cache.Instance.Contains(typeof(WorkReport)))
                    {
                        _work_report = (Cache.Instance.Get(typeof(WorkReport)) as WorkReport).GetInfo();
                    }

                    _entity.OidHolder  = (_work_report != null) ? _work_report.Oid : 0;
                    _entity.EMedioPago = EMedioPago.Efectivo;
                    SerieInfo serie = SerieInfo.Get(Library.Invoice.ModulePrincipal.GetWorkDeliverySerieSetting(), false);
                    _entity.OidSerie = (serie != null) ? serie.Oid : 0;
                }
                break;
                }
            }
            else
            {
                _entity = (OutputDelivery)parameters[0];
                _entity.BeginEdit();
                SerieInfo serie = SerieInfo.Get(_entity.OidSerie, false);
                _entity.OidSerie = (serie != null) ? serie.Oid : 0;
            }
        }
        public DeliveryLinenAddForm(ETipoProducto productType, OutputDelivery delivery, SerieInfo serie, ClienteInfo client, Form parent)
            : base(productType, delivery, serie, client, parent)
        {
            InitializeComponent();

            this.Text = Resources.Labels.CONCEPTO_NEW_TITLE;

            // Va aquí porque si no peta en el padre porque _entity es nulo
            _entity.PropertyChanged += new PropertyChangedEventHandler(Entity_PropertyChanged);
        }
        public override void CopyObjectAction(long oid)
        {
            DeliveryAddForm form = new DeliveryAddForm(OutputDelivery.CloneAsNew(ActiveItem), this);

            AddForm(form);
            if (form.ActionResult == DialogResult.OK)
            {
                _entity = form.Entity;
            }
        }
        public override void OpenAddForm()
        {
            DeliveryAddForm form = new DeliveryAddForm(_holder_type, this);

            AddForm(form);
            if (form.ActionResult == DialogResult.OK)
            {
                _entity = form.Entity;
            }
        }
        public DeliveryLineUIForm(ETipoProducto tipoProducto, OutputDelivery albaran, SerieInfo serie, ClienteInfo cliente, Form parent)
            : base(true, parent)
        {
            InitializeComponent();

            _delivery     = albaran;
            _serie        = serie;
            _client       = cliente;
            _product_type = tipoProducto;
            SetFormData();
        }
        public DeliveryLineEditForm(ETipoProducto tipo, OutputDelivery delivery, SerieInfo serie, ClienteInfo cliente, OutputDeliveryLine line, Form parent)
            : base(tipo, delivery, serie, cliente, parent)
        {
            InitializeComponent();

            this.Text = Resources.Labels.CONCEPTO_EDIT_TITLE;

            _entity = line;

            RefreshMainData();

            // Va aquí porque si no peta en el padre porque _entity es nulo
            _entity.PropertyChanged += new PropertyChangedEventHandler(Entity_PropertyChanged);
        }
        public override void OpenEditForm()
        {
            if (ActiveItem.Facturado)
            {
                PgMng.ShowInfoException("No es posible modificar un albarán facturado.");

                _action_result = DialogResult.Ignore;
                return;
            }

            DeliveryEditForm form = new DeliveryEditForm(ActiveOID, ActiveItem.EHolderType, this);

            if (form.Entity != null)
            {
                AddForm(form);
                _entity = form.Entity;
            }
        }
        public OutputDeliveryLine CopyItem(OutputDelivery parent, OutputDeliveryLineInfo concepto)
        {
            OutputDeliveryLine item;

            this.NewItem(OutputDeliveryLine.NewChild(parent, concepto));
            item     = this[Count - 1];
            item.Oid = item.Oid;

            if (concepto.OidPartida != 0)
            {
                //Stock stock = item.Stocks.NewItem(item);
                //stock.Oid = concepto.Stocks[0].Oid;
            }
            item.MarkItemOld();
            item.MarkItemDirty();

            return(item);
        }
        internal void Update(OutputDelivery parent)
        {
            try
            {
                this.RaiseListChangedEvents = false;

                SessionCode = parent.SessionCode;

                LoadLibroGanadero();

                // update (thus deleting) any deleted child objects
                foreach (OutputDeliveryLine obj in DeletedList)
                {
                    obj.DeleteSelf(parent);
                }

                // now that they are deleted, remove them from memory too
                DeletedList.Clear();

                // add/update any current child objects
                foreach (OutputDeliveryLine obj in this)
                {
                    if (obj.IsNew)
                    {
                        obj.Insert(parent);
                    }
                    else
                    {
                        obj.Update(parent);
                    }
                }
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }
            finally
            {
                this.RaiseListChangedEvents = true;
            }
        }
Example #16
0
        internal void Insert(OutputDelivery parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidAlbaran = parent.Oid;

            try
            {
                parent.Session().Save(Base.Record);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
Example #17
0
        /// <summary>
        /// Borra un registro de la base de datos.
        /// </summary>
        /// <param name="parent">Objeto padre</param>
        /// <remarks>Borrado inmediato<remarks/>
        internal void DeleteSelf(WorkReport parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            // if we're new then don't update the database
            if (this.IsNew)
            {
                return;
            }

            if (EEntityType == ETipoEntidad.OutputDelivery)
            {
                OutputDelivery.Delete(OidResource, ETipoEntidad.WorkReport, parent.SessionCode);
            }

            SessionCode = parent.SessionCode;
            Session().Delete(Session().Get <WorkReportResourceRecord>(Oid));

            MarkNew();
        }
Example #18
0
        protected override void AddDeliveryLineAction()
        {
            if (_entity.OidExpedient == 0)
            {
                PgMng.ShowInfoException(Resources.Messages.SELECT_HOLDER);
                return;
            }

            DeliveryAddForm form = new DeliveryAddForm(ETipoEntidad.WorkReport, this);

            form.ShowDialog();

            if (form.ActionResult == DialogResult.OK)
            {
                OutputDelivery item = form.Entity;

                if (_entity.Lines.GetItem(item) == null)
                {
                    _entity.Lines.NewItem(_entity, item);
                }
            }

            UpdateWorkReportAction();
        }
Example #19
0
        internal void Update(OutputDelivery parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            OidAlbaran = parent.Oid;

            try
            {
                SessionCode = parent.SessionCode;
                OutputDeliveryInvoiceRecord obj = Session().Get <OutputDeliveryInvoiceRecord>(Oid);
                obj.CopyValues(Base.Record);
                Session().Update(obj);
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkOld();
        }
Example #20
0
 public static string SELECT(OutputDelivery source)
 {
     return(SELECT(new QueryConditions {
         OutputDelivery = source.GetInfo(false)
     }));
 }
 public DeliveryAddForm(OutputDelivery entity, Form parent)
     : this(new object[2] {
     entity, ETipoEntidad.Cliente
 }, parent)
 {
 }
 public static string SELECT(OutputDelivery albaran)
 {
     return(SELECT(new QueryConditions {
         OutputDelivery = albaran.GetInfo(false)
     }));
 }
 public OutputDeliveryLine NewItem(OutputDelivery parent)
 {
     this.NewItem(OutputDeliveryLine.NewChild(parent));
     return(this[Count - 1]);
 }
 public OutputDeliveryLine NewItem(OutputDelivery parent, OutputDeliveryLineInfo concepto)
 {
     this.NewItem(OutputDeliveryLine.NewChild(parent, concepto));
     return(this[Count - 1]);
 }
 public override void DeleteAction()
 {
     OutputDelivery.Delete(ActiveOID, ActiveItem.EHolderType);
     _action_result = DialogResult.OK;
 }
        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)
                {
                    OutputDeliveryList listA = OutputDeliveryList.GetList(_filter_results);
                    listA.AddItem(_entity.GetInfo(false));
                    _filter_results = listA.GetSortedList();
                }
                break;

            case molAction.CustomAction1:
            case molAction.CustomAction2:
            case molAction.Edit:
            case molAction.Lock:
            case molAction.Unlock:

                if (_selected != null)
                {
                    List <OutputDeliveryInfo> entities = (List <OutputDeliveryInfo>)_selected;
                    foreach (OutputDeliveryInfo item in entities)
                    {
                        List.GetItem(item.Oid).CopyFrom(item);
                        if (FilterType == IFilterType.Filter)
                        {
                            OutputDeliveryList list   = OutputDeliveryList.GetList(_filter_results);
                            OutputDeliveryInfo entity = list.GetItem(item.Oid);
                            if (entity != null)
                            {
                                entity.CopyFrom(item);
                            }
                            _filter_results = list.GetSortedList();
                        }
                    }
                }

                if (_entity == null)
                {
                    return;
                }
                ActiveItem.CopyFrom(_entity);

                break;

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

            RefreshSources();
            if (_entity != null)
            {
                Select(_entity.Oid);
            }
            _entity = null;
        }
Example #27
0
        /// <summary>
        /// Crea los conceptos de factura asociados a un albarán
        /// </summary>
        /// <param name="source"></param>
        public virtual void Compact(OutputInvoice invoice)
        {
            if (this.Count == 0)
            {
                return;
            }

            OutputDelivery main_albaran = null;
            Cash           caja         = null;

            try
            {
                List <long> oid_list = new List <long>();

                foreach (AlbaranFactura item in this)
                {
                    oid_list.Add(item.OidAlbaran);
                }

                OutputDeliveryList albaranes = OutputDeliveryList.GetList(oid_list, true);
                main_albaran = OutputDelivery.Get(oid_list[0], true, invoice.SessionCode);

                foreach (AlbaranFactura af in this)
                {
                    if (af.OidAlbaran == main_albaran.Oid)
                    {
                        continue;
                    }

                    OutputDeliveryInfo source = albaranes.GetItem(af.OidAlbaran);
                    main_albaran.Merge(source);
                }

                main_albaran.Compact();

                SortedBindingList <AlbaranFactura> sorted_list = this.GetSortedList("CodigoAlbaran", ListSortDirection.Ascending);
                OutputDeliveryInfo first_albaran = OutputDeliveryInfo.Get(sorted_list[0].OidAlbaran, ETipoEntidad.Cliente, false);

                main_albaran.CopyFrom(invoice);
                main_albaran.Codigo = first_albaran.Codigo;
                main_albaran.Serial = first_albaran.Serial;
                main_albaran.Save();

                ToDelete = new List <OutputDeliveryInfo>();

                for (int i = 1; i < oid_list.Count; i++)
                {
                    Remove(GetItemByAlbaran(oid_list[i]).Oid);
                    ToDelete.Add(albaranes.GetItem(oid_list[i]));
                }

                CashLine.DeleteByAlbaranList(albaranes.GetListInfo(), ModulePrincipal.GetCajaTicketsSetting());
                Ticket.DeleteFromList(albaranes.GetListInfo());

                //Actualizamos la caja de Tickets
                caja = Cash.Get(ModulePrincipal.GetCajaTicketsSetting(), true, invoice.SessionCode);
                caja.UpdateSaldo();
                caja.SaveAsChild();

                AlbaranFactura ab = GetItemByAlbaran(main_albaran.Oid);
                ab.CodigoAlbaran = main_albaran.Codigo;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                Cache.Instance.Remove(typeof(ClienteList));
                Cache.Instance.Remove(typeof(ProductList));
            }
        }