private void RefreshData()
        {
            ISalesQuotationListRepository purchaseRepository = new SalesQuotationListRepository();

            this.DateFormat   = purchaseRepository.GetDateFormat();
            this.ShowAllCount = purchaseRepository.GetAllSalesQuotation().Count();
            GetOptionsandTaxValues();
            this.JsonData           = purchaseRepository.GetLastSelectionData(Convert.ToInt32(ScreenId.SalesQuotationList));
            this.SalesQuotationList = purchaseRepository.GetAllSalesQuotationJson(this.JsonData, this.IncludingGSTTrue).OrderBy(x => x.CustomerName).ToList();
            //changedateformat(this.SalesQuotationList);
            changeNumberformat(this.SalesQuotationList);


            this.ShowSelectedCount     = this.SalesQuotationList.Count();
            this.SalesQuotationListcmb = purchaseRepository.GetAllSalesQuotation().OrderBy(x => x.CustomerName).ToList();
            changeNumberformat(this.SalesQuotationListcmb);
            this.SalesQuotationListcmbSup = this.SalesQuotationList.GroupBy(x => x.CustomerName).Select(y => y.First()).OrderBy(x => x.CustomerName).Distinct().ToList();
            this.SalesQuotationListcmbQNo = this.SalesQuotationList.GroupBy(x => x.QuotationNo).Select(y => y.First()).OrderBy(x => x.SortQuotationNo).Distinct().ToList();
            this.YearRange = purchaseRepository.GetYearRange().ToList();

            DefaultList = this.SalesQuotationListcmb;
            FullPQList  = this.SalesQuotationListcmb;
            //this.ShowAllCount = this.SalesQuotationListcmb.Count();
            SetDefaultSearchSelection(this.JsonData);
            var    Updateddate = this.SalesQuotationListcmb.Max(x => x.CreatedDateList);
            string date        = this.DateFormat as string;

            this.LastUpdateDate = Convert.ToDateTime(Updateddate).ToString(date);
            TotalAmount         = Convert.ToString(SalesQuotationList.Sum(e => e.QAmount));

            //this.GetData(this.SelectedSearchSupplier);
        }
        void showexcGST(object param)
        {
            int decimalpoints = Convert.ToInt32(this.DecimalPlaces);

            IncludingGSTTrue  = false;
            IncludingGSTFalse = true;
            //foreach (var item in this.SalesQuotationList)
            //{
            //    //item.QuotationAmount = item.QuotationAmountExcGST;
            //    item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmountExcGST), decimalpoints).ToString();
            //}
            //if (this.ShowAllTrue == false)
            //    this.SalesQuotationList = DefaultList.Where(x => x.ExcIncGST == false).ToList();
            //else
            //    this.SalesQuotationList = FullPQList.Where(x => x.ExcIncGST == false).ToList();
            ISalesQuotationListRepository purchaseRepository = new SalesQuotationListRepository();

            this.SalesQuotationList = purchaseRepository.GetAllSalesQuotationJson(this.JsonData, this.IncludingGSTTrue).ToList();
            if (this.ShowAllTrue == false)
            {
                this.ShowSelectedCount = this.SalesQuotationList.Count();
            }
            else
            {
                this.ShowSelectedCount = 0;
            }
            this.SalesQuotationListcmb    = this.SalesQuotationList.OrderBy(x => x.CustomerName).ToList();
            this.SalesQuotationListcmbSup = this.SalesQuotationList.GroupBy(x => x.CustomerName).Select(y => y.First()).OrderBy(x => x.CustomerName).Distinct().ToList();
            this.SalesQuotationListcmbQNo = this.SalesQuotationList.GroupBy(x => x.QuotationNo).Select(y => y.First()).OrderBy(x => x.SortQuotationNo).Distinct().ToList();
            DefaultList = this.SalesQuotationListcmb;
            //changedateformat(this.SalesQuotationList);
            changeNumberformat(this.SalesQuotationList);
            TotalAmount = Convert.ToString(SalesQuotationList.Sum(e => e.QAmount));
        }
        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 = FullPQList.Where(x => x.CreatedDate.Value.Year == year).ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.SalesQuotationListcmb = DefaultList;
                }
                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 = FullPQList.Where(x => x.CreatedDate.Value.Month == month1 || x.CreatedDate.Value.Month == month2 || x.CreatedDate.Value.Month == month3).ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.SalesQuotationListcmb = DefaultList;
                    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.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.SalesQuotationListcmb = DefaultList;
                }
                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);
                    //string[] value = new string[2];
                    SearchEntity value1 = new SearchEntity();
                    value1.FieldName = "EndDate";
                    //value1.FieldValue = this.SelectedSearchEndDate.ToString();
                    value1.FieldValue = string.Format("{0:MMM/dd/yyyy}", this.SelectedSearchEndDate);

                    //DefaultList = FullPQList.Where(x => x.CreatedDate > this.SelectedSearchStartDate && x.CreatedDate < this.SelectedSearchEndDate).ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.SalesQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.SalesQuotationListcmb = DefaultList;
                    SearchValues.Add(value);
                    SearchValues.Add(value1);
                }
                //if (this.SelectedSearchEndDate != null || this.SelectedSearchEndDate == string.Empty)
                //{
                //    string[] value = new string[2];
                //    value[0] = "EndDate";
                //    value[1] = this.SelectedSearchEndDate;
                //    SearchValues.Add(value);
                //}

                //this.SalesQuotationList = this.SalesQuotationListInternal;
                jsonSearch    = JsonConvert.SerializeObject(SearchValues);
                this.JsonData = jsonSearch;

                ISalesQuotationListRepository purchaseRepository = new SalesQuotationListRepository();
                var results = purchaseRepository.SaveSearchJson(jsonSearch, Convert.ToInt32(ScreenId.SalesQuotationList), "Sales_Quotation_List");
                if (Count != 0)
                {
                    this.SalesQuotationList = purchaseRepository.GetAllSalesQuotationJson(jsonSearch, this.IncludingGSTTrue);
                    //changedateformat(this.SalesQuotationList);
                    changeNumberformat(this.SalesQuotationList);
                }

                this.SalesQuotationListcmb    = this.SalesQuotationList.GroupBy(x => x.CustomerName).Select(y => y.First()).Distinct().OrderBy(x => x.CustomerName).ToList();;
                this.SalesQuotationListcmbSup = this.SalesQuotationList.GroupBy(x => x.CustomerName).Select(y => y.First()).Distinct().OrderBy(x => x.CustomerName).ToList();
                this.SalesQuotationListcmbQNo = this.SalesQuotationList.GroupBy(x => x.QuotationNo).Select(y => y.First()).Distinct().OrderBy(x => x.SortQuotationNo).ToList();

                if (this.ShowAllTrue == true)
                {
                    this.ShowSelectedCount = 0;
                }
                else
                {
                    this.ShowSelectedCount = this.SalesQuotationList.Count();
                }
                DefaultList = this.SalesQuotationListcmb;

                TotalAmount = Convert.ToString(SalesQuotationList.Sum(e => e.QAmount));
            }
        }
        public void GetData(string SearchFilter, string parameter)
        {
            //ISalesQuotationListRepository purchaseRepository = new SalesQuotationListRepository();
            //var result = purchaseRepository.GetAllPurQuotation().ToList();
            if (SearchFilter != null || SearchFilter == string.Empty)
            {
                if (parameter == "Customer")
                {
                    this.ShowAllCount = this.ShowAllCount;
                    //var searchname = SearchFilter.Split('#')[0];
                    if (this.ShowAllTrue == true)
                    {
                        //commented on 23 May 2017
                        this.SalesQuotationList = FullPQList.Where(x => (x.CustomerName == SearchFilter || x.QuotationNo == SearchFilter || x.ConvertedTo == SearchFilter)).ToList();
                        //if (this.IncludingGSTTrue == true)
                        //{
                        //    this.SalesQuotationList = FullPQList.Where(x => (x.CustomerName == SearchFilter || x.QuotationNo == SearchFilter || x.ConvertedTo == SearchFilter) && x.ExcIncGST == true).ToList();
                        //}
                        //else
                        //{
                        //    this.SalesQuotationList = FullPQList.Where(x => (x.CustomerName == SearchFilter || x.QuotationNo == SearchFilter || x.ConvertedTo == SearchFilter) && x.ExcIncGST == false).ToList();
                        //}
                    }
                    else
                    {
                        this.SalesQuotationList = DefaultList.Where(x => (x.CustomerName == SearchFilter || x.QuotationNo == SearchFilter || x.ConvertedTo == SearchFilter)).ToList();
                        //if (this.IncludingGSTTrue == true)
                        //{
                        //    this.SalesQuotationList = DefaultList.Where(x => (x.CustomerName == SearchFilter || x.QuotationNo == SearchFilter || x.ConvertedTo == SearchFilter) && x.ExcIncGST == true).ToList();
                        //}
                        //else
                        //{
                        //    this.SalesQuotationList = DefaultList.Where(x => (x.CustomerName == SearchFilter || x.QuotationNo == SearchFilter || x.ConvertedTo == SearchFilter) && x.ExcIncGST == false).ToList();
                        //}
                    }

                    //DefaultList = DefaultList.Where(x => x.SupplierName == SearchFilter).ToList();
                }
                if (parameter == "ConvertedTo")
                {
                    this.ShowAllCount = this.ShowAllCount;
                    //var searchname = SearchFilter.Split('#')[0];
                    if (this.ShowAllTrue == true)
                    {
                        var search = SearchFilter.Split(':')[1];
                        if (search == " SO")
                        {
                            this.SalesQuotationList = FullPQList.Where(x => x.ConvertedToSO == true).ToList();
                        }
                        else if (search == " SI")
                        {
                            this.SalesQuotationList = FullPQList.Where(x => x.ConvertedToSI == true).ToList();
                        }
                        else if (search == " All")
                        {
                            this.SalesQuotationList = FullPQList.ToList();
                        }
                    }
                    else
                    {
                        var search = SearchFilter.Split(':')[1];
                        if (search == " SO")
                        {
                            this.SalesQuotationList = DefaultList.Where(x => x.ConvertedToSO == true).ToList();
                        }
                        else if (search == " SI")
                        {
                            this.SalesQuotationList = DefaultList.Where(x => x.ConvertedToSI == true).ToList();
                        }
                        else if (search == " All")
                        {
                            this.SalesQuotationList = DefaultList.ToList();
                        }
                    }
                }
            }
            else
            {
                if (this.ShowAllTrue == true)
                {
                    this.SalesQuotationList = FullPQList.ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.SalesQuotationList = FullPQList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.SalesQuotationList = FullPQList.Where(x => x.ExcIncGST == false).ToList();
                }
                else
                {
                    this.SalesQuotationList = DefaultList.ToList();
                    //if (this.IncludingGSTTrue == true)
                    //    this.SalesQuotationList = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.SalesQuotationList = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                }
            }
            //changedateformat(SalesQuotationList);
            //changeNumberformat(SalesQuotationList);
            TotalAmount = Convert.ToString(SalesQuotationList.Sum(e => e.QAmount));
        }