private void PrintAll() { string date1; string date2; date1 = DtpFrom.Value.ToString("dd/MM/yyyy"); date2 = DtpTo.Value.ToString("dd/MM/yyyy"); DataTable tblRpt = new DataTable(); tblRpt.Clear(); tblRpt = db.readData("SELECT [Order_ID] as 'رقم الفاتورة',[Cust_Name] as 'اسم العميل',Products.Pro_Name as 'المنتج',[Unit] as 'الوحدة',[Sales_Rb7h].[Qty] as 'الكمية',[Buy_Price] as 'سعر الشراء',[Discount] as 'الخصم',[Sales_Rb7h].[Tax_Value] as 'قيمة الضريبة',[Price_Tax] as 'السعر بعد الضريبة',([Price_Tax] - [Buy_Price]) * [Sales_Rb7h].[Qty] as 'الربح',[Total] as 'اجمالى الصنف' ,[TotalOrder] as 'اجمالى الفاتورة',[Madfou3] as 'المبلغ المدفوع',[Baky] as 'المتبقى',[Date] as 'التاريخ',[User_Name] as 'اسم الكاشير',[Time] as 'الوقت' FROM [dbo].[Sales_Rb7h] ,Products where Products.Pro_ID =Sales_Rb7h.Pro_ID and Convert(date,Date ,105 ) between '" + date1 + "' and '" + date2 + "' ", ""); try { Frm_Print frm = new Frm_Print(); frm.crystalReportViewer1.RefreshReport(); RptSalesRb7h rpt = new RptSalesRb7h(); rpt.SetDatabaseLogon("", "", @".\SQLEXPRESS", "Sales_System"); rpt.SetDataSource(tblRpt); rpt.SetParameterValue("From", date1); rpt.SetParameterValue("To", date2); frm.crystalReportViewer1.ReportSource = rpt; System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument(); rpt.PrintOptions.PrinterName = printDocument.PrinterSettings.PrinterName; // rpt.PrintToPrinter(1, true, 0, 0); frm.ShowDialog(); } catch (Exception) { } }
public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RptSalesRb7h rpt = new RptSalesRb7h(); rpt.Site = this.Site; return(rpt); }