public void RefreshData() { ProductList = pandsRepository.GetPandSList().Where(e => e.PSType == "P" && e.IsInActive != "Y"); if (ProductList != null) { ProductAndServices = new ObservableCollection <PandSQtyAndStockModel>(ProductList); } var pscat1 = pandsRepository.GetCategoryContent("PSC01"); var pscat2 = pandsRepository.GetCategoryContent("PSC02"); if (pscat1 != null) { PSCategory1 = pscat1.ToList(); } if (pscat2 != null) { PSCategory2 = pscat2.ToList(); } AdjustedAmountStr = Convert.ToString(PSDetailsEntity.Sum(e => e.Amount)); GetOptionsandTaxValues(); }
public int ManageDuplicatePandS() { int rowFocusindex = -1; ShowAllCount = PSDetailsEntity.Where(e => e.SelectedPSID != 0).Count(); lst = new ObservableCollection <DataGridViewModel>(); lst = PSDetailsEntity; var query = lst.GroupBy(x => x.SelectedPSID) .Where(g => g.Count() > 1) .ToList(); if (query.Count > 0 && PSDetailsEntity.Count > 1) { var obj1 = query[0].ElementAt(0); var obj2 = query[0].ElementAt(1); int? qty = 1; decimal?productAmount2 = 0; // decimal? discountP2 = 0; qty = query[0].ElementAt(0).CountQty + query[0].ElementAt(1).CountQty; productAmount2 = Convert.ToDecimal(query[0].ElementAt(1).Amount); // discountP2 = query[0].ElementAt(1).PQDiscount; var index1 = lst.IndexOf(query[0].ElementAt(0)); var index2 = lst.IndexOf(query[0].ElementAt(1)); if (productAmount2 != null) { obj1.CountQty = qty; obj1.AmountStr = Convert.ToString(productAmount2); // obj1.PQDiscount = discountP2; PSDetailsEntity[index1] = obj1; var row = new DataGridViewModel(ProductList); //row.CountQty = 0; PSDetailsEntity[index2] = row; rowFocusindex = index2; } OnPropertyChanged("PSDetailsEntity"); Lst = PSDetailsEntity; } else { int count = PSDetailsEntity.Count(x => x.SelectedPSID == 0); if (count == 0) { var row = new DataGridViewModel(ProductList); // row.CountQty = 0; // row.GSTRate = TaxRate; PSDetailsEntity.Add(row); OnPropertyChanged("PSDetailsEntity"); Lst = PSDetailsEntity; rowFocusindex = -1; } else { var emptyRow = lst.Where(y => y.SelectedPSID == 0).FirstOrDefault(); rowFocusindex = PSDetailsEntity.IndexOf(emptyRow); } } AdjustedAmountStr = Convert.ToString(PSDetailsEntity.Sum(e => e.Amount)); return(rowFocusindex); }