Пример #1
0
 public override void PopulateData()
 {
     try
     {
         string   Message         = string.Empty;
         DateTime?dtFrom          = dtpFromDate.Value.ToDateorNull();
         DateTime?dtTill          = dtpToDate.Value.ToDateorNull();
         int      BookingStatusId = 0;
         string   MonthCommencing = string.Empty;
         if (dtFrom.Value == null)
         {
             Message = "Required : From Date";
         }
         if (dtTill.Value == null)
         {
             if (!string.IsNullOrEmpty(Message))
             {
                 Message = "Required : To Date";
             }
             else
             {
                 Message += Environment.NewLine;// "Required : To Date";
                 Message += "Required : To Date";
             }
         }
         if (!string.IsNullOrEmpty(Message))
         {
             ENUtils.ShowMessage(Message);
             return;
         }
         MonthCommencing = string.Format("{0:dd/MM/yyyy}", dtFrom.Value) + "-" + string.Format("{0:dd/MM/yyyy}", dtTill.Value);
         if (opAll.IsChecked)
         {
             BookingStatusId = 0;
         }
         if (opCompleted.IsChecked)
         {
             BookingStatusId = Enums.BOOKINGSTATUS.DISPATCHED.ToInt();
         }
         if (opCancelled.IsChecked)
         {
             BookingStatusId = Enums.BOOKINGSTATUS.CANCELLED.ToInt();
         }
         using (TaxiDataContext db = new TaxiDataContext())
         {
             var list = db.stp_OperatorVehicleRecord(ddlSubCompany.SelectedValue.ToInt(), dtFrom.Value, dtTill.Value + TimeSpan.Parse("23:59:59"), BookingStatusId, MonthCommencing).ToList();
             grdLister.DataSource = list;
         }
         grdLister.Columns["Id"].IsVisible                       = false;
         grdLister.Columns["BookingNo"].IsVisible                = false;
         grdLister.Columns["DriverId"].IsVisible                 = false;
         grdLister.Columns["MonthCommencing"].HeaderText         = "Month Commencing";
         grdLister.Columns["OperatorLicenceNumber"].HeaderText   = "Operator Licence Number";
         grdLister.Columns["OperatorLicenceNumber"].Width        = 200;
         grdLister.Columns["MonthCommencing"].Width              = 160;
         grdLister.Columns["OperatorName"].HeaderText            = "Operator Name";
         grdLister.Columns["VehicleRegistrationMark"].HeaderText = "Vehicle Registration Mark";
         grdLister.Columns["VehicleMake"].HeaderText             = "Vehicle Make";
         grdLister.Columns["OperatorName"].Width                 = 170;
         grdLister.Columns["VehicleMake"].Width                  = 150;
         grdLister.Columns["VehicleRegistrationMark"].Width      = 200;
         //grdLister.Columns["Total"].Width = 130;
         //grdLister.Columns["DriverNo"].Width = 120;
         //Active
     }
     catch (Exception ex)
     {
         ENUtils.ShowMessage(ex.Message);
     }
 }
