Пример #1
0
        public void AddToPriceList(GridState gridState, IList <Filters.IFilter> filters, int priceListId)
        {
            if (!gridState.IsAnyItemMarked)
            {
                throw new NoItemMarkedException("No se ha seleccionado ningun Canal de Venta.");
            }

            MasterPriceSearchParameters msps = FilterHelper.GetSearchFilters(filters);

            ExecutePermissionValidator epv = new ExecutePermissionValidator();

            epv.ClassType     = typeof(PriceList);
            epv.KeyIdentifier = Config.SeePriceLists;

            bool  CanSeeAll    = PermissionManager.Check(epv);
            IList priceListIds = null;

            if (!CanSeeAll)
            {
                priceListIds = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create);
            }

            epv               = new ExecutePermissionValidator();
            epv.ClassType     = typeof(Distributor);
            epv.KeyIdentifier = Config.DistributorInactiveStatus;
            bool isActive = PermissionManager.Check(epv);

            IList <Distributor> lst = repository.GetSelecteds(msps.Description, msps.Country, msps.PriceList, msps.PaymentTerm, msps.DistributorStatus, gridState, msps.Incoterm, msps.LookupType, msps.Categories[1] as CatalogPage, priceListIds, isActive);

            foreach (Distributor d in lst)
            {
                d.PriceList = new PriceList(priceListId);
                repository.Save(d);
            }
        }
Пример #2
0
        public bool Remove(GridState gridState, IList <Filters.IFilter> filters)
        {
            if (!gridState.IsAnyItemMarked)
            {
                throw new NoItemMarkedException("No items has been marked");
            }

            string order = "DESC";

            if (gridState.SortAscending)
            {
                order = "ASC";
            }

            MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters);

            if (ControllerManager.PriceBase.RemoveFromSelection(mpsp.Description, mpsp.Categories, mpsp.CtrRange, mpsp.Selection, mpsp.Frequency, gridState.SortField, order, gridState.MarkedAll, gridState.Items, mpsp.Currency, mpsp.PriceGroup, mpsp.Provider, mpsp.SearchDate, mpsp.PriceBaseStatus, mpsp.ProductStatus, mpsp.IndexPrice, mpsp.SearchDateTo, mpsp.PriceImport, mpsp.PriceList, mpsp.WorkListItemStatus, mpsp.PublishList, mpsp.Distributor))
            {
                if ((gridState.MarkedAll) && (CanRemove(mpsp.Selection.ID)))
                {
                    ControllerManager.Selection.DeleteSelection(mpsp.Selection.ID);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        public IList <CatalogPage> GetPagesByFilters(GridState gridState, IList <Filters.IFilter> filters)
        {
            ICriteria crit = GetCriteria();
            MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters);

            if (!string.IsNullOrEmpty(mpsp.Description))
            {
                Disjunction d = new Disjunction();
                d.Add(Restrictions.InsensitiveLike("Description", mpsp.Description, MatchMode.Anywhere));
                d.Add(Restrictions.InsensitiveLike("DescriptionAlternative", mpsp.Description, MatchMode.Anywhere));
                d.Add(Restrictions.InsensitiveLike("Name", mpsp.Description, MatchMode.Anywhere));
                d.Add(Restrictions.InsensitiveLike("NameAlternative", mpsp.Description, MatchMode.Anywhere));

                crit.Add(d);
            }
            if (mpsp.CatalogPage != null)
            {
                crit.Add(Expression.Eq("Parent", mpsp.CatalogPage));
            }

            if (mpsp.CategoryPageStatus != null)
            {
                crit.Add(Expression.Eq("CategoryPageStatus", mpsp.CategoryPageStatus));
            }

            DetachedCriteria levelOneCriteria = DetachedCriteria.For <CatalogPage>().SetProjection(Projections.Property("ID"))
                                                .Add(Expression.IsNull("Parent"));

            ICriterion levelOneSubquery = Subqueries.PropertyIn("Parent", levelOneCriteria);

            crit.Add(levelOneSubquery);

            string[]  sort      = gridState.SortField.Split('.');
            ICriteria critSort  = crit;
            string    sortField = gridState.SortField;

            if (!sortField.Contains("TimeStamp") && sort.Length > 1)
            {
                critSort = crit.GetCriteriaByPath(sort[0]);
                if (critSort == null)
                {
                    critSort = crit.CreateCriteria(sort[0]);
                }
                sortField = sort[1];
            }
            critSort.AddOrder(new Order(sortField, gridState.SortAscending));
            if (!gridState.MarkedAll)
            {
                crit.Add(Expression.In("ID", gridState.Items));
            }

            return(crit.List <CatalogPage>());
        }
Пример #4
0
        public void AddToPriceList(GridState gridState, IList <Filters.IFilter> filters, int priceListId)
        {
            if (!gridState.IsAnyItemMarked)
            {
                throw new NoItemMarkedException("No se ha seleccionado ningun Canal de Venta.");
            }

            MasterPriceSearchParameters msps = FilterHelper.GetSearchFilters(filters);

            IList <Distributor> lst = GetSelecteds(msps.Description, msps.Country, msps.PriceList, msps.PaymentTerm, msps.DistributorStatus, gridState, msps.Incoterm, msps.LookupType, msps.Categories[1] as CatalogPage);

            foreach (Distributor d in lst)
            {
                d.PriceList = new PriceList(priceListId);
                Save(d);
            }
            //NHibernateSession.Flush();
            //CommitChanges();
        }
Пример #5
0
        public Quote AddItems(GridState gridState, IList <Filters.IFilter> filters, int quoteId, string distributorName, string description, string observations, int vigency, int quoteCondition, int quoteIntroText, string email, string contact, out bool canfinal)
        {
            canfinal = true;
            Quote q = new Quote();

            if (quoteId > 0)
            {
                q = GetById(quoteId);
            }

            q.Distributor  = ControllerManager.Distributor.GetByName(distributorName);
            q.Condition    = ControllerManager.Lookup.GetById(quoteCondition);
            q.Description  = description;
            q.IntroText    = ControllerManager.Lookup.GetById(quoteIntroText);
            q.Observations = observations;
            q.Status       = QuoteStatus.Draft;
            q.Vigency      = ControllerManager.Lookup.GetById(vigency);
            q.Email        = email;
            q.Contact      = contact;

            MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters);

            //Si no limpiamos los items antes de agregarlos, se ahorraria tiempo y se podria acomodar por fecha de creación.
            //¿Porque se sacan todos?
            q.QuoteItems.Clear();
            List <PriceBase> temppblist = ControllerManager.PriceBase.GetPriceBases(string.Empty, null, null, null, null, null, null, false, gridState.Items, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);

            foreach (PriceBase priceBase in temppblist)
            {
                canfinal = canfinal && AddItem(q, priceBase, string.Empty);
            }

            Save(q);
            CommitChanges();
            q.Number = q.ID.ToString("000000");

            if (quoteId == 0)
            {
                PermissionManager.AddEntityPermision(q.GetType(), q.ID.ToString(), MembershipHelper.GetUser().UserName);
            }

            return(q);
        }
