private void RefreshData()
        {
            ITopCustomersRepository pandsRepository = new TopCustomersRepository();

            this.TopCustomersList  = pandsRepository.GetPandSList(null).OrderByDescending(x => x.Sales).ToList();
            this.ShowAllCount      = this.TopCustomersList.Count();
            this.ShowSelectedCount = 0;
            FullList    = this.TopCustomersList.ToList();
            DefaultList = this.TopCustomersList.ToList();
            this.TopCustomersListcmb = this.TopCustomersList.OrderBy(x => x.CustomerName).ToList();
            //this.TopCustomersListcmbCode = this.TopCustomersList.OrderBy(x => x.PandSCode).ToList();
            //this.TopCustomersListcmbCat1 = this.TopCustomersList.GroupBy(x => x.Category1).Select(e => e.First()).OrderBy(x => x.Category1).ToList();
            //this.TopCustomersListcmbCat2 = this.TopCustomersList.GroupBy(x => x.Category2).Select(e => e.First()).OrderBy(x => x.Category2).ToList();

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

            this.ShowSelectedTrue = false;


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

            TotalSalesAmountStr   = Convert.ToString(TopCustomersList.Sum(e => e.Sales));
            TotalPaymentAmountStr = Convert.ToString(TopCustomersList.Sum(e => e.Payment));

            SetDefaultSearchSelection(this.JsonData);
        }
Example #2
0
        private void RefreshData()
        {
            ITopCustomersRepository pandsRepository = new TopCustomersRepository();
            String   sDate    = DateTime.Now.ToString();
            DateTime dateTime = DateTime.UtcNow.Date;
            var      quarter  = (dateTime.Month + 2) / 3;

            var lastQuarter = quarter - 1;

            if (lastQuarter == 0)
            {
                lastQuarter = 1;
            }
            DateTime datevalue = (Convert.ToDateTime(sDate.ToString()));

            this.JsonData = pandsRepository.GetLastSelectionData(Convert.ToInt32(ScreenId.TopCustomers));
            //this.TopCustomersList = pandsRepository.GetPandSList(null).OrderByDescending(x => x.Sales).ToList();
            this.TopCustomersList = pandsRepository.GetPandSList(this.JsonData).ToList();
            this.ShowAllCount     = this.TopCustomersList.Count();
            //this.ShowSelectedCount = 0;
            FullList = this.TopCustomersList.ToList();
            //DefaultList = this.TopCustomersList.ToList();
            this.TopCustomersListcmb = this.TopCustomersList.OrderBy(x => x.CustomerName).ToList();
            //this.TopCustomersListcmbCode = this.TopCustomersList.OrderBy(x => x.PandSCode).ToList();
            //this.TopCustomersListcmbCat1 = this.TopCustomersList.GroupBy(x => x.Category1).Select(e => e.First()).OrderBy(x => x.Category1).ToList();
            //this.TopCustomersListcmbCat2 = this.TopCustomersList.GroupBy(x => x.Category2).Select(e => e.First()).OrderBy(x => x.Category2).ToList();

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

            //this.ShowSelectedTrue = false;


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

            TotalSalesAmountStr   = Convert.ToString(TopCustomersList.Sum(e => e.Sales));
            TotalPaymentAmountStr = Convert.ToString(TopCustomersList.Sum(e => e.Payment));

            SetDefaultSearchSelection();
        }
        }//end

        void GetOptionsandTaxValues()
        {
            OptionsEntity           oData           = new OptionsEntity();
            ITopCustomersRepository pandsRepository = new TopCustomersRepository();

            oData = pandsRepository.GetOptionDetails();
            if (oData != null)
            {
                this.CurrencyName   = oData.CurrencyCode;   //there is no currency name field in database
                this.CurrencyCode   = oData.CurrencyCode;
                this.CurrencyFormat = oData.NumberFormat;
                this.DateFormat     = oData.DateFormat;
                this.DecimalPlaces  = oData.DecimalPlaces;
                if (oData.ShowAmountIncGST == true)
                {
                    this.ShowIncTaxTrue = true;
                    this.ShowExcTaxTrue = false;
                }
                else
                {
                    this.ShowIncTaxTrue = false;
                    this.ShowExcTaxTrue = true;
                    int decimalpoints = Convert.ToInt32(DecimalPlaces);
                }
            }
            else
            {
                this.CurrencyName   = "USD";
                this.CurrencyCode   = "USD";
                this.CurrencyFormat = "en-US";
                this.DateFormat     = "dd/MM/yyyy";
            }
            var objDefaultTax = pandsRepository.GetTaxes().FirstOrDefault();

            if (objDefaultTax != null)
            {
                this.TaxName = objDefaultTax.TaxName;
            }
            else
            {
                this.TaxName = "GST";
            }
        }
        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;

                ITopCustomersRepository casRepository = new TopCustomersRepository();
                var results = casRepository.SaveSearchJson(jsonSearch, Convert.ToInt32(ScreenId.TopCustomers), "TopCustomers_List");
                if (Count != 0)
                {
                    this.TopCustomersList = casRepository.GetPandSList(jsonSearch);
                }
                TotalSalesAmountStr      = Convert.ToString(TopCustomersList.Sum(e => e.Sales));
                TotalPaymentAmountStr    = Convert.ToString(TopCustomersList.Sum(e => e.Payment));
                this.TopCustomersListcmb = this.TopCustomersList.OrderBy(e => e.CustomerName).ToList();
                //this.TopCustomersListDate = this.TopCustomersList.GroupBy(x => x.CountAndAdjustStockDateDatetime).Select(y => y.First()).OrderBy(x => x.CountAndAdjustStockDateDatetime).Distinct().ToList();
                //this.TopCustomersListSCNo = casRepository.GetAllStockCount().OrderBy(e => e.TopCustomersListSCNo).ToList();
                //this.TopCustomersListAmount = 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.TopCustomersList.Count();
                }
                DefaultList = this.TopCustomersListcmb;
            }
        }