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);
            }
        }
        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);
            }
        }
Exemple #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>());
        }
Exemple #4
0
        public void Run(MasterPriceSearchParameters mpsp, GridState gs, Currency currency, PriceBaseStatus priceBaseStatus)
        {
            if (mpsp.ProductStatus == null)
            {
                mpsp.ProductStatus = ProductStatus.Active;
            }

            IQuery           q             = ControllerManager.PriceBase.GetProductListQuery("DISTINCT PB", mpsp.Description, mpsp.Categories, mpsp.CtrRange, mpsp.Selection, mpsp.Frequency, currency, 0, 0, string.Empty, string.Empty, gs.MarkedAll, gs.Items, false, null, null, mpsp.PriceGroup, mpsp.Provider, mpsp.SearchDate, priceBaseStatus, mpsp.ProductStatus, mpsp.IndexPrice, mpsp.SearchDateTo, mpsp.PriceImport, mpsp.PriceList, mpsp.WorkListItemStatus, mpsp.PublishList, mpsp.Distributor);
            List <PriceBase> pricebaselist = q.List <PriceBase>() as List <PriceBase>;

            if (pricebaselist.Count > 0)
            {
                priceBases = pricebaselist;
                Execute();
            }
        }
Exemple #5
0
        public void Run(MasterPriceSearchParameters mpsp, GridState gs, int categoryId, bool addCategory)
        {
            CategoryBase tempcb = null;

            if (addCategory)
            {
                tempcb = new CategoryBase(categoryId);
            }
            IList <PriceBase> temppblist = ControllerManager.PriceBase.GetPriceBases(
                mpsp.Description, mpsp.Categories, mpsp.CtrRange, mpsp.Selection, mpsp.Frequency, string.Empty, string.Empty, gs.MarkedAll, gs.Items, false, mpsp.Currency, null, tempcb, null, mpsp.Provider, mpsp.SearchDate, PriceBaseStatus.NotVerified, mpsp.ProductStatus, mpsp.IndexPrice, mpsp.SearchDateTo, mpsp.PriceImport, mpsp.PriceList, mpsp.WorkListItemStatus, mpsp.PublishList, mpsp.Distributor);

            if (temppblist.Count > 0)
            {
                priceBases = temppblist;
                Execute();
            }
        }
Exemple #6
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();
        }
Exemple #7
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);
        }
Exemple #8
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);
        }
        public void Run(MasterPriceSearchParameters mpsp, GridState gs, Currency currency, PriceBaseStatus status)
        {
#if !DEBUG
            // Indicates which method to execute
            string      id          = Guid.NewGuid().ToString();
            ProcessItem processItem = new ProcessItem(id);
            processItem.AssemblyName          = typeof(PriceCalculator).Assembly.FullName;
            processItem.ClassName             = typeof(PriceCalculator).FullName;
            processItem.ConstructorParameters = new object[] { true, MembershipHelper.GetUser().UserId };
            processItem.MethodName            = "Run";
            processItem.MethodParameters      = new object[] { mpsp, gs, currency, status };

            // Add the task for processing whenever possible
            DynamicProcessorRemoting processor = (DynamicProcessorRemoting)Activator.GetObject(typeof(DynamicProcessorRemoting), Config.RemotingProcessor);
            processor.AddTask(processItem);
#else
            new PriceCalculator(true, MembershipHelper.GetUser().UserId).Run(mpsp, gs, currency, status);
#endif
        }
        /// <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);
        }
Exemple #11
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));
        }
Exemple #12
0
        public static SearchParameters GetSerchParameters(IList <IFilter> filters)
        {
            MasterPriceSearchParameters msps             = GetSearchFilters(filters);
            SearchParameters            searchParameters = new SearchParameters();

            for (int i = 0; i < 6; i++)
            {
                if (msps.Categories[i] != null)
                {
                    searchParameters.Categories[i] = msps.Categories[i].ID;
                }
            }
            if (msps.Country != null)
            {
                searchParameters.Country = msps.Country.ID;
            }
            if (msps.CtrRange != null)
            {
                searchParameters.CtrRange = msps.CtrRange.ID;
            }
            if (msps.Currency != null)
            {
                searchParameters.Currency = msps.Currency.ID;
            }
            if (!string.IsNullOrEmpty(msps.Description))
            {
                searchParameters.Description = msps.Description;
            }
            if (msps.Distributor != null)
            {
                searchParameters.Distributor = msps.Distributor.ID;
            }
            if (msps.DistributorStatus != null)
            {
                searchParameters.DistributorStatus = msps.DistributorStatus;
            }
            if (msps.Family != null)
            {
                searchParameters.Family = msps.Family.ID;
            }
            if (msps.Incoterm != null)
            {
                searchParameters.Incoterm = msps.Incoterm;
            }
            if (msps.IndexPrice != null)
            {
                searchParameters.IndexPrice = msps.IndexPrice.ID;
            }
            if (msps.PaymentTerm != null)
            {
                searchParameters.PaymentTerm = msps.PaymentTerm;
            }
            if (msps.PriceBaseStatus != null)
            {
                searchParameters.PriceBaseStatus = msps.PriceBaseStatus;
            }
            if (msps.PriceGroup != null)
            {
                searchParameters.PriceGroup = msps.PriceGroup.ID;
            }
            if (msps.PriceImport != null)
            {
                searchParameters.PriceImport = msps.PriceImport.ID;
            }
            if (msps.PriceList != null)
            {
                searchParameters.PriceList = msps.PriceList.ID;
            }
            if (msps.Frequency != null)
            {
                searchParameters.Frequency = msps.Frequency;
            }
            if (msps.ProductStatus != null)
            {
                searchParameters.ProductStatus = msps.ProductStatus;
            }
            if (msps.Provider != null)
            {
                searchParameters.Provider = msps.Provider.ID;
            }
            if (msps.PublishList != null)
            {
                searchParameters.PublishList = msps.PublishList.ID;
            }
            if (msps.PublishListStatus != null)
            {
                searchParameters.PublishListStatus = msps.PublishListStatus;
            }
            if (msps.SearchDate != null)
            {
                searchParameters.SearchDate = msps.SearchDate;
            }
            if (msps.SearchDateTo != null)
            {
                searchParameters.SearchDateTo = msps.SearchDateTo;
            }
            if (msps.Selection != null)
            {
                searchParameters.Selection = msps.Selection.ID;
            }
            if (msps.WorkListItemStatus != null)
            {
                searchParameters.WorkListItemStatus = msps.WorkListItemStatus;
            }
            if (msps.CategoryBase != null)
            {
                searchParameters.CategoryBase = msps.CategoryBase.ID;
            }
            if (msps.CategoryType != null)
            {
                searchParameters.CategoryType = msps.CategoryType.ToString();
            }
            if (msps.LookupType != null)
            {
                searchParameters.Type = msps.LookupType.ID;
            }
            if (msps.LookupTypeABM != null)
            {
                searchParameters.LookupType = msps.LookupTypeABM;
            }
            if (msps.PriceCalculationPriority != null)
            {
                searchParameters.PriceCalculationPriority = msps.PriceCalculationPriority;
            }
            if (msps.QuoteStatus != null)
            {
                searchParameters.QuoteStatus = msps.QuoteStatus;
            }
            if (msps.ProviderStatus != null)
            {
                searchParameters.ProviderStatus = msps.ProviderStatus;
            }
            if (msps.MembershipHelperUser != null)
            {
                searchParameters.MembershipHelperUser = msps.MembershipHelperUser;
            }
            if (msps.ImportStatus != null)
            {
                searchParameters.ImportStatus = msps.ImportStatus;
            }
            if (msps.CatalogPage != null)
            {
                searchParameters.CatalogPage = msps.CatalogPage.ID;
            }
            if (msps.CategoryPageStatus != null)
            {
                searchParameters.CategoryPageStatus = msps.CategoryPageStatus;
            }

            return(searchParameters);
        }
Exemple #13
0
        public static MasterPriceSearchParameters GetSearchFilters(IList <IFilter> filters)
        {
            MasterPriceSearchParameters mpsp = new MasterPriceSearchParameters();

            mpsp.PriceGroup         = (PriceGroup)FindObjectFromFilter(filters, typeof(PriceGroup), "ID");
            mpsp.PriceBaseStatus    = (PriceBaseStatus?)FindObjectFromFilter(filters, typeof(PriceBaseStatus), "ID");
            mpsp.ProductStatus      = (ProductStatus?)FindObjectFromFilter(filters, typeof(ProductStatus), "ID");
            mpsp.Currency           = FindObjectFromFilter(filters, typeof(Currency), "ID") as Currency;
            mpsp.Description        = (FindObjectFromFilter(filters, typeof(Product), "Description") as String ?? string.Empty).Trim();
            mpsp.CtrRange           = FindObjectFromFilter(filters, typeof(CtrRange), "ID") as CtrRange;
            mpsp.IndexPrice         = FindObjectFromFilter(filters, typeof(IndexPrice), "ID") as IndexPrice;
            mpsp.Selection          = FindObjectFromFilter(filters, typeof(Selection), "ID") as Selection;
            mpsp.Provider           = FindObjectFromFilter(filters, typeof(Provider), "ID") as Provider;
            mpsp.Distributor        = FindObjectFromFilter(filters, typeof(Distributor), "ID") as Distributor;
            mpsp.Incoterm           = (Incoterm?)FindObjectFromFilter(filters, typeof(Incoterm), "ID");
            mpsp.PriceImport        = (PriceImport)FindObjectFromFilter(filters, typeof(PriceImport), "ID");
            mpsp.PublishListStatus  = (PublishListStatus?)FindObjectFromFilter(filters, typeof(PublishListStatus), "ID");
            mpsp.PriceList          = (PriceList)FindObjectFromFilter(filters, typeof(PriceList), "ID");
            mpsp.Frequency          = (Frequency?)FindObjectFromFilter(filters, typeof(Frequency), "ID");
            mpsp.WorkListItemStatus = (WorkListItemStatus?)FindObjectFromFilter(filters, typeof(WorkListItemStatus), "ID");
            mpsp.PublishList        = (PublishList)FindObjectFromFilter(filters, typeof(PublishList), "ID");
            mpsp.PaymentTerm        = (Lookup)FindObjectFromFilter(filters, typeof(Lookup), "Payment");
            mpsp.DistributorStatus  = (DistributorStatus?)FindObjectFromFilter(filters, typeof(DistributorStatus), "ID");
            mpsp.Country            = FindObjectFromFilter(filters, typeof(Country), "ID") as Country;
            mpsp.ProviderStatus     = (ProviderStatus?)FindObjectFromFilter(filters, typeof(ProviderStatus), "ID");
            mpsp.CategoryType       = (Type)FindObjectFromFilter(filters, typeof(Type), "FullName");
            //mpsp.CategoryBase = (CategoryBase)FindObjectFromFilter(filters, typeof(CategoryBase), "ID");
            mpsp.CategoryBase             = (CategoryBase)FindObjectFromFilter(filters, typeof(CategoryBase), "ID");
            mpsp.LookupType               = FindObjectFromFilter(filters, typeof(Lookup), "ID") as Lookup;
            mpsp.LookupTypeABM            = (LookupType?)FindObjectFromFilter(filters, typeof(LookupType), "ID");
            mpsp.PriceCalculationPriority = (PriceCalculationPriority?)FindObjectFromFilter(filters, typeof(PriceCalculationPriority), "ID");
            mpsp.QuoteStatus              = (QuoteStatus?)FindObjectFromFilter(filters, typeof(QuoteStatus), "ID");
            mpsp.ImportStatus             = (ImportStatus?)FindObjectFromFilter(filters, typeof(ImportStatus), "ID");
            mpsp.CatalogPage              = (CatalogPage)FindObjectFromFilter(filters, typeof(CatalogPage), "Parent");
            mpsp.CategoryPageStatus       = (CategoryPageStatus?)FindObjectFromFilter(filters, typeof(CategoryPageStatus), "ID");

            mpsp.MembershipHelperUser = (Guid?)
                                        FindObjectFromFilter(filters, typeof(Guid), "UserId");

            mpsp.Categories[0] = FindObjectFromFilter(filters, typeof(Family), "ID") as Family;
            mpsp.Categories[1] = FindObjectFromFilter(filters, typeof(CatalogPage), "ID") as CatalogPage;
            mpsp.Categories[2] = FindObjectFromFilter(filters, typeof(ProductType), "ID") as ProductType;
            mpsp.Categories[3] = FindObjectFromFilter(filters, typeof(Application), "ID") as Application;
            mpsp.Categories[4] = FindObjectFromFilter(filters, typeof(Line), "ID") as Line;
            mpsp.Categories[5] = FindObjectFromFilter(filters, typeof(Area), "ID") as Area;

            Pair p = (Pair)FindObjectFromFilter(filters, typeof(Pair), "TimeStampCheck");

            if (p != null)
            {
                if (!string.IsNullOrEmpty(p.First.ToString()))
                {
                    mpsp.SearchDate = Convert.ToDateTime(p.First);
                }
                if (!string.IsNullOrEmpty(p.Second.ToString()))
                {
                    mpsp.SearchDateTo = Convert.ToDateTime(p.Second);
                }
            }

            return(mpsp);
        }