Exemple #1
0
        /// <summary>
        /// Method BindGridDetails to bind the grid.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>void</returns>
        public void BindGridDetails(object obj)
        {
            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            try
            {
                if (obj == null)
                {
                    CurrentPageIndex = 0;
                }
                if (CurrentPageIndex == 0)
                {
                    Application.Current.Properties["FindUserGridLastScrollOffset"] = 0;
                    Application.Current.Properties["FindUserGridCurrentPageIndex"] = 0;
                }
                // creating the object of service property
                AppWorksService.Properties.BillingProp objBillingProp = new AppWorksService.Properties.BillingProp();
                if (vin != null)
                {
                    objBillingProp.Vin = Vin;
                }
                else
                {
                    objBillingProp.Vin = string.Empty;
                }

                objBillingProp.CustomerName     = CustomerName;
                objBillingProp.InvoiceStatus    = SelectedInvoiceStatus;
                objBillingProp.InvoiceType      = SelectedInvoiceType;
                objBillingProp.InvoiceNumber    = InvoiceNumber;
                objBillingProp.Vin              = Vin;
                objBillingProp.CustomerNumber   = CustomerNumber;
                objBillingProp.CustIndent       = CustIndent;
                objBillingProp.CreatedBetwDtFrm = CreatedBetwDtFrm;
                if (CreatedBetwDtTo != null)
                {
                    objBillingProp.CreatedBetwDtTo = CreatedBetwDtTo.Value.AddDays(1);
                }
                objBillingProp.DtInvBetwDtFrm = DtInvBetwDtFrm;
                if (DtInvBetwDtTo != null)
                {
                    objBillingProp.DtInvBetwDtTo = DtInvBetwDtTo.Value.AddDays(1);
                }
                objBillingProp.DtPaidBetwDtFrm = DtPaidBetwDtFrm;
                if (DtPaidBetwDtTo != null)
                {
                    objBillingProp.DtPaidBetwDtTo = DtPaidBetwDtTo.Value.AddDays(1);
                }
                objBillingProp.CurrentPageIndex = CurrentPageIndex;
                objBillingProp.PageSize         = CurrentPageIndex > 0 ? _GridPageSizeOnScroll : _GridPageSize;
                objBillingProp.DefaultPageSize  = _GridPageSize;

                //objBillingProp.Driver = SelectedDriverList;
                //objBillingProp.OutsideCarrier = SelectedoutsideCarrier;
                //objBillingProp.LoadNumber = LoadNumber;
                //objBillingProp.OrderNumber = OrderNumber;
                //objBillingProp.PONumber = PONumber;

                var data = _serviceInstance.BillingSearch(objBillingProp);

                IEnumerable <BillingModel> model = new List <BillingModel>();

                model = data.Select(d => new BillingModel()
                {
                    BillingID      = d.BillingID,
                    InvoiceNumber  = d.InvoiceNumber,
                    CustomerName   = d.CustomerName,
                    CustomerNumber = d.CustomerNumber,
                    VIN            = d.Vin,
                    CustIndent     = d.CustIndent,
                    InvoiceDate    = d.InvoiceDate,
                    InvoiceStatus  = d.InvoiceStatus,
                    InvoiceType    = d.InvoiceType,
                    Address        = d.CustomerAddress,
                    TotalPageCount = d.TotalPageCount
                                     //LoadNumber = d.LoadNumber,
                                     //OutsideCarrier = d.OutsideCarrier,
                                     //Driver = d.Driver,
                                     //CarrierName = d.CarrierName,
                                     //PONumber = d.PONumber,
                                     //OrderNumber = d.OrderNumber,
                });

                if (CurrentPageIndex == 0)
                {
                    BillingList = null;
                    BillingList = new ObservableCollection <BillingModel>(model);
                }
                else
                {
                    if (BillingList != null && BillingList.Count > 0)
                    {
                        foreach (BillingModel ud in new ObservableCollection <BillingModel>(model))
                        {
                            App.Current.Dispatcher.Invoke(() =>
                            {
                                BillingList.Add(ud);
                            });
                        }
                    }
                }

                if (BillingList.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault() != null)
                {
                    Count = BillingList.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault().TotalPageCount;
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }