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

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

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

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

                    stockdetailsEntity.Add(row);
                    OnPropertyChanged("stockdetailsEntity");
                    TempList      = stockdetailsEntity;
                    rowFocusindex = -1;
                }
                else
                {
                    var emptyRow = TempList.Where(y => y.ID == 0).FirstOrDefault();
                    rowFocusindex = stockdetailsEntity.IndexOf(emptyRow);
                }
            }
            return(rowFocusindex);
        }
        public void createStock()
        {
            var row = new StockGridViewModel(StockList);

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