Пример #1
0
 public override void PopulateData()
 {
     try
     {
         string FromPostCode = null;
         string ToPostCode   = null;
         int    FromLocId    = 0;
         int    ToLocId      = 0;
         int    FromZoneId   = 0;
         int    ToZoneId     = 0;
         if (rbtnPostCode.IsChecked == true)
         {
             string PostCode = txtPostCode.Text.Trim();
             if (string.IsNullOrEmpty(PostCode))
             {
                 ENUtils.ShowMessage("Requierd : Post Code");
                 return;
             }
             if (rbtnPickup.IsChecked == true)
             {
                 FromPostCode = PostCode;
             }
             else if (rbtnDestination.IsChecked == true)
             {
                 ToPostCode = PostCode;
             }
             else
             {
                 FromPostCode = PostCode;
                 ToPostCode   = PostCode;
             }
         }
         else if (rbtnLocation.IsChecked == true)
         {
             int LocationId = ddlLocation.SelectedValue.ToInt();
             if (LocationId == 0)
             {
                 ENUtils.ShowMessage("Requierd : Loaction Code");
                 return;
             }
             if (rbtnPickup.IsChecked == true)
             {
                 FromLocId = LocationId;
             }
             else if (rbtnDestination.IsChecked == true)
             {
                 ToLocId = LocationId;
             }
             else
             {
                 ToLocId   = LocationId;
                 FromLocId = LocationId;
             }
         }
         else
         {
             int ZoneId = ddlArea.SelectedValue.ToInt();
             if (ZoneId == 0)
             {
                 ENUtils.ShowMessage("Requierd : Area Code");
                 return;
             }
             if (rbtnPickup.IsChecked == true)
             {
                 FromZoneId = ZoneId;
             }
             else if (rbtnDestination.IsChecked == true)
             {
                 ToZoneId = ZoneId;
             }
             else
             {
                 FromZoneId = ZoneId;
                 ToZoneId   = ZoneId;
             }
         }
         using (TaxiDataContext db = new TaxiDataContext())
         {
             var list = db.stp_JobStatistics(FromPostCode, ToPostCode, FromLocId, ToLocId, FromZoneId, ToZoneId, fromDate.Value.ToDate(), tillDate.Value.ToDate()).ToList();
             if (list.Count() > 0)
             {
                 grdJobsStatistics.Columns.Clear();
                 grdJobsStatistics.DataSource = list;
                 grdJobsStatistics.Columns["BookingNo"].Width           = 150;
                 grdJobsStatistics.Columns["PickupDateTime"].Width      = 145;
                 grdJobsStatistics.Columns["VehicleType"].Width         = 130;
                 grdJobsStatistics.Columns["FromAddress"].Width         = 280;
                 grdJobsStatistics.Columns["ToAddress"].Width           = 280;
                 grdJobsStatistics.Columns["DriverName"].Width          = 130;
                 grdJobsStatistics.Columns["StatusName"].Width          = 130;
                 grdJobsStatistics.Columns["BookingNo"].HeaderText      = "Booking No";
                 grdJobsStatistics.Columns["PickupDateTime"].HeaderText = "Pickup Date Time";
                 grdJobsStatistics.Columns["VehicleType"].HeaderText    = "Vehicle Type";
                 grdJobsStatistics.Columns["FromAddress"].HeaderText    = "From Address";
                 grdJobsStatistics.Columns["ToAddress"].HeaderText      = "To Address";
                 grdJobsStatistics.Columns["DriverName"].HeaderText     = "Driver Name";
                 grdJobsStatistics.Columns["StatusName"].HeaderText     = "Status";
             }
             else
             {
                 grdJobsStatistics.Columns.Clear();
                 grdJobsStatistics.Rows.Clear();
                 FormatGrid();
             }
             lblTotalJobs.Text = "Total Jobs : " + grdJobsStatistics.Rows.Count();
         }
     }
     catch (Exception ex)
     {
         ENUtils.ShowMessage(ex.Message);
     }
 }