private ICriteria GetDistributorsCriteria(string name, Country country, PriceList priceList, Lookup paymentTerm, DistributorStatus?status, GridState gridState, Incoterm?saleCondition, Lookup type, CatalogPage page) { ICriteria crit = GetCriteria(); ExecutePermissionValidator epv = new ExecutePermissionValidator(); epv.ClassType = typeof(Distributor); epv.KeyIdentifier = Config.SeeAllDistributors; if (PermissionManager.Check(epv) == false) { IList priceListIds = PermissionManager.GetPermissionIdentifiers(typeof(PriceList), PermissionAction.Create); int[] intPriceListIds = new int[priceListIds.Count]; for (int i = 0; i < priceListIds.Count; i++) { intPriceListIds[i] = Convert.ToInt32(priceListIds[i]); } ICriteria critDistributor = crit.CreateCriteria("PriceList"); critDistributor.Add(Expression.In("ID", intPriceListIds)); } if (!string.IsNullOrEmpty(name)) { Disjunction d = new Disjunction(); d.Add(Expression.InsensitiveLike("Name", name, MatchMode.Anywhere)); d.Add(Expression.InsensitiveLike("Code", name, MatchMode.Anywhere)); crit.Add(d); } if (country != null) { ICriteria critCountry = crit.CreateCriteria("Country"); critCountry.Add(Expression.Eq("ID", country.ID)); } if (priceList != null) { ICriteria critPriceList = crit.CreateCriteria("PriceList"); critPriceList.Add(Expression.Eq("ID", priceList.ID)); } if (paymentTerm != null) { crit.Add(Expression.Eq("PaymentTerm", paymentTerm)); } if (status != null) { crit.Add(Expression.Eq("DistributorStatus", status)); } else { epv = new ExecutePermissionValidator(); epv.ClassType = typeof(Distributor); epv.KeyIdentifier = Config.DistributorInactiveStatus; if (PermissionManager.Check(epv) == false) { crit.Add(Expression.Eq("DistributorStatus", DistributorStatus.Active)); } } if (saleCondition != null) { crit.Add(Expression.Eq("SaleConditions", saleCondition)); } if (type != null) { crit.Add(Expression.Eq("Type", type)); } if (page != null) { crit.CreateCriteria("PriceList").CreateCriteria("CategoryPages").Add(Expression.Eq("ID", page.ID)); } return(crit); }
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)); }
public IList <Distributor> GetDistributors(string name, Country country, PriceList priceList, Lookup paymentTerm, DistributorStatus?status, GridState gridState, out int totalRecords, Incoterm?saleCondition, Lookup type, CatalogPage page) { int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; ICriteria crit = GetDistributorsCriteria(name, country, priceList, paymentTerm, status, gridState, saleCondition, type, page); crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("ID"))); totalRecords = crit.UniqueResult <int>(); if (totalRecords == 0) { return(new List <Distributor>()); } pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords); crit = GetDistributorsCriteria(name, country, priceList, paymentTerm, status, gridState, saleCondition, type, page); crit.SetMaxResults(gridState.PageSize); if (pageNumber == 1) { crit.SetFirstResult(0); } else { crit.SetFirstResult((pageNumber - 1) * gridState.PageSize); } string[] sort = gridState.SortField.Split('.'); ICriteria critSort = crit; string sortField = gridState.SortField; if (!sortField.Contains("TimeStamp") && sort.Length > 1) { critSort = crit.CreateCriteria(sort[0], JoinType.LeftOuterJoin); sortField = sort[1]; } critSort.AddOrder(new Order(sortField, gridState.SortAscending)); return(crit.List <Distributor>()); }
public IList <CategoryBase> ListSearch(string search, Type type, CategoryBase parent, GridState gridState, out int records) { ICriteria crit = ListSearchCriteria(search, type, parent); crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("ID"))); records = crit.UniqueResult <int>(); if (records == 0) { return(new List <CategoryBase>()); } int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, records); crit = ListSearchCriteria(search, type, parent); crit.SetMaxResults(gridState.PageSize); if (pageNumber == 1) { crit.SetFirstResult(0); } else { crit.SetFirstResult((pageNumber - 1) * gridState.PageSize); } crit.AddOrder(new Order("Type", true)); crit.AddOrder(new Order("Parent", true)); crit.AddOrder(new Order("ID", true)); return(crit.List <CategoryBase>()); }
public IList <CatalogPage> ListLevelOnePages(string search, CatalogPage parent, CategoryPageStatus?status, GridState gridState, out int totalRecords) { ICriteria crit = ListLevelOnePagesCriteria(search, parent, status); crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("ID"))); totalRecords = crit.UniqueResult <int>(); if (totalRecords == 0) { return(new List <CatalogPage>()); } int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords); crit = ListLevelOnePagesCriteria(search, parent, status); crit.SetMaxResults(gridState.PageSize); if (pageNumber == 1) { crit.SetFirstResult(0); } else { crit.SetFirstResult((pageNumber - 1) * gridState.PageSize); } string[] sort = gridState.SortField.Split('.'); ICriteria critSort = crit; string sortField = gridState.SortField; if (!sortField.Contains("TimeStamp") && sort.Length > 1) { critSort = crit.CreateCriteria(sort[0], JoinType.LeftOuterJoin); sortField = sort[1]; } critSort.AddOrder(new Order(sortField, gridState.SortAscending)); return(crit.List <CatalogPage>()); }
public IList <PriceImport> Search(string info, DateTime?fromDate, out int totalRecords, GridState gridState, DateTime?toDate, ImportStatus?status) { int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; ICriteria crit = SearchCriteria(info, fromDate, toDate, status); crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("Number"))); totalRecords = crit.UniqueResult <int>(); if (totalRecords == 0) { return(new List <PriceImport>()); } pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords); crit = SearchCriteria(info, fromDate, toDate, status); crit.SetMaxResults(pageSize); if (pageNumber == 1) { crit.SetFirstResult(0); } else { crit.SetFirstResult((pageNumber - 1) * pageSize); } 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)); return(crit.List <PriceImport>()); }
public IList <Distributor> GetDistributors(string name, Country country, PriceList priceList, Lookup paymentTerm, DistributorStatus?status, GridState gridState, out int totalRecords, Lookup saleCondition, Lookup type, CatalogPage page) { 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); return(repository.GetDistributors(name, country, priceList, paymentTerm, status, gridState, out totalRecords, saleCondition, type, page, priceListIds, isActive)); }
//public void SaveAudit(PriceBase priceBase, HistoryStatus historyStatus) //{ // SaveAudit(priceBase, historyStatus, null); //} //public void SaveAudit(PriceBase priceBase, HistoryStatus historyStatus, Guid? userId) //{ // PriceBaseHistory priceBaseHistory = new PriceBaseHistory(); // priceBaseHistory.PriceImport = priceBase.PriceImport; // priceBaseHistory.PriceList = priceBase.PriceList; // priceBaseHistory.PriceListCurrency = priceBase.PriceListCurrency; // priceBaseHistory.PricePurchase = priceBase.PricePurchase; // priceBaseHistory.PricePurchaseCurrency = priceBase.PricePurchaseCurrency; // priceBaseHistory.PriceSuggest = priceBase.PriceSuggest; // priceBaseHistory.PriceSuggestCurrency = priceBase.PriceSuggestCurrency; // priceBaseHistory.Product = priceBase.Product; // priceBaseHistory.Provider = priceBase.Provider; // priceBaseHistory.ProviderCode = priceBase.ProviderCode; // priceBaseHistory.Status = priceBase.Status; // priceBaseHistory.HistoryStatus = historyStatus; // priceBaseHistory.CurrencyRate = priceBase.CurrencyRate; // priceBaseHistory.PricePurchaseCurrencyRate = priceBase.PricePurchaseCurrencyRate; // priceBaseHistory.PriceSuggestCurrencyRate = priceBase.PriceSuggestCurrencyRate; // if (userId.HasValue) // { // priceBaseHistory.TimeStamp.CreatedBy = userId; // priceBaseHistory.TimeStamp.CreatedOn = DateTime.Now; // priceBaseHistory.TimeStamp.ModifiedBy = userId; // priceBaseHistory.TimeStamp.ModifiedOn = DateTime.Now; // } // Save(priceBaseHistory); //} //public void SaveAudit(IList<PriceBase> lst, HistoryStatus historyStatus) //{ // foreach (PriceBase priceBase in lst) // SaveAudit(priceBase, historyStatus); //} public IList <ProductListView> GetByProduct(Product product, GridState gridState, out int totalRecords) { ICriteria crit = GetByProductCriteria(product); //crit.SetProjection(Projections.ProjectionList().Add(Projections.Count("ID"))); //totalRecords = crit.UniqueResult<int>(); //if (totalRecords == 0) // return new List<ProductListView>(); int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; //crit = GetByProductCriteria(product); //crit.SetMaxResults(gridState.PageSize); //if (pageNumber == 1) // crit.SetFirstResult(0); //else // crit.SetFirstResult((pageNumber - 1) * gridState.PageSize); string[] sort = gridState.SortField.Split('.'); ICriteria critSort = crit; string sortField = gridState.SortField; if (!sortField.Contains("TimeStamp") && sort.Length > 1) { critSort = crit.CreateCriteria(sort[0]); sortField = sort[1]; } critSort.AddOrder(new Order(sortField, gridState.SortAscending)); IList <PriceBaseHistory> priceBaseHistoryList = crit.List <PriceBaseHistory>(); IList <ProductListView> productListViewList = new List <ProductListView>(); totalRecords = priceBaseHistoryList.Count; pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords); int count; int maxcount; if (pageNumber == 1) { count = 0; } else { count = (pageNumber - 1) * gridState.PageSize; } maxcount = count + pageSize; decimal price = -1; foreach (PriceBaseHistory pbh in priceBaseHistoryList) { if (count < maxcount) { if (price == pbh.PriceList) { continue; } ProductListView productListView = new ProductListView(pbh); productListViewList.Add(productListView); count++; price = pbh.PriceList; } else { break; } } return(productListViewList); }
//public WorkListItemHistory SaveAudit(WorkListItem workListItem, HistoryStatus historyStatus) //{ // WorkListItemHistory workListItemHistory = new WorkListItemHistory(); // workListItemHistory.Price = workListItem.Price; // workListItemHistory.LastApproved = workListItem.LastApproved; // workListItemHistory.LastPublishItem = workListItem.LastPublishItem; // workListItemHistory.PriceCurrency = workListItem.PriceCurrency; // workListItemHistory.PriceList = workListItem.PriceList; // workListItemHistory.WorkListItemStatus = workListItem.WorkListItemStatus; // workListItemHistory.PriceBase = workListItem.PriceAttribute.PriceBase; // workListItemHistory.CurrencyRate = workListItem.CurrencyRate; // workListItemHistory.HistoryStatus = historyStatus; // workListItemHistory.PricePurchaseCurrencyRate = workListItem.PricePurchaseCurrencyRate; // workListItemHistory.PriceSuggestCurrencyRate = workListItem.PriceSuggestCurrencyRate; // Save(workListItemHistory); // return workListItemHistory; //} //public void SaveAudit(IList<WorkListItem> wliList, HistoryStatus historyStatus) //{ // foreach (WorkListItem workListItem in wliList) // { // SaveAudit(workListItem, historyStatus); // } //} public IList <WorkListItemHistory> GetByProduct(Product product, PriceList priceList, GridState gridState, out int totalRecords) { ICriteria crit = GetByProductCriteria(product, priceList); int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; crit.AddOrder(new Order("PriceList", true)); crit.AddOrder(new Order("TimeStamp.CreatedOn", false)); string[] sort = gridState.SortField.Split('.'); ICriteria critSort = crit; string sortField = gridState.SortField; if (!sortField.Contains("TimeStamp") && sort.Length > 1) { critSort = crit.CreateCriteria(sort[0]); sortField = sort[1]; } critSort.AddOrder(new Order(sortField, gridState.SortAscending)); IList <WorkListItemHistory> workListItemHistoryList = crit.List <WorkListItemHistory>(); IList <WorkListItemHistory> productListViewList = new List <WorkListItemHistory>(); totalRecords = workListItemHistoryList.Count; pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords); int count; int maxcount; if (pageNumber == 1) { count = 0; } else { count = (pageNumber - 1) * gridState.PageSize; } maxcount = count + pageSize; decimal price = -1; foreach (WorkListItemHistory wlih in workListItemHistoryList) { if (count < maxcount) { if (price == wlih.Price) { continue; } productListViewList.Add(wlih); count++; price = wlih.Price; } else { break; } } return(productListViewList); }
public IList <PriceCalculationListView> List(string search, CategoryBase[] category, Provider provider, PriceCalculationPriority?priority, GridState gridState, out int totalRecords) { ICriteria crit = ListCriteria(search, category, provider, priority); crit.AddOrder(new Order("Priority", true)); crit.AddOrder(new Order("Provider", true)); crit.AddOrder(new Order("CategoryBase", true)); crit.AddOrder(new Order("TimeStamp.ModifiedOn", false)); IList <PriceCalculationListView> tmp = ConvertToView(crit.List <PriceCalculation>()); IList <PriceCalculationListView> lstFinal = new List <PriceCalculationListView>(); int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, tmp.Count); for (int i = (pageNumber - 1) * gridState.PageSize; i < ((pageNumber - 1) * gridState.PageSize) + gridState.PageSize; i++) { if (i < tmp.Count) { lstFinal.Add(tmp[i]); } } totalRecords = tmp.Count; if (totalRecords == 0) { return(new List <PriceCalculationListView>()); } return(lstFinal); }
public IList <Product> GetProductList(string description, Frequency?frequency, DateTime?date, ProductStatus?status, Provider provider, CategoryBase[] category, Selection selection, GridState gridState, out int totalRecords) { string sortOrder = gridState.SortAscending ? "ASC" : "DESC"; int pageNumber = gridState.PageNumber; int pageSize = gridState.PageSize; IQuery q = ControllerManager.PriceBase.GetProductListQuery("COUNT(DISTINCT P.ID)", description, category, selection, frequency, date, status, provider, 0, 0, string.Empty, string.Empty, gridState.MarkedAll, null); totalRecords = Convert.ToInt32(q.UniqueResult()); pageNumber = Utils.AdjustPageNumber(pageNumber, pageSize, totalRecords); q = ControllerManager.PriceBase.GetProductListQuery("P", description, category, selection, frequency, date, status, provider, pageNumber, pageSize, gridState.SortField, sortOrder, gridState.MarkedAll, null); return(q.List <Product>()); }
public IList <QuoteRange> List(GridState gridState, out int totalRecords) { return(repository.List(gridState, out totalRecords)); }
public IList <Quote> List(GridState gridState, string text, Distributor distributor, QuoteStatus?status, out int records, Guid?userId, IList quoteIds) { return(repository.List(gridState, text, distributor, status, out records, userId, quoteIds)); }
public Quote AddItems(GridState gridState, int quoteId, string distributorName, string description, string observations, int vigency, int quoteCondition, int quoteIntroText, string email, string contact, out bool canfinal, List <int> contactids, int currencyId) { lstRates = ControllerManager.CurrencyRate.GetArray(); canfinal = true; Currency c = ControllerManager.Currency.GetById(currencyId); Quote q = new Quote(); if (quoteId > 0) { q = repository.GetById(quoteId); } Distributor d = ControllerManager.Distributor.GetByName(distributorName); q.Distributor = d; 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.Currency = c; q.CurrencyRate = ControllerManager.CurrencyRate.GetLast(q.Currency); List <Contact> temp = new List <Contact>(d.Contacts); AddContactNotifications(q, temp, contactids); if (!string.IsNullOrEmpty(email.Trim())) { AddNotifications(q, contact.Trim(), email.Trim()); } if (q.QuoteNotifications.Count == 0 && !string.IsNullOrEmpty(q.Distributor.Email)) { AddNotifications(q, q.Distributor.Contact, q.Distributor.Email); } else if (q.QuoteNotifications.Count == 0 && !string.IsNullOrEmpty(q.Distributor.AlternativeEmail)) { AddNotifications(q, q.Distributor.Contact, q.Distributor.AlternativeEmail); } //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); int i = 1; foreach (int item in gridState.Items) { PriceBase pb = temppblist.Find(delegate(PriceBase record) { if (record.ID == item) { return(true); } return(false); }); canfinal = canfinal && AddItem(q, pb, string.Empty, i); i++; } //foreach (PriceBase priceBase in temppblist) // canfinal = canfinal && AddItem(q, priceBase, string.Empty); repository.Save(q); repository.CommitChange(); q.Number = q.ID.ToString("000000"); if (quoteId == 0) { PermissionManager.AddEntityPermision(q.GetType(), q.ID.ToString(), MembershipHelper.GetUser().UserName); } return(q); }