public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { RptOrderBuy rpt = new RptOrderBuy(); 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 'رقم الفاتورة',Suppliers.Sup_Name as 'اسم المورد',Products.Pro_Name as 'اسم المنتج',[Date] as 'تاريخ الفاتورة',[Buy_Detalis].[Qty] as 'الكمية',Unit_Name as 'الوحدة',[User_Name] as 'اسم المستخدم',[Price] as 'السعر قبل الضريبة',[Buy_Detalis].Tax_Value as 'الضريبة',Price_Tax as 'السعر بعد الضريبة',[Discount] as 'الخصم',[Total] as 'اجمالى الصنف',[TotalOrder] as 'الاجمالى العام',[Madfou3] as 'المدفوع',[Baky] as 'المبلغ المتبقى' FROM [dbo].[Buy_Detalis],Suppliers,Products where Suppliers.Sup_ID =[Buy_Detalis].Sup_ID and Products.Pro_ID =[Buy_Detalis].Pro_ID and Order_ID =" + id + "", ""); try { Frm_Print frm = new Frm_Print(); frm.crystalReportViewer1.RefreshReport(); if (Properties.Settings.Default.BuyPrintKind == "8CM") { RptOrderBuy rpt = new RptOrderBuy(); 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.BuyPrintKind == "A4") { RptOrderBuyA4 rpt = new RptOrderBuyA4(); 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) { } }