public void LoadSearchResult(string Suppliername)
        {
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            this.ShowAllCount          = purchaseRepository.GetAllPurQuotation().Count();
            this.PurchaseQuotationList = purchaseRepository.GetAllPurQuotation().Where(x => x.SupplierName == Suppliername).ToList();
        }
        private void RefreshData()
        {
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            this.DateFormat   = purchaseRepository.GetDateFormat();
            this.ShowAllCount = purchaseRepository.GetAllPurQuotation().Count();
            GetOptionsandTaxValues();
            this.JsonData = purchaseRepository.GetLastSelectionData(Convert.ToInt32(ScreenId.PurchaseQuotationList));
            this.PurchaseQuotationList    = purchaseRepository.GetAllPurQuotationJson(this.JsonData, this.IncludingGSTTrue).OrderBy(e => e.SupplierName).ToList();
            this.ShowSelectedCount        = this.PurchaseQuotationList.Count();
            this.PurchaseQuotationListcmb = purchaseRepository.GetAllPurQuotation().OrderBy(x => x.SupplierName).ToList();
            this.PurchaseQuotationListSup = this.PurchaseQuotationList.GroupBy(x => x.SupplierName).Select(y => y.First()).OrderBy(x => x.SupplierName).Distinct().ToList();

            this.YearRange = purchaseRepository.GetYearRange().ToList();
            //changedateformat(this.PurchaseQuotationList);
            changeNumberformat(this.PurchaseQuotationList);
            changeNumberformat(this.PurchaseQuotationListcmb);
            this.PurchaseQuotationListQno = purchaseRepository.GetAllPurQuotation().OrderBy(e => e.SortQuotationNo).ToList();
            DefaultList = this.PurchaseQuotationListcmb;
            FullPQList  = this.PurchaseQuotationListcmb;
            //this.ShowAllCount = this.PurchaseQuotationListcmb.Count();
            SetDefaultSearchSelection(this.JsonData);
            var    Updateddate = this.PurchaseQuotationListcmb.Max(x => x.CreatedDateList);
            string date        = this.DateFormat as string;

            this.LastUpdateDate  = Convert.ToDateTime(Updateddate).ToString(date);
            TotalQuotationAmount = Convert.ToString(PurchaseQuotationList.Sum(e => e.QAmount));
            //this.GetData(this.SelectedSearchSupplier);
        }
        void showexcGST(object param)
        {
            int decimalpoints = Convert.ToInt32(this.DecimalPlaces);
            //foreach (var item in this.PurchaseQuotationList)
            //{
            //    //item.QuotationAmount = item.QuotationAmountExcGST;
            //    item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmountExcGST), decimalpoints).ToString();
            //}
            //if (this.ShowAllTrue == false)
            //    this.PurchaseQuotationList = DefaultList.Where(x => x.ExcIncGST == false).ToList();
            //else
            //    this.PurchaseQuotationList = FullPQList.Where(x => x.ExcIncGST == false).ToList();
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            this.PurchaseQuotationList = purchaseRepository.GetAllPurQuotationJson(this.JsonData, this.IncludingGSTTrue).ToList();

            if (this.ShowAllTrue == false)
            {
                this.ShowSelectedCount = this.PurchaseQuotationList.Count();
            }
            else
            {
                this.ShowSelectedCount = 0;
            }
            this.PurchaseQuotationListcmb = this.PurchaseQuotationList.OrderBy(e => e.SupplierName).ToList();
            this.PurchaseQuotationListSup = this.PurchaseQuotationList.GroupBy(x => x.SupplierName).Select(y => y.First()).OrderBy(x => x.SupplierName).Distinct().ToList();
            this.PurchaseQuotationListQno = purchaseRepository.GetAllPurQuotation().OrderBy(e => e.SortQuotationNo).ToList();
            DefaultList = this.PurchaseQuotationListcmb;
            //changedateformat(this.PurchaseQuotationList);
            //changeNumberformat(this.PurchaseQuotationList);
        }
        private void LoadUserSecurityBackground(object sender, DoWorkEventArgs e)
        {
            int  minHeight   = 300;
            int  headerRows  = 180;//180+40+30+10;
            var  height      = System.Windows.SystemParameters.PrimaryScreenHeight - headerRows - 512;
            bool validHeight = int.TryParse(height.ToString(), out minHeight);

            this.UserGridHeight = minHeight;
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            this.DateFormat = purchaseRepository.GetDateFormat();
        }
        /// <summary>
        /// Loads the product models background.
        /// </summary>
        public void LoadOptionsBackground()
        {
            SelectedOptions = null; // Unselects last selection. Essential, as assignment below won't clear other control's SelectedItems
            var Options = new OptionsEntity();

            IOptionsService OptionsDetails = new OptionsService();
            var             results        = OptionsDetails.GetOptionsDetails();

            results.ShowAmountIncGST = true;


            int  minHeight   = 300;
            int  headerRows  = 490;//180+40+30+10;
            var  height      = System.Windows.SystemParameters.PrimaryScreenHeight - headerRows - 155;
            bool validHeight = int.TryParse(height.ToString(), out minHeight);

            results.OptionGridHeight = minHeight;
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            this.DateFormat = purchaseRepository.GetDateFormat();

            SelectedOptions = results;
            //int compId = 0;
            Mouse.OverrideCursor = Cursors.Wait;

            //run time-consuming operations on a background thread
            BackgroundWorker worker = new BackgroundWorker();

            //Set the WorkerReportsProgress property to true if you want the BackgroundWorker to support progress updates.
            //When this property is true, user code can call the ReportProgress method to raise the ProgressChanged event.
            worker.WorkerReportsProgress = true;

            //This event is raised when you call the RunWorkerAsync method. This is where you start the time-consuming operation.
            worker.DoWork += new DoWorkEventHandler(this.LoadOptionsBackground);

            // This event is raised when you call the ReportProgress method.
            //worker.ProgressChanged += new ProgressChangedEventHandler(this.LoadProductsBackgroundProgress);

            //The RunWorkerCompleted event is raised when the background worker has completed.
            //Depending on whether the background operation completed successfully, encountered an error,
            //or was canceled, update the user interface accordingly
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.LoadOptionsBackgroundComplete);

            //Starts running a background operation
            worker.RunWorkerAsync();
        }
