public int ManageDuplicateUndeliveredPurchase()
        {
            int rowFocusindex = -1;

            //ShowAllCount = PSDetailsEntity.Where(e => e.SelectedPSID != 0).Count();
            TempList = new ObservableCollection <UndeliveredPurchaseOrdersDepositsGridViewModel>();
            TempList = UndeliveredPurchaseOrdersDepositsDetailsEntity;

            var query = TempList.GroupBy(x => x.ID)
                        .Where(g => g.Count() > 1)
                        .ToList();

            if (query.Count > 0 && UndeliveredPurchaseOrdersDepositsDetailsEntity.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("UndeliveredPurchaseOrdersDepositsDetailsEntity");
                TempList = UndeliveredPurchaseOrdersDepositsDetailsEntity;
            }
            else
            {
                int count = UndeliveredPurchaseOrdersDepositsDetailsEntity.Count(x => x.ID == 0);
                if (count == 0)
                {
                    var row = new UndeliveredPurchaseOrdersDepositsGridViewModel(UndeliveredPurchaseList);
                    // row.CountQty = 0;
                    //   row.GSTRate = TaxRate;

                    UndeliveredPurchaseOrdersDepositsDetailsEntity.Add(row);
                    OnPropertyChanged("UndeliveredPurchaseOrdersDepositsDetailsEntity");
                    TempList      = UndeliveredPurchaseOrdersDepositsDetailsEntity;
                    rowFocusindex = -1;
                }
                else
                {
                    var emptyRow = TempList.Where(y => y.ID == 0).FirstOrDefault();
                    rowFocusindex = UndeliveredPurchaseOrdersDepositsDetailsEntity.IndexOf(emptyRow);
                }
            }
            return(rowFocusindex);
        }
        public void createNewUndeliveredPurchase()
        {
            var row = new UndeliveredPurchaseOrdersDepositsGridViewModel(UndeliveredPurchaseList);

            //row.SelectedPSID = 0;
            if (UndeliveredPurchaseOrdersDepositsDetailsEntity != null)
            {
                if (UndeliveredPurchaseOrdersDepositsDetailsEntity.Count > 0)
                {
                    UndeliveredPurchaseOrdersDepositsDetailsEntity.Clear();
                    // var row = new CollectAmountDataGridViewModel();
                    //  PQDetailsEntity.Add(row);
                    OnPropertyChanged("UndeliveredPurchaseOrdersDepositsDetailsEntity");
                }
            }
            UndeliveredPurchaseOrdersDepositsDetailsEntity.Add(row);
            OnPropertyChanged("UndeliveredPurchaseOrdersDepositsDetailsEntity");
        }