Ejemplo n.º 1
0
 private void cbxCategory_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (IsLoaded)
     {
         c1DataSource1.ViewSources["Products"].FilterDescriptors[0].Value = ((Categories)cbxCategory.SelectedItem).CategoryID;
         c1DataSource1.ViewSources["Products"].Refresh();
         _report.Render();
     }
 }
Ejemplo n.º 2
0
        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            if (_report.IsBusy)
            {
                return;
            }

            string selectedReport = cbReport.SelectedItem as string;

            if (string.IsNullOrEmpty(selectedReport))
            {
                return;
            }
            PrintInfo pi = cbPrinter.SelectedItem as PrintInfo;

            if (pi == null)
            {
                return;
            }

            // load report
            try
            {
                // load from resource stream
                Assembly asm = Assembly.GetExecutingAssembly();
                using (Stream stream = asm.GetManifestResourceStream("FlexReportSamples.Resources.FlexCommonTasks_XML.flxr"))
                    _report.Load(stream, selectedReport);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Failed to load report [{0}], exception:\r\n{1}", selectedReport, ex.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            // render and print report
            try
            {
                _report.Render();
                C1PrintOptions po = new C1PrintOptions();
                po.PrintQueue = pi.PrintQueue;
                _report.Print(po);
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("Failed to print report [{0}], exception:\r\n{1}", selectedReport, ex.Message), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }