public void ShowAll(object param) { PSDetailsEntity = Lst; SelectedPSCat1 = 0; SelectedPSCat2 = 0; ShowAllCount = PSDetailsEntity.Where(e => e.SelectedPSID != 0).Count(); ShowAllrdn = true; ShowSelectedrdn = false; ShowSelectedCount = 0; OnPropertyChanged("PSDetailsEntity"); }
public void IncDecStock(object param) { SharedValues.StockType = Convert.ToInt16(Stock_Type.IncreaseDecreaseStock); Type = Convert.ToInt16(Stock_Type.IncreaseDecreaseStock); foreach (var item in PSDetailsEntity.Where(e => e.SelectedPSID != 0)) { item.Amount = 0; item.AdjustedAmount = 0; item.AvgCost = Convert.ToString(0); } }
public CountAndAdjustStockForm GetDataIntoModel() { OptionsEntity oData = new OptionsEntity(); ISalesOrderListRepository purchaseRepository = new SalesOrderListRepository(); oData = purchaseRepository.GetOptionSettings(); CountAndAdjustStockForm CSForm = new CountAndAdjustStockForm(); CSForm.CountAndAdjustStockDetails = new List <CountAndAdjustStockDetailsEntity>(); CountAndAdjustStockEntity model = new CountAndAdjustStockEntity(); model.StockCountNo = this.StockCountNo; model.StockDate = DateTime.ParseExact(this.StockDateStr, oData.DateFormat, null); if (IsIncreaseDecreaseStock == true) { model.StockType = Convert.ToByte(Stock_Type.IncreaseDecreaseStock); } if (IsStockDamaged == true) { model.StockType = Convert.ToByte(Stock_Type.StockDamaged); } if (IsStockTake == true) { model.StockType = Convert.ToByte(Stock_Type.StockTake); } CSForm.CountAndAdjustStock = model; foreach (var item in PSDetailsEntity.Where(e => e.CountQty != 0)) { if (item.SelectedPSID != 0) { CountAndAdjustStockDetailsEntity pqEntity = new CountAndAdjustStockDetailsEntity(); pqEntity.PSID = item.SelectedPSID; pqEntity.PandSCode = item.PandSCode; pqEntity.PandSName = item.PandSName; pqEntity.SystemQty = item.SystemQty; pqEntity.CountQty = item.CountQty; pqEntity.Difference = item.Difference; pqEntity.AvgCost = item.AvgCost; pqEntity.Amount = item.Amount; pqEntity.AdjustedAmount = Convert.ToDecimal(AdjustedAmountStr); pqEntity.AdjustedAmountStr = AdjustedAmountStr; if (item.SelectedPSID != 0 && Convert.ToInt32(item.SelectedPSID) > 0) { CSForm.CountAndAdjustStockDetails.Add(pqEntity); } } } return(CSForm); }
public void ShowSelected() { // List<DataGridViewModel> lst = new List<DataGridViewModel>(); if (SelectedPSCat1 != 0 && SelectedPSCat2 != 0) { PSDetailsEntity = new ObservableCollection <DataGridViewModel>(Lst.Where(e => e.PSCat1 == SelectedPSCat1 && e.PSCat2 == SelectedPSCat2)); } else if (SelectedPSCat1 != 0) { PSDetailsEntity = new ObservableCollection <DataGridViewModel>(Lst.Where(e => e.PSCat1 == SelectedPSCat1)); } else if (SelectedPSCat2 != 0) { PSDetailsEntity = new ObservableCollection <DataGridViewModel>(Lst.Where(e => e.PSCat2 == SelectedPSCat2)); } ShowAllrdn = false; ShowSelectedrdn = true; ShowSelectedCount = PSDetailsEntity.Where(e => e.SelectedPSID != 0).Count(); OnPropertyChanged("PSDetailsEntity"); }
public void OnStockTake(object param) { SharedValues.StockType = Convert.ToInt16(Stock_Type.StockTake); Type = Convert.ToInt16(Stock_Type.StockTake); foreach (var item in PSDetailsEntity.Where(e => e.SelectedPSID != 0 || e.SelectedPSID != null)) { item.Difference = item.CountQty - item.SystemQty; if (item.Difference != null) { if (item.AvgCost != Convert.ToString(0)) { item.Amount = Convert.ToInt32(item.Difference) * Convert.ToDecimal(item.AvgCost); item.AdjustedAmount = item.AdjustedAmount + item.Amount; } else { item.AvgCost = item.AvgCostStr; item.Amount = Convert.ToInt32(item.Difference) * Convert.ToDecimal(item.AvgCostStr); item.AdjustedAmount = item.AdjustedAmount + item.Amount; } } } }
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); }