Пример #2
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            try
            {
                if (DialogResult.OK == saveFileDialog1.ShowDialog())
                {
                    if (radGridView1 == null)
                    {
                        InitializeExportGrid();
                    }


                    radGridView1.Columns.Clear();
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("MonthCommencing", "MonthCommencing"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("OperatorLicenceNumber", "OperatorLicenceNumber"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("OperatorName", "OperatorName"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("VehicleRegistrationMark", "VehicleRegistrationMark"));
                    radGridView1.Columns.Add(new GridViewTextBoxColumn("VehicleMake", "VehicleMake"));
                    //
                    string   Message         = string.Empty;
                    DateTime?dtFrom          = dtpFromDate.Value.ToDateorNull();
                    DateTime?dtTill          = dtpToDate.Value.ToDateorNull();
                    int      BookingStatusId = 0;
                    string   MonthCommencing = string.Empty;
                    if (dtFrom.Value == null)
                    {
                        Message = "Required : From Date";
                    }
                    if (dtTill.Value == null)
                    {
                        if (!string.IsNullOrEmpty(Message))
                        {
                            Message = "Required : To Date";
                        }
                        else
                        {
                            Message += Environment.NewLine;// "Required : To Date";
                            Message += "Required : To Date";
                        }
                    }
                    if (!string.IsNullOrEmpty(Message))
                    {
                        ENUtils.ShowMessage(Message);
                        return;
                    }
                    MonthCommencing = string.Format("{0:dd/MM/yyyy}", dtFrom.Value) + "-" + string.Format("{0:dd/MM/yyyy}", dtTill.Value);
                    if (opAll.IsChecked)
                    {
                        BookingStatusId = 0;
                    }
                    if (opCompleted.IsChecked)
                    {
                        BookingStatusId = Enums.BOOKINGSTATUS.DISPATCHED.ToInt();
                    }
                    if (opCancelled.IsChecked)
                    {
                        BookingStatusId = Enums.BOOKINGSTATUS.CANCELLED.ToInt();
                    }
                    //

                    using (TaxiDataContext db = new TaxiDataContext())
                    {
                        var list = db.stp_OperatorVehicleRecord(ddlSubCompany.SelectedValue.ToInt(), dtFrom.Value, dtTill.Value + TimeSpan.Parse("23:59:59"), BookingStatusId, MonthCommencing).ToList();  // grdLister.DataSource = list;



                        radGridView1.RowCount = list.Count;
                        for (int i = 0; i < list.Count; i++)
                        {
                            radGridView1.Rows[i].Cells["MonthCommencing"].Value         = list[i].MonthCommencing;
                            radGridView1.Rows[i].Cells["OperatorLicenceNumber"].Value   = list[i].OperatorLicenceNumber;
                            radGridView1.Rows[i].Cells["OperatorName"].Value            = list[i].OperatorName;
                            radGridView1.Rows[i].Cells["VehicleRegistrationMark"].Value = list[i].VehicleRegistrationMark;
                            radGridView1.Rows[i].Cells["VehicleMake"].Value             = list[i].VehicleMake;

                            //  radGridView1.Rows[i].Cells["Telephone"].ViewInfo.;
                            //radGridView1.Rows[i].Cells["Telephone"].Value = (radGridView1.Rows[i].Cells["Telephone"].Value.ToString().Replace(".", ""));
                        }
                    }

                    // this.radGridView1.Columns["Telephone"].ExcelExportType = DisplayFormatType.Fixed;
                    //this.radGridView1.Columns["Telephone"].ExcelExportType = DisplayFormatType.Custom;
                    ExportToExcelML export = new ExportToExcelML(this.radGridView1);
                    export.ExportVisualSettings = true;
                    export.HiddenColumnOption   = HiddenOption.ExportAsHidden;
                    export.HiddenColumnOption   = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport;
                    export.ExcelCellFormatting += new Telerik.WinControls.UI.Export.ExcelML.ExcelCellFormattingEventHandler(export_ExcelCellFormatting);
                    //

                    //
                    //radGridView1.Columns["PickupDate"].HeaderText = "Pickup Date-Time";

                    //radGridView1.Columns["From"].HeaderText = "Pick-up Address";
                    //radGridView1.Columns["To"].HeaderText = "Drop-off Address";
                    radGridView1.Columns["MonthCommencing"].HeaderText         = "Month Commencing";
                    radGridView1.Columns["OperatorLicenceNumber"].HeaderText   = "Operator Licence Number";
                    radGridView1.Columns["OperatorName"].HeaderText            = "Operator Name";
                    radGridView1.Columns["VehicleRegistrationMark"].HeaderText = "Vehicle Registration Mark";
                    radGridView1.Columns["VehicleMake"].HeaderText             = "Vehicle Make";

                    //CompanyName
                    exporter = new RadGridViewExcelExporter();

                    BackgroundWorker worker = new BackgroundWorker();
                    worker.DoWork             += new DoWorkEventHandler(worker_DoWork);
                    worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bg_RunWorkerCompleted);
                    worker.RunWorkerAsync(saveFileDialog1.FileName);
                    exporter.Progress += new ProgressHandler(exportProgress);

                    this.btnExport.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                ENUtils.ShowMessage(ex.Message);
            }
        }
        //Operator Vehicle recod

        private void OperatorVehicleRecod()
        {
            try
            {
                string   Message         = string.Empty;
                DateTime?dtFrom          = dtpFromDate2.Value.ToDateorNull();
                DateTime?dtTill          = dtpToDate2.Value.ToDateorNull();
                int      BookingStatusId = 0;
                string   MonthCommencing = string.Empty;
                if (dtFrom.Value == null)
                {
                    Message = "Required : From Date";
                }
                if (dtTill.Value == null)
                {
                    if (!string.IsNullOrEmpty(Message))
                    {
                        Message = "Required : To Date";
                    }
                    else
                    {
                        Message += Environment.NewLine;// "Required : To Date";
                        Message += "Required : To Date";
                    }
                }
                if (!string.IsNullOrEmpty(Message))
                {
                    RadMessageBox.Show(Message);
                    return;
                }
                MonthCommencing = string.Format("{0:dd/MM/yyyy}", dtFrom.Value) + "-" + string.Format("{0:dd/MM/yyyy}", dtTill.Value);
                if (rdoAll2.IsChecked)
                {
                    BookingStatusId = 0;
                }
                if (rdoCompleted2.IsChecked)
                {
                    BookingStatusId = 2;
                }
                if (rdoCanceled2.IsChecked)
                {
                    BookingStatusId = 3;
                }
                using (TaxiDataContext db = new TaxiDataContext())
                {
                    var list = db.stp_OperatorVehicleRecord(ddlSubCompany2.SelectedValue.ToInt(), dtFrom.Value, dtTill.Value + TimeSpan.Parse("23:59:59"), BookingStatusId, MonthCommencing).ToList();
                    grdOperatorVehicleRecord.DataSource = list;
                }
                grdOperatorVehicleRecord.Columns["Id"].IsVisible                       = false;
                grdOperatorVehicleRecord.Columns["BookingNo"].IsVisible                = false;
                grdOperatorVehicleRecord.Columns["DriverId"].IsVisible                 = false;
                grdOperatorVehicleRecord.Columns["DriverNo"].IsVisible                 = false;
                grdOperatorVehicleRecord.Columns["DriverName"].IsVisible               = false;
                grdOperatorVehicleRecord.Columns["MonthCommencing"].HeaderText         = "Month Commencing";
                grdOperatorVehicleRecord.Columns["OperatorLicenceNumber"].HeaderText   = "Operator Licence Number";
                grdOperatorVehicleRecord.Columns["OperatorLicenceNumber"].Width        = 170;
                grdOperatorVehicleRecord.Columns["MonthCommencing"].Width              = 160;
                grdOperatorVehicleRecord.Columns["OperatorName"].HeaderText            = "Operator Name";
                grdOperatorVehicleRecord.Columns["VehicleRegistrationMark"].HeaderText = "Vehicle Registration Mark";
                grdOperatorVehicleRecord.Columns["VehicleMake"].HeaderText             = "Vehicle Make";
                grdOperatorVehicleRecord.Columns["OperatorName"].Width                 = 170;
                grdOperatorVehicleRecord.Columns["VehicleMake"].Width                  = 150;
                grdOperatorVehicleRecord.Columns["VehicleRegistrationMark"].Width      = 170;
                grdOperatorVehicleRecord.Columns["PHCVehicle"].Width                   = 130;
                grdOperatorVehicleRecord.Columns["PHCVehicle"].HeaderText              = "PHC Vehicle";
            }
            catch (Exception ex)
            {
                RadMessageBox.Show(ex.Message);
            }
        }