public Normal(object Document, app_document_range app_range, PrintStyles PrintStyle) { if (app_range.app_document != null ? app_range.app_document.style_reciept : false || app_range.app_document != null ? app_range.app_document.id_application == App.Names.PointOfSale:false) { TicketPrint.Document_Print(app_range.app_document.id_document, Document); } else { string DocumentName = string.Empty; if (app_range != null) { DocumentName = app_range.app_document.name; } else { DocumentName = "PurchaseInvoice"; } string PathFull = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\CogntivoERP\\TemplateFiles\\" + app_range.app_document.name + ".rdlc"; if (Directory.Exists(PathFull) == false) { CreateFile(app_range); } DataSource DataSource = new DataSource(); /// if (PrintStyle == PrintStyles.Automatic && !app_range.use_default_printer && app_range.printer_name != null) { LocalReport LocalReport = new LocalReport(); PrintInvoice PrintInvoice = new PrintInvoice(); LocalReport.ReportPath = PathFull; // Path of the rdlc file LocalReport.DataSources.Add(DataSource.Create(Document)); PrintInvoice.Export(LocalReport); PrintInvoice.Print(app_range.printer_name); } else { DocumentViewr DocumentViewr = new DocumentViewr(); DocumentViewr.reportViewer.LocalReport.ReportPath = PathFull; // Path of the rdlc file DocumentViewr.reportViewer.LocalReport.DataSources.Add(DataSource.Create(Document)); DocumentViewr.reportViewer.RefreshReport(); Window window = new Window { Title = "Report", Content = DocumentViewr }; window.ShowDialog(); } } }
// initialize printing context for the specified appointment private bool SetupPrintContext(Appointment appointment) { if (appointment != null) { _currentAppointments = new List <Appointment>(); _currentAppointments.Add(appointment); } else if (_schedule.SelectedAppointment != null) { _currentAppointments = new List <Appointment>(); _currentAppointments.Add(_schedule.SelectedAppointment); } if (PrintStyles.Contains("Memo") && (_currentAppointments != null && _currentAppointments.Count > 0)) { CurrentStyle = PrintStyles["Memo"]; } else { int daysNumber = _schedule.VisibleDates.Count; if (daysNumber > 14 && PrintStyles.Contains("Month")) { CurrentStyle = PrintStyles["Month"]; } else if (daysNumber == 7 && PrintStyles.Contains("Week")) { CurrentStyle = PrintStyles["Week"]; } else if (PrintStyles.Contains("Daily")) { CurrentStyle = PrintStyles["Daily"]; } else if (PrintStyles.Contains("Details")) { CurrentStyle = PrintStyles["Details"]; } else { CurrentStyle = PrintStyles[0]; } } if (CurrentStyle == null) { return(false); } SetupPrintContext(CurrentStyle, _schedule.VisibleDates[0], _schedule.VisibleDates[_schedule.VisibleDates.Count - 1]); return(true); }