public int ManageDuplicateUnpaidSalesInvoice() { int rowFocusindex = -1; //ShowAllCount = PSDetailsEntity.Where(e => e.SelectedPSID != 0).Count(); TempList = new ObservableCollection <UnpaidSalesInvoiceGridViewModel>(); TempList = UnpaidSalesInvoicedetailsEntity; var query = TempList.GroupBy(x => x.ID) .Where(g => g.Count() > 1) .ToList(); if (query.Count > 0 && UnpaidSalesInvoicedetailsEntity.Count > 1) { var obj1 = query[0].ElementAt(0); var obj2 = query[0].ElementAt(1); int?qty = 1; qty = query[0].ElementAt(0).CountQty + query[0].ElementAt(1).CountQty; var index1 = TempList.IndexOf(query[0].ElementAt(0)); var index2 = TempList.IndexOf(query[0].ElementAt(1)); OnPropertyChanged("UnpaidSalesInvoicedetailsEntity"); TempList = UnpaidSalesInvoicedetailsEntity; } else { int count = UnpaidSalesInvoicedetailsEntity.Count(x => x.ID == 0); if (count == 0) { var row = new UnpaidSalesInvoiceGridViewModel(UnpaidInvoiceList); // row.CountQty = 0; // row.GSTRate = TaxRate; UnpaidSalesInvoicedetailsEntity.Add(row); OnPropertyChanged("UnpaidSalesInvoicedetailsEntity"); TempList = UnpaidSalesInvoicedetailsEntity; rowFocusindex = -1; } else { var emptyRow = TempList.Where(y => y.ID == 0).FirstOrDefault(); rowFocusindex = UnpaidSalesInvoicedetailsEntity.IndexOf(emptyRow); } } return(rowFocusindex); }
public void createNewUnpaidSalesInvoice() { var row = new UnpaidSalesInvoiceGridViewModel(UnpaidInvoiceList); //row.SelectedPSID = 0; if (UnpaidSalesInvoicedetailsEntity != null) { if (UnpaidSalesInvoicedetailsEntity.Count > 0) { UnpaidSalesInvoicedetailsEntity.Clear(); // var row = new CollectAmountDataGridViewModel(); // PQDetailsEntity.Add(row); OnPropertyChanged("UnpaidSalesInvoicedetailsEntity"); } } UnpaidSalesInvoicedetailsEntity.Add(row); OnPropertyChanged("UnpaidSalesInvoicedetailsEntity"); }