public override void PopulateData()
        {
            try
            {
                int    RangeId  = ddlDateRange.SelectedValue.ToInt();
                int    DriverId = ddlDriver.SelectedValue.ToInt();
                string Error    = string.Empty;
                if (RangeId == 0)
                {
                    Error = "Required: Date Range";
                }

                if (!string.IsNullOrEmpty(Error))
                {
                    ENUtils.ShowMessage(Error);
                    return;
                }
                int idx = 0;
                int val = 0;
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    //var list = (from a in db.stp_PaymentCollection()
                    //            select new
                    //            {
                    //                Id = a.Id,
                    //                Active = a.Active,
                    //                DriverNo = a.DriverNo,
                    //                DriverName = a.DriverName,
                    //                Rent = a.Rent,
                    //                Collection = a.PDA,
                    //                AgentCommission = a.AgentCommission,
                    //                OldAgentBalance = a.OldAgentBalance,
                    //                PerviousBalance = a.BalanceDue,
                    //                Adjustments=a.Adjustments,
                    //                Total = a.Total,
                    //                IsPaid = a.IsPaid,
                    //                TranId=a.TransId,
                    //                FromDate=  a.FromDate,
                    //               ToDate= a.ToDate,
                    //                Paid=a.IsPaid!=null && a.IsPaid==true ? "Paid" : ""
                    //            }).ToList();

                    //var list =(from a in db.stp_GetDriverCommissionCollectionHistory(RangeId, DriverId)
                    //               select new
                    //               {
                    //                   Id = a.Id,
                    //                   Active = a.Active,
                    //                   DriverNo = a.DriverNo,
                    //                   //DriverName = a.DriverName,
                    //                   Rent = a.RentComm,
                    //                   Collection = a.DriverCollection,
                    //                   AgentCommission = a.AgentCommission,
                    //                   OldAgentBalance = a.PreviousAgentCommission,
                    //                   PerviousBalance = a.PrevRentComm,
                    //                   Adjustments = a.Adjustment,
                    //                   Total = a.Total,
                    //                   IsPaid = a.IsPaid,
                    //                   TranId = a.TransId,
                    //                   FromDate = a.FromDate,
                    //                   ToDate = a.TillDate,
                    //                   Paid = a.IsPaid != null && a.IsPaid == true ? "Paid" : ""
                    //               }).ToList();
                    var list = (db.stp_GetDriverCommissionCollectionHistory(RangeId, DriverId)).ToList();

                    if (list.Count == 0)
                    {
                        grdLister.RowCount = 0;
                        return;
                    }
                    var list2 = (from a in list.AsEnumerable().OrderBy(item => item.DriverNo, new NaturalSortComparer <string>())
                                 select new
                    {
                        Id = a.Id,
                        Paid = a.IsPaid != null && a.IsPaid == true ? "Paid" : "",
                        IsPaid = a.IsPaid,
                        PreviousAgentCommission = a.PreviousAgentCommission,
                        PrevRentComm = a.PrevRentComm,
                        RentComm = a.RentComm,
                        TillDate = a.TillDate,
                        Total = a.Total,
                        TransId = a.TransId,
                        FromDate = a.FromDate,
                        DriverNo = a.DriverNo,
                        DriverCollection = a.DriverCollection,
                        PrevDriverCollection = a.PrevDriverCollection,

                        AgentCommission = a.AgentCommission,
                        Adjustment = a.Adjustment,
                        PrevAdjustment = a.PrevAdjustment,
                        Active = a.Active,
                    }).ToList();

                    idx = grdLister.CurrentRow != null ? grdLister.CurrentRow.Cells[COLS.Id].Value.ToInt() : -1;
                    val = grdLister.TableElement.VScrollBar.Value;



                    grdLister.BeginUpdate();
                    grdLister.RowCount = list2.Count;
                    for (int i = 0; i < list2.Count; i++)
                    {
                        grdLister.Rows[i].Cells[COLS.Id].Value       = list2[i].Id;
                        grdLister.Rows[i].Cells[COLS.Active].Value   = list2[i].Active;
                        grdLister.Rows[i].Cells[COLS.DriverNo].Value = list2[i].DriverNo;
                        //grdLister.Rows[i].Cells[COLS.DriverName].Value = list2[i].DriverName;


                        grdLister.Rows[i].Cells[COLS.Rent].Value     = list2[i].RentComm;
                        grdLister.Rows[i].Cells[COLS.PaidRent].Value = list2[i].IsPaid.ToBool() && list2[i].RentComm.ToDecimal() > 0 ? list2[i].RentComm.ToDecimal() : 0.00m;


                        grdLister.Rows[i].Cells[COLS.Collection].Value     = list2[i].DriverCollection;
                        grdLister.Rows[i].Cells[COLS.PaidCollection].Value = list2[i].IsPaid.ToBool() ? list2[i].DriverCollection.ToDecimal() : 0.00m;



                        grdLister.Rows[i].Cells[COLS.OldCollection].Value     = list2[i].PrevDriverCollection.ToDecimal();
                        grdLister.Rows[i].Cells[COLS.OldPaidCollection].Value = list2[i].IsPaid.ToBool() ? list2[i].PrevDriverCollection.ToDecimal() : 0.00m;


                        grdLister.Rows[i].Cells[COLS.AgentCommission].Value     = list2[i].AgentCommission;
                        grdLister.Rows[i].Cells[COLS.PaidAgentCommission].Value = list2[i].IsPaid.ToBool() ? list2[i].AgentCommission.ToDecimal() : 0.00m;


                        grdLister.Rows[i].Cells[COLS.OldAgentBalance].Value     = list2[i].PreviousAgentCommission.ToDecimal();
                        grdLister.Rows[i].Cells[COLS.PaidOldAgentBalance].Value = list2[i].IsPaid.ToBool() ? list2[i].PreviousAgentCommission.ToDecimal() : 0.00m;



                        grdLister.Rows[i].Cells[COLS.PreviousBalance].Value     = list2[i].PrevRentComm;
                        grdLister.Rows[i].Cells[COLS.PaidPreviousBalance].Value = list2[i].IsPaid.ToBool() && list2[i].PrevRentComm.ToDecimal() > 0 ? list2[i].PrevRentComm.ToDecimal() : 0.00m;


                        grdLister.Rows[i].Cells[COLS.Adjustment].Value     = list2[i].Adjustment.ToDecimal();
                        grdLister.Rows[i].Cells[COLS.PaidAdjustment].Value = list2[i].IsPaid.ToBool() ? list2[i].Adjustment.ToDecimal() : 0.00m;


                        grdLister.Rows[i].Cells[COLS.OldAdjustment].Value     = list2[i].PrevAdjustment.ToDecimal();
                        grdLister.Rows[i].Cells[COLS.OldPaidAdjustment].Value = list2[i].IsPaid.ToBool() ? list2[i].PrevAdjustment.ToDecimal() : 0.00m;


                        grdLister.Rows[i].Cells[COLS.Total].Value     = list2[i].Total;
                        grdLister.Rows[i].Cells[COLS.PaidTotal].Value = list2[i].IsPaid.ToBool() ? list2[i].Total.ToDecimal() : 0.00m;



                        grdLister.Rows[i].Cells[COLS.IsPaid].Value = list2[i].IsPaid;
                        grdLister.Rows[i].Cells[COLS.TranId].Value = list2[i].TransId;

                        grdLister.Rows[i].Cells[COLS.Paid].Value     = list2[i].Paid;
                        grdLister.Rows[i].Cells[COLS.FromDate].Value = list2[i].FromDate;
                        grdLister.Rows[i].Cells[COLS.ToDate].Value   = list2[i].TillDate;
                        grdLister.Rows[i].Cells["Check"].Value       = false;
                    }


                    grdLister.EndUpdate();
                }

                grdLister.Columns["FromDate"].IsVisible = false;
                grdLister.Columns["ToDate"].IsVisible   = false;
                grdLister.Columns["IsPaid"].IsVisible   = false;


                AddSummaries();
                UpdatePeriod();

                if (idx > 0)
                {
                    grdLister.CurrentRow = grdLister.Rows.FirstOrDefault(c => c.Cells[COLS.Id].Value.ToInt() == idx);
                }


                if (grdLister.TableElement.VScrollBar.Maximum >= val)
                {
                    grdLister.TableElement.VScrollBar.Value = val;
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }