private void RefreshData()
        {
            ITopSuppliersRepository pandsRepository = new TopSuppliersRepository();

            this.TopSuppliersList  = pandsRepository.GetPandSList(null).OrderByDescending(x => x.Purchases).ToList();
            this.ShowAllCount      = this.TopSuppliersList.Count();
            this.ShowSelectedCount = 0;
            FullList    = this.TopSuppliersList.ToList();
            DefaultList = this.TopSuppliersList.ToList();
            this.TopSuppliersListcmb = this.TopSuppliersList.OrderBy(x => x.SupplierName).ToList();
            //this.TopSuppliersListcmbCode = this.TopSuppliersList.OrderBy(x => x.PandSCode).ToList();
            //this.TopSuppliersListcmbCat1 = this.TopSuppliersList.GroupBy(x => x.Category1).Select(e => e.First()).OrderBy(x => x.Category1).ToList();
            //this.TopSuppliersListcmbCat2 = this.TopSuppliersList.GroupBy(x => x.Category2).Select(e => e.First()).OrderBy(x => x.Category2).ToList();

            //allPosition.Category1 = "All";
            //allPosition.Category2 = "All";
            //this.TopSuppliersListcmbCat1.Insert(0, allPosition);
            //this.TopSuppliersListcmbCat2.Insert(0, allPosition);
            GetOptionsandTaxValues();
            this.ShowAllTrue = true;

            this.ShowSelectedTrue = false;


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

            TotalPurchasesAmountStr = Convert.ToString(TopSuppliersList.Sum(e => e.Purchases));
            TotalPaymentAmountStr   = Convert.ToString(TopSuppliersList.Sum(e => e.Payment));

            SetDefaultSearchSelection(this.JsonData);
        }
Beispiel #2
0
        public void GetData(string SearchFilter, string parameter)
        {
            if (parameter == "ShowIncTaxTrue" && SearchFilter == "True")
            {
                Search(null);
            }
            if (parameter == "ShowExcTaxTrue" && SearchFilter == "True")
            {
                Search(null);
            }
            if (parameter == "ShowAllTrue" && SearchFilter == "True")
            {
                this.TopSuppliersList    = FullList.ToList();
                DefaultList              = this.TopSuppliersList;
                this.TopSuppliersListcmb = this.TopSuppliersList;

                //this.ShowSelectedTrue = false;
                this.ShowAllTrue       = true;
                this.ShowSelectedCount = 0;
                Search(null);
            }
            if (parameter == "SelectedSupplierName")
            {
                if (SearchFilter != null || SearchFilter == string.Empty)
                {
                    this.TopSuppliersList        = DefaultList.Where(x => x.SupplierName == SearchFilter).ToList();
                    this.TotalPurchasesAmountStr = Convert.ToString(TopSuppliersList.Sum(e => e.Purchases));
                }
                else
                {
                    this.TopSuppliersList = DefaultList.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.PaymentQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PaymentQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PaymentQuotationListcmb = 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.PaymentQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PaymentQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PaymentQuotationListcmb = 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.PaymentQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PaymentQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PaymentQuotationListcmb = 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 (true)
                {
                    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;

                ITopSuppliersRepository casRepository = new TopSuppliersRepository();
                var results = casRepository.SaveSearchJson(jsonSearch, Convert.ToInt32(ScreenId.TopSuppliers), "TopSuppliers_List");
                if (Count != 0)
                {
                    this.TopSuppliersList = casRepository.GetPandSList(jsonSearch);
                }
                TotalPurchasesAmountStr  = Convert.ToString(TopSuppliersList.Sum(e => e.Purchases));
                TotalPaymentAmountStr    = Convert.ToString(TopSuppliersList.Sum(e => e.Payment));
                this.TopSuppliersListcmb = this.TopSuppliersList.OrderBy(e => e.SupplierName).ToList();
                //this.TopSuppliersListDate = this.TopSuppliersList.GroupBy(x => x.CountAndAdjustStockDateDatetime).Select(y => y.First()).OrderBy(x => x.CountAndAdjustStockDateDatetime).Distinct().ToList();
                //this.TopSuppliersListSCNo = casRepository.GetAllStockCount().OrderBy(e => e.TopSuppliersListSCNo).ToList();
                //this.TopSuppliersListAmount = 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.TopSuppliersList.Count();
                }
                DefaultList = this.TopSuppliersListcmb;
            }
        }