internal void Update(InputDelivery parent)
        {
            this.RaiseListChangedEvents = false;

            // update (thus deleting) any deleted child objects
            foreach (AlbaranFacturaProveedor 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 (AlbaranFacturaProveedor obj in this)
            {
                if (obj.IsNew)
                {
                    obj.Insert(parent);
                }
                else
                {
                    obj.Update(parent);
                }
            }

            this.RaiseListChangedEvents = true;
        }
        /// <summary>
        /// Builds a AlbaranProveedorList from IList<!--<AlbaranProveedor>--> and retrieve AlbaranProveedorInfo Childs from DB
        /// </summary>
        /// <param name="list"></param>
        /// <returns>AlbaranProveedorList</returns>
        public static InputDeliveryList GetChildList(IList <InputDelivery> list)
        {
            InputDeliveryList flist = new InputDeliveryList();

            if (list != null)
            {
                int        sessionCode = InputDelivery.OpenSession();
                CriteriaEx criteria    = null;

                flist.IsReadOnly = false;

                foreach (InputDelivery item in list)
                {
                    criteria = InputDeliveryLine.GetCriteria(sessionCode);
                    criteria.AddEq("OidAlbaran", item.Oid);
                    item.Conceptos = InputDeliveryLines.GetChildList(criteria.List <InputDeliveryLine>());

                    flist.AddItem(item.GetInfo());
                }

                flist.IsReadOnly = true;

                InputDelivery.CloseSession(sessionCode);
            }

            return(flist);
        }
Example #3
0
        internal void DeleteSelf(InputDelivery 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 <InputDeliveryInvoiceRecord>(Oid));
            }
            catch (Exception ex)
            {
                iQExceptionHandler.TreatException(ex);
            }

            MarkNew();
        }
        internal void UpdateTipo(ETipoAcreedor oldProviderType)
        {
            CriteriaEx criteria = Proveedor.GetCriteria(SessionCode);

            QueryConditions conditions = new QueryConditions
            {
                Acreedor     = this.GetInfo(false),
                TipoAcreedor = new ETipoAcreedor[1] {
                    oldProviderType
                },
                PaymentType = ETipoPago.Factura
            };

            criteria.Query = InputDelivery.UPDATE_TIPO(conditions);
            ExecuteSQL(criteria);

            criteria.Query = InputInvoiceSQL.UPDATE_TIPO(conditions);
            ExecuteSQL(criteria);

            criteria.Query = ProductoProveedor.UPDATE_TIPO(conditions);
            ExecuteSQL(criteria);

            //PagoFactura antes que Pago porque si modificamos el tipo del pago antes luego no coinciden
            criteria.Query = TransactionPayment.UPDATE_TIPO(conditions);
            ExecuteSQL(criteria);

            criteria.Query = Payment.UPDATE_TIPO(conditions);
            ExecuteSQL(criteria);
        }
Example #5
0
        protected override void GetFormSourceData(long oid, object[] parameters)
        {
            ETipoAcreedor tipo = (ETipoAcreedor)parameters[0];

            _entity       = InputDelivery.Get(oid, tipo);
            _deliveryType = _entity.Contado ? ETipoAlbaranes.Agrupados : ETipoAlbaranes.Todos;
            _entity.BeginEdit();
        }
        public override void OpenAddForm()
        {
            InputDeliveryAddForm form = new InputDeliveryAddForm(this, _tipo);

            AddForm(form);
            if (form.ActionResult == DialogResult.OK)
            {
                _entity = form.Entity;
            }
        }
        public override void CopyObjectAction(long oid)
        {
            InputDeliveryAddForm form = new InputDeliveryAddForm(InputDelivery.CloneAsNew(ActiveItem), this);

            AddForm(form);
            if (form.ActionResult == DialogResult.OK)
            {
                _entity = form.Entity;
            }
        }
Example #8
0
        /// Constructor
        /// </summary>
        public InputDeliveryLineUIForm(InputDeliveryLine line, InputDelivery delivery, SerieInfo serie, IAcreedorInfo provider, Form parent)
            : base(true, parent)
        {
            InitializeComponent();

            _entity   = line;
            _delivery = delivery;
            _serie    = serie;
            _provider = provider;
        }
Example #9
0
        public Batch NewItem(Almacen parent, Expedient expedient, InputDelivery delivery, InputDeliveryLine source)
        {
            Batch item = Batch.NewChild(parent, expedient, delivery, source);

            this.AddItem(item);
            if (MaxSerial == 0)
            {
                ResetMaxSerial(item.OidProducto, delivery.Fecha.Year);
            }
            SetNextCode(item);
            item.FechaCompra = item.FechaCompra.AddSeconds(item.Serial);

            //Entrada de stock asociada a la partida
            Stock stock = parent.Stocks.NewItem(this[Count - 1], ETipoStock.Compra);

            stock.Inicial            = true;
            stock.Kilos              = source.CantidadKilos;
            stock.Bultos             = source.CantidadBultos;
            stock.OidKit             = source.OidKit;
            stock.OidAlbaran         = delivery.Oid;
            stock.OidConceptoAlbaran = source.Oid;
            stock.OidLineaPedido     = source.OidLineaPedido;
            stock.OidExpediente      = source.OidExpediente;
            stock.Fecha              = delivery.Fecha;
            stock.Observaciones      = String.Format(Resources.Messages.ENTRADA_POR_ALBARAN, delivery.Codigo);

            if (expedient != null)
            {
                switch (expedient.ETipoExpediente)
                {
                //Cabeza de ganado para expedientes de Ganado
                case ETipoExpediente.Ganado:
                    item.KilosIniciales  = 1;
                    item.BultosIniciales = 1;
                    //Cabeza cabeza = expediente.Cabezas.NewItem(expediente);
                    //cabeza.CopyFrom(item);
                    //cabeza.Observaciones = source.Concepto;
                    break;

                //Maquina para expedientes de Maquinaria
                case ETipoExpediente.Maquinaria:
                    item.KilosIniciales  = 1;
                    item.BultosIniciales = 1;
                    Maquinaria maquina = expedient.Maquinarias.NewItem(expedient);
                    maquina.CopyFrom(this[Count - 1]);
                    maquina.Observaciones = source.Concepto;
                    item.Machine          = maquina;
                    break;
                }

                expedient.TipoMercancia = item.Producto;
            }

            return(item);
        }
        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;
        }
        private static InputDeliveryList GetList(bool childs, string query)
        {
            CriteriaEx criteria = InputDelivery.GetCriteria(InputDelivery.OpenSession());

            criteria.Childs = childs;

            criteria.Query = query;
            InputDeliveryList list = DataPortal.Fetch <InputDeliveryList>(criteria);

            CloseSession(criteria.SessionCode);
            return(list);
        }
Example #12
0
        public static string SELECT(InputDelivery delivery)
        {
            string query;

            QueryConditions conditions = new QueryConditions {
                InputDelivery = delivery.GetInfo(false)
            };

            query = InputDeliveryLineSQL.SELECT(conditions, true);

            return(query);
        }
Example #13
0
 protected override void GetFormSourceData(object[] parameters)
 {
     if (parameters[0] == null)
     {
         _deliveryType = (ETipoAlbaranes)parameters[1];
         _entity       = InputDelivery.New(_deliveryType);
         _entity.BeginEdit();
     }
     else
     {
         _entity = (InputDelivery)parameters[0];
         _entity.BeginEdit();
     }
 }
        internal void Update(InputInvoice 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(moleQule.Resources.Messages.GENERIC_VALIDATION_ERROR);
            }

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

            long oid_exp_old = obj.OidExpediente;

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

            if ((OidExpediente != 0) && (parent.OidExpediente != OidExpediente))
            {
                Store.Expedient.Get(OidExpediente, false, true, parent.SessionCode);
            }

            if ((oid_exp_old != 0) && (OidExpediente != oid_exp_old))
            {
                Store.Expedient.Get(oid_exp_old, false, true, parent.SessionCode);

                InputDeliveryLineInfo ca = InputDeliveryLineInfo.Get(OidConceptoAlbaran, false);

                if (ca.OidExpediente != OidExpediente)
                {
                    InputDelivery albaran = InputDelivery.Get(ca.OidAlbaran, ETipoAcreedor.Todos, true, SessionCode);

                    albaran.Conceptos.GetItem(ca.Oid).OidExpediente = OidExpediente;

                    albaran.SaveAsChild();
                }
            }

            MarkOld();
        }
        /// <summary>
        /// Retrieve the complete list from db
        /// </summary>
        /// <param name="get_childs">retrieving the childs</param>
        /// <returns>AlbaranProveedorList</returns>
        public static InputDeliveryList GetChildList(bool childs)
        {
            CriteriaEx criteria = InputDelivery.GetCriteria(InputDelivery.OpenSession());

            criteria.Childs = childs;

            if (nHManager.Instance.UseDirectSQL)
            {
                criteria.Query = SELECT();
            }

            InputDeliveryList list = DataPortal.Fetch <InputDeliveryList>(criteria);

            CloseSession(criteria.SessionCode);
            return(list);
        }
        public override void OpenEditForm()
        {
            if (ActiveItem.Facturado)
            {
                PgMng.ShowInfoException("No es posible modificar un albarán facturado.");

                _action_result = DialogResult.Ignore;
                return;
            }

            InputDeliveryEditForm form = new InputDeliveryEditForm(ActiveOID, this, ActiveItem.ETipoAcreedor);

            if (form.Entity != null)
            {
                AddForm(form);
                _entity = form.Entity;
            }
        }
        static void Main(string[] args)
        {
            //Mapper.Initialize(cfg => cfg.AddProfile<InputToOutputProfile>());
            Mapper.Initialize(cfg => cfg.AddProfiles(typeof(Program))); //  Busca todos los profiles en el Assembly

            InputOrder inputOrder = InputOrder.BuildInputOrder();

            Console.WriteLine(JsonConvert.SerializeObject(inputOrder, Formatting.Indented));

            Console.ReadKey();
            OutputOrder   outputOrder   = Mapper.Map <OutputOrder>(inputOrder, opt => opt.Items.Add("IsPayByCard", false));
            InputDelivery inputDelivery = InputDelivery.BuildInputDelivery();

            Mapper.Map(inputDelivery, outputOrder);
            Console.WriteLine(JsonConvert.SerializeObject(outputOrder, Formatting.Indented));

            //List<FlatOutput> outputs = Mapper.Map<List<FlatOutput>>(inputOrder);
            //Console.WriteLine(JsonConvert.SerializeObject(outputs, Formatting.Indented));

            Console.ReadKey();
        }
