public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RptOrderSalesA4 rpt = new RptOrderSalesA4(); rpt.Site = this.Site; return(rpt); }
private void Print() { int id = Convert.ToInt32(DgvSearch.CurrentRow.Cells[0].Value); DataTable tblRpt = new DataTable(); tblRpt.Clear(); tblRpt = db.readData("SELECT [Order_ID] as 'رقم الفاتورة',[Cust_Name] as 'اسم العميل',Products.Pro_Name as 'المنتج',[Sales_Detalis].[Qty] as 'الكمية',[Price] as 'السعر',[Discount] as 'الخصم',[Total] as 'الاجمالى',[TotalOrder] as 'اجمالى الفاتورة',[Madfou3] as 'المبلغ المدفوع',[Baky] as 'المتبقى',[User_Name] as 'الكاشير',[Date] as 'التاريخ' FROM [dbo].[Sales_Detalis] , Products where Products.Pro_ID = Sales_Detalis.Pro_ID and Order_ID=" + id + "", ""); try { Frm_Print frm = new Frm_Print(); frm.crystalReportViewer1.RefreshReport(); if (Properties.Settings.Default.SalePrintKind == "8CM") { RptOrderSales rpt = new RptOrderSales(); rpt.SetDatabaseLogon("", "", @".\SQLEXPRESS", "Sales_System"); rpt.SetDataSource(tblRpt); rpt.SetParameterValue("ID", id); frm.crystalReportViewer1.ReportSource = rpt; System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument(); rpt.PrintOptions.PrinterName = Properties.Settings.Default.PrinterName; // rpt.PrintToPrinter(1, true, 0, 0); frm.ShowDialog(); } else if (Properties.Settings.Default.SalePrintKind == "A4") { RptOrderSalesA4 rpt = new RptOrderSalesA4(); rpt.SetDatabaseLogon("", "", @".\SQLEXPRESS", "Sales_System"); rpt.SetDataSource(tblRpt); rpt.SetParameterValue("ID", id); frm.crystalReportViewer1.ReportSource = rpt; System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument(); rpt.PrintOptions.PrinterName = Properties.Settings.Default.PrinterName; // rpt.PrintToPrinter(1, true, 0, 0); frm.ShowDialog(); } } catch (Exception) { } }