private void RefreshData()
        {
            ITopPandSRepository pandsRepository = new TopPandSRepository();

            this.TopPandSList      = pandsRepository.GetPandSList(null).OrderByDescending(x => x.Sales).ToList();
            this.ShowAllCount      = this.TopPandSList.Count();
            this.ShowSelectedCount = 0;
            FullList    = this.TopPandSList.ToList();
            DefaultList = this.TopPandSList.ToList();
            //   this.TopPandSListcmb = this.TopPandSList.OrderBy(x => x.PandSName).ToList();
            //this.TopPandSListcmbCode = this.TopPandSList.OrderBy(x => x.PandSCode).ToList();
            //this.TopPandSListcmbCat1 = this.TopPandSList.GroupBy(x => x.Category1).Select(e => e.First()).OrderBy(x => x.Category1).ToList();
            //this.TopPandSListcmbCat2 = this.TopPandSList.GroupBy(x => x.Category2).Select(e => e.First()).OrderBy(x => x.Category2).ToList();

            //allPosition.Category1 = "All";
            //allPosition.Category2 = "All";
            //this.TopPandSListcmbCat1.Insert(0, allPosition);
            //this.TopPandSListcmbCat2.Insert(0, allPosition);
            GetOptionsandTaxValues();
            this.ShowAllTrue      = true;
            this.ShowBoth         = true;
            this.ShowSelectedTrue = false;
            this.ShowProducts     = false;
            this.ShowServices     = false;

            this.YearRange = pandsRepository.GetYearRange().ToList();

            TotalSalesAmountStr    = Convert.ToString(TopPandSList.Sum(e => e.Sales));
            TotalPurchaseAmountStr = Convert.ToString(TopPandSList.Sum(e => e.Purchase));
            //if (this.ShowIncTaxTrue == true)
            //{
            //    foreach (var item in this.TopPandSList)
            //    {
            //        //item.StandardSellPriceStr = item.PandSStdSellPriceaftGST.ToString();
            //        //item.AverageSellPriceStr = item.PandSAveSellPriceaftGST.ToString();
            //        //item.LastSellPriceStr = item.PandSLastSoldPriceaftGST.ToString();
            //    }
            //}
            //else
            //{
            //    foreach (var item in DefaultList)
            //    {
            //        //item.StandardSellPriceStr = item.PandSStdSellPricebefGST.ToString();
            //        //item.AverageSellPriceStr = item.PandSAveSellPricebefGST.ToString();
            //        //item.LastSellPriceStr = item.PandSLastSoldPricebefGST.ToString();
            //    }
            //}
            SetDefaultSearchSelection(this.JsonData);
            var pscat1 = psRepository.GetCategoryContent("PSC01");
            var pscat2 = psRepository.GetCategoryContent("PSC02");

            if (pscat1 != null)
            {
                PSCategory1 = pscat1.ToList();
            }
            if (pscat2 != null)
            {
                PSCategory2 = pscat2.ToList();
            }
        }
        void Search(object param)
        {
            if (Count != 0)
            {
                SearchValues = new List <SearchEntity>();
                //this.ShowSelectedTrue = true;
                //this.ShowAllTrue = false;
                if (this.SelectedSearchYear != null || this.SelectedSearchYear == string.Empty)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Year";
                    value.FieldValue = this.SelectedSearchYear;
                    SearchValues.Add(value);
                    //var year = Convert.ToInt32(this.SelectedSearchYear);
                    //DefaultList = FullList.Where(x => x.CreatedDate.Value.Year == year).ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PurchaseQuotationListcmb = DefaultList;
                }
                else
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Year";
                    value.FieldValue = "0";
                    SearchValues.Add(value);
                }

                if (this.SelectedSearchQuarter != null || this.SelectedSearchQuarter == string.Empty)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Quarter";
                    value.FieldValue = this.SelectedSearchQuarter;
                    int month1;
                    int month2;
                    int month3;
                    if (Convert.ToInt32(this.SelectedSearchQuarter) == 1)
                    {
                        month1 = 1;
                        month2 = 2;
                        month3 = 3;
                    }
                    else if (Convert.ToInt32(this.SelectedSearchQuarter) == 2)
                    {
                        month1 = 4;
                        month2 = 5;
                        month3 = 6;
                    }
                    else if (Convert.ToInt32(this.SelectedSearchQuarter) == 3)
                    {
                        month1 = 7;
                        month2 = 8;
                        month3 = 9;
                    }
                    else
                    {
                        month1 = 10;
                        month2 = 11;
                        month3 = 12;
                    }
                    //DefaultList = FullList.Where(x => x.CreatedDate.Value.Month == month1 || x.CreatedDate.Value.Month == month2 || x.CreatedDate.Value.Month == month3).ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PurchaseQuotationListcmb = DefaultList;
                    SearchValues.Add(value);
                }
                else
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Quarter";
                    value.FieldValue = "0";
                    SearchValues.Add(value);
                }

                if (this.SelectedSearchMonth != null || this.SelectedSearchMonth == string.Empty)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Month";
                    value.FieldValue = this.SelectedSearchMonth;
                    SearchValues.Add(value);
                    //var month = Convert.ToInt32(this.SelectedSearchMonth);
                    //DefaultList = FullPQList.Where(x => x.CreatedDate.Value.Month == month).ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PurchaseQuotationListcmb = DefaultList;
                }
                else
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Month";
                    value.FieldValue = "0";
                    SearchValues.Add(value);
                }

                if (ShowIncTaxTrue == true)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "IncExcGST";
                    value.FieldValue = "true";
                    SearchValues.Add(value);
                }
                else
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "IncExcGST";
                    value.FieldValue = "false";
                    SearchValues.Add(value);
                }

                if (ShowAllTrue == true)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "ShowAll";
                    value.FieldValue = this.ShowAllTrue.ToString();
                    SearchValues.Add(value);
                }
                else
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "ShowAll";
                    value.FieldValue = "false";
                    SearchValues.Add(value);
                }

                if (ShowProducts == true)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Products";
                    value.FieldValue = "1";
                    SearchValues.Add(value);
                }
                else if (ShowServices == true)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Products";
                    value.FieldValue = "2";
                    SearchValues.Add(value);
                }
                else
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "Products";
                    value.FieldValue = "0";
                    SearchValues.Add(value);
                }

                if (this.SelectedSearchStartDate != null && this.SelectedSearchEndDate != null)
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "StartDate";
                    value.FieldValue = this.SelectedSearchStartDate.ToString();
                    value.FieldValue = string.Format("{0:MMM/dd/yyyy}", this.SelectedSearchStartDate);
                    SearchValues.Add(value);

                    SearchEntity value1 = new SearchEntity();
                    value1.FieldName  = "EndDate";
                    value1.FieldValue = string.Format("{0:MMM/dd/yyyy}", this.SelectedSearchEndDate);

                    SearchValues.Add(value);
                    SearchValues.Add(value1);
                }
                else
                {
                    SearchEntity value = new SearchEntity();
                    value.FieldName  = "StartDate";
                    value.FieldValue = "";
                    //value.FieldValue = string.Format("{0:MMM/dd/yyyy}", this.SelectedSearchStartDate);
                    // SearchValues.Add(value);

                    SearchEntity value1 = new SearchEntity();
                    value1.FieldName  = "EndDate";
                    value1.FieldValue = "";
                    SearchValues.Add(value);
                    SearchValues.Add(value1);
                }


                jsonSearch    = JsonConvert.SerializeObject(SearchValues);
                this.JsonData = jsonSearch;

                ITopPandSRepository casRepository = new TopPandSRepository();
                var results = casRepository.SaveSearchJson(jsonSearch, Convert.ToInt32(ScreenId.TopPandS), "TopPandS_List");
                if (Count != 0)
                {
                    this.TopPandSList = casRepository.GetPandSList(jsonSearch);
                }
                TotalSalesAmountStr    = Convert.ToString(TopPandSList.Sum(e => e.Sales));
                TotalPurchaseAmountStr = Convert.ToString(TopPandSList.Sum(e => e.Purchase));
                //this.TopPandSListcmb = this.TopPandSList.OrderBy(e => e.CountAndAdjustStockNo).ToList();
                //this.TopPandSListDate = this.TopPandSList.GroupBy(x => x.CountAndAdjustStockDateDatetime).Select(y => y.First()).OrderBy(x => x.CountAndAdjustStockDateDatetime).Distinct().ToList();
                //this.TopPandSListSCNo = casRepository.GetAllStockCount().OrderBy(e => e.TopPandSListSCNo).ToList();
                //this.TopPandSListAmount = casRepository.GetAllStockCount().GroupBy(x => x.AdjustedAmountd).Select(y => y.First()).OrderBy(x => x.AdjustedAmountd).Distinct().ToList();
                if (this.ShowAllTrue == true)
                {
                    this.ShowSelectedCount = 0;
                }
                else
                {
                    this.ShowSelectedCount = this.TopPandSList.Count();
                }
                DefaultList = this.TopPandSListcmb;
            }
        }