Example #1
0
        public PrintRentForm(SqlConnection connection)
        {
            InitializeComponent();

            RentDataViewer.Reset();

            DataTable rentData     = CarRentalDbWorker.RentToPrintData(connection);
            string    currentUser  = rentData.Rows[0][rentData.Columns[3]].ToString();
            DataTable customerData = CarRentalDbWorker.RentCustomerToPrintData(connection, currentUser);
            string    currentCar   = rentData.Rows[0][rentData.Columns[4]].ToString();
            DataTable carsData     = CarRentalDbWorker.RentCarToPrintData(connection, currentCar);

            ReportDataSource RentDataSource     = new ReportDataSource("RentData", rentData);
            ReportDataSource CustomerDataSource = new ReportDataSource("CustomerData", customerData);
            ReportDataSource CarDataSource      = new ReportDataSource("CarData", carsData);

            RentDataViewer.LocalReport.DataSources.Add(RentDataSource);
            RentDataViewer.LocalReport.DataSources.Add(CustomerDataSource);
            RentDataViewer.LocalReport.DataSources.Add(CarDataSource);

            RentDataViewer.LocalReport.ReportEmbeddedResource = "CarRentDBApp.RentReport.rdlc";
            RentDataViewer.RefreshReport();

            ShowActivated = true;
            Show();
        }