Пример #6
0
        public bool Remove(GridState gridState, IList <Filters.IFilter> filters, int newfamilyId, bool isProduct)
        {
            MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters);

            bool changed = ControllerManager.PriceBase.RemoveFromCategory(mpsp.Description, mpsp.Categories, mpsp.CtrRange, mpsp.Selection, mpsp.Frequency, null, null, gridState.MarkedAll, gridState.Items, mpsp.Currency, newfamilyId, null, mpsp.Provider, mpsp.SearchDate, mpsp.PriceBaseStatus, mpsp.ProductStatus, mpsp.IndexPrice, mpsp.SearchDateTo, mpsp.PriceImport, mpsp.PriceList, mpsp.WorkListItemStatus, mpsp.PublishList, mpsp.Distributor, isProduct);

            CommitChanges();

            if (changed)
            {
                IQuery q = NHibernateSession.GetNamedQuery("CategoryCountUpdate");
                q.SetInt32("CategoryId", newfamilyId);
                q.UniqueResult();

                ControllerManager.PriceCalculation.Run(mpsp, gridState, newfamilyId, false);
            }

            return(changed);
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gridState"></param>
        /// <param name="filters"></param>
        /// <param name="newselection"></param>
        /// <param name="selectionid"></param>
        /// <returns></returns>
        /// <exception cref="SelectionAlreadyExistException">Throws this exception when a selection already exist.</exception>
        public Selection Add(GridState gridState, IList <Filters.IFilter> filters, string newselection, int selectionid)
        {
            if (!gridState.IsAnyItemMarked)
            {
                throw new NoItemMarkedException("No items has been marked");
            }

            Selection nuevaseleccion;

            if (!string.IsNullOrEmpty(newselection))
            {
                if (!CanCreate(newselection))
                {
                    throw new SelectionAlreadyExistException("Ya existe una selección con ese nombre");
                }

                MembershipHelperUser usuario = MembershipHelper.GetUser();
                nuevaseleccion = ControllerManager.Selection.CreateSelection(newselection, usuario.UserId);
            }
            else
            {
                nuevaseleccion = ControllerManager.Selection.GetWithProducts(selectionid);
            }

            if (nuevaseleccion == null)
            {
                return(null);
            }

            string order = "DESC";

            if (gridState.SortAscending)
            {
                order = "ASC";
            }

            MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters);

            ControllerManager.PriceBase.AddToSelection(mpsp.Description, mpsp.Categories, mpsp.CtrRange, mpsp.Selection, mpsp.Frequency, gridState.SortField, order, gridState.MarkedAll, gridState.Items, mpsp.Currency, nuevaseleccion, mpsp.PriceGroup, mpsp.Provider, mpsp.SearchDate, mpsp.PriceBaseStatus, mpsp.ProductStatus, mpsp.IndexPrice, mpsp.SearchDateTo, mpsp.PriceImport, mpsp.PriceList, mpsp.WorkListItemStatus, mpsp.PublishList, mpsp.Distributor);
            return(nuevaseleccion);
        }
Пример #8
0
        public bool Remove(GridState gridState, IList <Filters.IFilter> filters, bool isProduct)
        {
            MasterPriceSearchParameters mpsp = FilterHelper.GetSearchFilters(filters);

            return(Remove(gridState, filters, (mpsp.Categories[1] as CatalogPage).ID, isProduct));
        }