예제 #6
0
        public void GetPurchaseInvoice(string pqNo)
        {
            OptionsEntity oData = new OptionsEntity();
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            oData = purchaseRepository.GetOptionSettings();
            // Mouse.OverrideCursor = Cursors.Wait;
            PurchaseInvoiceForm pqf = pqRepository.GetPurchaseInvoice(pqNo);

            if (pqf.Invoice != null)
            {
                this.ID             = pqf.Invoice.ID;
                this.InvoiceNo      = pqf.Invoice.InvoiceNo;
                this.OurPONo        = pqf.Invoice.OurPONo;
                this.InvoiceDateStr = pqf.Invoice.InvoiceDate.ToString(oData.DateFormat);
                DateTime Dateinstr = (DateTime)pqf.Invoice.PaymentDueDate;
                this.PaymentDueDateStr = Dateinstr.ToString(oData.DateFormat);

                this.SelectedSupplierID = pqf.Invoice.SupplierID;
                if (this.SelectedSupplierID > 0)
                {
                    GetSupplierDetails();
                }

                this.TermsAndConditions = pqf.Invoice.TermsAndConditions;

                this.TotalBeforeTax    = pqf.Invoice.TotalBeforeTax;
                this.TotalTax          = pqf.Invoice.TotalTax;
                this.TotalAfterTax     = pqf.Invoice.TotalAfterTax;
                this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax);
                this.TotalTaxStr       = Convert.ToString(TotalTax);
                this.TotalAfterTaxStr  = Convert.ToString(TotalAfterTax);

                if (pqf.Invoice.ExcIncGST == true)
                {
                    ExcludingTax = false;
                    IncludingTax = true;
                    //  PQDEntity.GSTRate = 0;
                }
                else
                {
                    ExcludingTax = true;
                    IncludingTax = false;
                    // PQDEntity.GSTRate = TaxRate;
                }
                this.PIStatus = pqf.Invoice.PIStatus;
                if (this.PIStatus == Convert.ToByte(PI_Status.Paid))
                {
                    AllFieldsReadonly = true;
                    AllFieldsEnabled  = false;
                }
                else
                {
                    AllFieldsReadonly = false;
                    AllFieldsEnabled  = true;
                }

                this.BEDetailsEntity = new ObservableCollection <AccountDataGridViewModel>();
                if (pqf.BEInvoiceDetails.Count() > 0)
                {
                    foreach (var item in pqf.BEInvoiceDetails)
                    {
                        AccountDataGridViewModel pqEntity = new AccountDataGridViewModel(AccountsList);
                        pqEntity.SelectedAccountName = item.AccountName;

                        var acc = Accounts.Where(e => e.AccountName == item.AccountName).FirstOrDefault();
                        if (acc != null)
                        {
                            pqEntity.SelectedAccountId = acc.AccountID;
                        }
                        pqEntity.PQAmount    = item.PQAmount;
                        pqEntity.PQAmountStr = Convert.ToString(item.PQAmount);
                        pqEntity.GSTRate     = item.GSTRate;
                        pqEntity.Description = item.Description;
                        var tax = Taxes.Where(e => e.TaxRate == item.GSTRate).FirstOrDefault();
                        if (tax != null)
                        {
                            pqEntity.SelectedTaxID = tax.TaxID;
                        }
                        BEDetailsEntity.Add(pqEntity);
                    }
                }
                else
                {
                    var row = new AccountDataGridViewModel(AccountsList);
                    BEDetailsEntity.Add(row);
                    OnPropertyChanged("BEDetailsEntity");
                }
            }
            else
            {
                GetNewPQ();
            }
        }
        void GetOptionsandTaxValues()
        {
            OptionsEntity oData = new OptionsEntity();
            IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();

            oData = purchaseRepository.GetOptionSettings();
            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.IncludingGSTTrue  = true;
                    this.IncludingGSTFalse = false;
                    //int decimalpoints = Convert.ToInt32(DecimalPlaces);
                    //foreach (var item in this.PurchaseQuotationList)
                    //{
                    //    item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmount), decimalpoints).ToString();
                    //}
                    //this.PurchaseQuotationList = this.PurchaseQuotationList.Where(x => x.ExcIncGST == true).ToList();
                }
                else
                {
                    this.IncludingGSTTrue  = false;
                    this.IncludingGSTFalse = true;
                    int decimalpoints = Convert.ToInt32(DecimalPlaces);
                    //foreach (var item in this.PurchaseQuotationList)
                    //{
                    //    //item.QuotationAmount = item.QuotationAmountExcGST;
                    //    //item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmountExcGST), decimalpoints).ToString();
                    //    item.QuotationAmount = Math.Round(Convert.ToDouble(item.QuotationAmount), decimalpoints).ToString();
                    //}
                    //commented on 23 May 2017
                    //if (this.PurchaseQuotationList != null)
                    //    this.PurchaseQuotationList = this.PurchaseQuotationList.Where(x => x.ExcIncGST == false).ToList();
                }
            }
            else
            {
                this.CurrencyName   = "USD";
                this.CurrencyCode   = "USD";
                this.CurrencyFormat = "en-US";
                this.DateFormat     = "dd/MM/yyyy";
            }



            //var objDefaultTax = new List<TaxModel>();
            var objDefaultTax = purchaseRepository.GetDefaultTaxes().FirstOrDefault();

            if (objDefaultTax != null)
            {
                this.TaxName = objDefaultTax.TaxName;
                //this.TaxName = objDefaultTax.TaxRate;
            }
            else
            {
                this.TaxName = "GST";
                //this.TaxRate = 0;
            }
        }
        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.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PurchaseQuotationListcmb = 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.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PurchaseQuotationListcmb = 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.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PurchaseQuotationListcmb = 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.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == true).ToList();
                    //else
                    //    this.PurchaseQuotationListInternal = DefaultList.Where(x => x.ExcIncGST == false).ToList();
                    //this.PurchaseQuotationListcmb = 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.PurchaseQuotationList = this.PurchaseQuotationListInternal;
                jsonSearch    = JsonConvert.SerializeObject(SearchValues);
                this.JsonData = jsonSearch;

                IPurchaseQuotationListRepository purchaseRepository = new PurchaseQuotationListRepository();
                var results = purchaseRepository.SaveSearchJson(jsonSearch, Convert.ToInt32(ScreenId.PurchaseQuotationList), "Purhcase_Quotation_List");
                if (Count != 0)
                {
                    this.PurchaseQuotationList = purchaseRepository.GetAllPurQuotationJson(jsonSearch, this.IncludingGSTTrue);
                    //changedateformat(this.PurchaseQuotationList);
                    changeNumberformat(this.PurchaseQuotationList);
                }

                this.PurchaseQuotationListcmb = this.PurchaseQuotationList.OrderBy(e => e.SupplierName).ToList();
                this.PurchaseQuotationListSup = this.PurchaseQuotationList.GroupBy(x => x.SupplierName).Select(y => y.First()).OrderBy(x => x.SupplierName).Distinct().ToList();
                this.PurchaseQuotationListQno = PurchaseQuotationList.OrderBy(e => e.SortQuotationNo).ToList();
                if (this.ShowAllTrue == true)
                {
                    this.ShowSelectedCount = 0;
                }
                else
                {
                    this.ShowSelectedCount = this.PurchaseQuotationList.Count();
                }
                DefaultList = this.PurchaseQuotationListcmb;

                TotalQuotationAmount = Convert.ToString(this.PurchaseQuotationList.Sum(e => e.QAmount));
            }
        }