private void wfhMain_Loaded(object sender, RoutedEventArgs e)
        {
            ReportDataSource nwReportDataSource = new ReportDataSource();
            DaySheetSchedule dataSet            = new DaySheetSchedule();

            dataSet.BeginInit();

            nwReportDataSource.Name  = "DataSet1";
            nwReportDataSource.Value = dataSet.spInstructorSchedule;
            rptViewer.LocalReport.DataSources.Add(nwReportDataSource);

            var startupPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            var reportPath  = System.IO.Path.Combine(startupPath, @"Report\InstructorDaySheet.rdlc");

            this.rptViewer.LocalReport.ReportPath = reportPath;

            //Add report parameters
            ReportParameter p = new ReportParameter("ReportParameter1", instruktaName);

            rptViewer.LocalReport.SetParameters(p);
            dataSet.EndInit();

            //Fill data into the DataSet
            DataSet.DaySheetScheduleTableAdapters.spInstructorScheduleTableAdapter itemsTableAdapter = new DataSet.DaySheetScheduleTableAdapters.spInstructorScheduleTableAdapter();

            itemsTableAdapter.ClearBeforeFill = true;
            itemsTableAdapter.Fill(dataSet.spInstructorSchedule, insrtuctorID, DateTime.Today);
            rptViewer.RefreshReport();
        }
Exemplo n.º 2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            if (dtpDate.SelectedDate == null)
            {
                MessageBox.Show("Please select the date first", "Date Missing", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            }
            else if (cmbInstructorName.SelectedValue == null)
            {
                MessageBox.Show("Please select the instructor first", "DATA MISSING", MessageBoxButton.OK, MessageBoxImage.Stop);
            }
            else
            {
                wndFilter.Show();
                ReportDataSource nwReportDataSource = new ReportDataSource();
                DaySheetSchedule dataSet            = new DaySheetSchedule();

                dataSet.BeginInit();

                nwReportDataSource.Name  = "DataSet1";
                nwReportDataSource.Value = dataSet.spInstructorSchedule;
                rptViewer.LocalReport.DataSources.Add(nwReportDataSource);

                var startupPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
                var reportPath  = System.IO.Path.Combine(startupPath, @"Report\InstructorDaySheet.rdlc");
                this.rptViewer.LocalReport.ReportPath = reportPath;

                //Add report parameters
                ReportParameter p  = new ReportParameter("ReportParameter1", cmbInstructorName.Text);
                ReportParameter p1 = new ReportParameter("ReportParameter2", dtpDate.SelectedDate.Value.ToLongDateString());

                rptViewer.LocalReport.SetParameters(p);
                rptViewer.LocalReport.SetParameters(p1);
                dataSet.EndInit();

                //Fill data into the DataSet
                DataSet.DaySheetScheduleTableAdapters.spInstructorScheduleTableAdapter itemsTableAdapter = new DataSet.DaySheetScheduleTableAdapters.spInstructorScheduleTableAdapter();

                itemsTableAdapter.ClearBeforeFill = true;
                itemsTableAdapter.Fill(dataSet.spInstructorSchedule, Convert.ToInt32(cmbInstructorName.SelectedValue), Convert.ToDateTime(dtpDate.SelectedDate));// DateTime.Today);
                rptViewer.RefreshReport();
            }
        }