Example #18
0
        internal void Insert(InputDelivery 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 #19
0
        internal void Update(InputDelivery parent)
        {
            try
            {
                this.RaiseListChangedEvents = false;

                SessionCode = parent.SessionCode;

                LoadLibroGanadero();

                // update (thus deleting) any deleted child objects
                foreach (InputDeliveryLine 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 (InputDeliveryLine obj in this)
                {
                    if (obj.IsNew)
                    {
                        obj.Insert(parent);
                    }
                    else
                    {
                        obj.Update(parent);
                    }
                }
            }
            finally
            {
                this.RaiseListChangedEvents = true;
            }
        }
Example #20
0
        internal void Update(InputDelivery parent)
        {
            // if we're not dirty then don't update the database
            if (!this.IsDirty)
            {
                return;
            }

            this.OidAlbaran = parent.Oid;

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

            MarkOld();
        }
Example #21
0
        protected override bool SaveObject()
        {
            this.Datos.RaiseListChangedEvents = false;

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

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

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

                return(true);
            }
            finally
            {
                this.Datos.RaiseListChangedEvents = true;
            }
        }
Example #22
0
 public InputDeliveryLine NewItem(InputDelivery parent, InputDeliveryLineInfo line)
 {
     this.NewItem(InputDeliveryLine.NewChild(parent, line));
     return(this[Count - 1]);
 }
Example #23
0
 public InputDeliveryEditForm(InputDelivery entity, Form parent)
     : this(-1, new object[1] {
     entity
 }, parent)
 {
 }
 public override void DeleteAction()
 {
     InputDelivery.Delete(ActiveOID, ActiveItem.ETipoAcreedor);
     _action_result = DialogResult.OK;
 }
Example #25
0
 public InputDeliveryLine NewItem(InputDelivery parent, IDocumentLine line, ProductInfo product, decimal currencyRate)
 {
     this.NewItem(InputDeliveryLine.NewChild(parent, line, product, currencyRate));
     return(this[Count - 1]);
 }
 public static string SELECT(QueryConditions conditions)
 {
     return(InputDelivery.SELECT(conditions));
 }
Example #27
0
        private void ExportToInputDelivery()
        {
            InputDeliveries in_deliveries  = null;
            ISchemaInfo     current_schema = AppContext.ActiveSchema;

            try
            {
                List <OutputDeliveryInfo> list = _config.SourceEntityList as List <OutputDeliveryInfo>;

                List <long> oids = new List <long>
                                   (
                    from item in list
                    select(item as OutputDeliveryInfo).Oid
                                   );

                OutputDeliveryList out_deliveries  = OutputDeliveryList.GetList(oids, true);
                ProductList        source_products = ProductList.GetList(false);

                string fromCurrencyIso = (AppContext.ActiveSchema as CompanyInfo).CurrencyIso;
                string fromCurrency    = (AppContext.ActiveSchema as CompanyInfo).Currency;

                //Move to new schema to create destination entities

                AppContext.Principal.ChangeUserSchema(_config.DestinationCompany);

                string toCurrencyIso = (AppContext.ActiveSchema as CompanyInfo).CurrencyIso;
                string toCurrency    = (AppContext.ActiveSchema as CompanyInfo).Currency;

                decimal currencyRate = 1;

                if (fromCurrencyIso != toCurrencyIso)
                {
                    currencyRate = CurrencyExchange.GetCurrencyRate(fromCurrencyIso, toCurrencyIso);
                }

                if (currencyRate == 0)
                {
                    throw new iQException(string.Format(Resources.Messages.NO_CURRENCY_EXCHANGE_RATE, fromCurrency, toCurrency), new object[2] {
                        ETipoEntidad.CurrencyExchange, 0
                    });
                }

                in_deliveries = InputDeliveries.NewList();
                ProductList dest_products = ProductList.GetList(false);

                foreach (OutputDeliveryInfo item in out_deliveries)
                {
                    InputDelivery delivery = in_deliveries.NewItem();
                    delivery.CopyFrom(item, _config.DestinationHolder as IAcreedorInfo);

                    foreach (OutputDeliveryLineInfo line in item.Conceptos)
                    {
                        ProductInfo source_product = source_products.GetItem(line.OidProducto);

                        if (string.IsNullOrEmpty(source_product.ExternalCode))
                        {
                            throw new iQException(string.Format(Resources.Messages.NO_PRODUCT_EXTERNAL_CODE, source_product.Codigo, source_product.Nombre), new object[2] {
                                ETipoEntidad.Producto, source_product.Oid
                            });
                        }

                        List <ProductInfo> dest_product = new List <ProductInfo>
                                                          (
                            from p in dest_products
                            where p.ExternalCode == source_product.ExternalCode
                            select p
                                                          );

                        if (dest_product.Count() == 0)
                        {
                            throw new iQException(string.Format(Resources.Messages.PRODUCT_EXTERNAL_CODE_MISSMATCH, source_product.Codigo, source_product.Nombre), new object[2] {
                                ETipoEntidad.Producto, source_product.Oid
                            });
                        }

                        delivery.Conceptos.NewItem(delivery, line, dest_product[0], currencyRate);
                    }

                    delivery.CalculateTotal();
                }

                in_deliveries.Save();
            }
            catch (Exception ex)
            {
                if (in_deliveries != null)
                {
                    in_deliveries.CloseSession();
                }
                throw ex;
            }
            finally
            {
                //Move back to  active schema
                AppContext.Principal.ChangeUserSchema(current_schema);
            }
        }
Example #28
0
 public InputDeliveryAddForm(InputDelivery entity, Form parent)
     : this(new object [1] {
     entity
 }, parent)
 {
 }
Example #29
0
 public InputDeliveryLineAddForm(InputDelivery delivery, SerieInfo serie, IAcreedorInfo provider, Form parent)
     : base(null, delivery, serie, provider, parent)
 {
     InitializeComponent();
     SetFormData();
 }
 public void CopyFrom(InputDelivery source)
 {
     _base.CopyValues(source);
 }