void btnImprimir_Click(object sender, EventArgs e) { //Tabla para guardar las filas seleccionadas (Value = 1), agrega n filas de la la misma fila (Quantity) DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.Columns.Add("ItemCode", typeof(string)); dt.Columns.Add("Dscription", typeof(string)); dt.Columns.Add("Quantity", typeof(Int32)); dt.Columns.Add("Codebars", typeof(string)); dt.Columns.Add("Docnum", typeof(Int32)); dt.Columns.Add("DocDate", typeof(string)); dt.Columns.Add("DocTime", typeof(string)); dt.Columns.Add("DocEntry", typeof(Int32)); dt.Columns.Add("LineNum", typeof(Int32)); dt.Columns.Add("NumatCard", typeof(string)); foreach (DataGridViewRow dgv in dataGridView1.Rows) { if (Convert.ToInt32(dgv.Cells[0].Value) == 1) { for (int i = 0; i < Convert.ToInt32(dgv.Cells[3].Value); i++) { dt.Rows.Add(dgv.Cells[1].Value, dgv.Cells[2].Value, dgv.Cells[3].Value, dgv.Cells[4].Value, dgv.Cells[5].Value, dgv.Cells[6].Value, dgv.Cells[7].Value, dgv.Cells[8].Value, dgv.Cells[9].Value, dgv.Cells[10].Value); } } } //Agrega la tabla con los datos seleccionados, crea archivo xml para lectura de los datos en Crystal, nuevo reporte, asignacion del DataSet y el Viewer ds.Tables.Add(dt); ds.WriteXmlSchema("Sample.xml"); CrystalReport1 cr = new CrystalReport1(); cr.SetDataSource(ds); crystalReportViewer1.ReportSource = cr; }
protected void CrystalReport1_Init(object sender, EventArgs e) { CrystalReport1 objRpt; objRpt = new CrystalReport1(); String ConnStr = @"Data Source=SQLSRV\TuServidor;Initial Catalog=TuBasedeDatos;Persist Security Info=True;User ID=Tuusuario;Password=Tupassword"; // LA DE ARRIBA ES NUESTRA CADENA DE CONEXION DEL SERVIDOR SqlConnection myConnection = new SqlConnection(ConnStr); // TIENEN QUE UTILIZAR EN EL USING LA CLASE DE System.Data.SqlClient String Query = "SELECT * FROM EjemploReportes"; // ESTE ES NUESTRO QUERY SqlDataAdapter adapter = new SqlDataAdapter(Query, ConnStr); Reportes Ds = new Reportes(); // ESTE ES EL NOMBRE DE NUESTRO DATASET adapter.Fill(Ds, "Reportes"); // ESTE Reportes ES EL NOMBRE DE NUESTRA TABLA DE DATOS QUE ESTA DENTRO DE NUESTRO DATASET objRpt.SetDataSource(Ds); frmReporte rpt = new frmReporte(); // ES EL FORM DONDE ESTA NUESTRO CRYSTAL REPORT VIEWER rpt.crystalReportViewer1.ReportSource = objRpt; // ESTE ES NUESTRO REPORT VIEWER rpt.ShowDialog(); // AQUI LO MUESTRA }
private void Print_Load(object sender, EventArgs e) { this.Visible = false; dsPrint ds = new dsPrint(); DataRow dataRow = reportDataSet.Rows[0]; DataRow dr = ds.DTPrint.NewRow(); dr["BarCode"] = dataRow["BarCode"]; dr["Mode"] = dataRow["Mode"]; dr["TestNo"] = dataRow["TestNo"]; for (int i = 0; i < cMain.DataShow; i++) { dr[string.Format("Data{0}", i + 1)] = dataRow[string.Format("Data{0}", i + 1)]; dr[string.Format("DataUp{0}", i + 1)] = dataRow[string.Format("DataUp{0}", i + 1)]; dr[string.Format("DataDown{0}", i + 1)] = dataRow[string.Format("DataDown{0}", i + 1)]; } ds.DTPrint.Rows.Add(dr); CrystalReport1 cr1 = new CrystalReport1(); cr1.SetDataSource(ds); crystalReportViewer1.ReportSource = cr1; //crystalReportViewer1.PrintReport(); cr1.PrintToPrinter(1, true, 0, 0); this.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Member m = (Member)Session["User"]; CrystalReport1 cr1 = new CrystalReport1(); if (m.MemberRole == 1) { cr1.SetDataSource(getDataForMember()); } else if (m.MemberRole == 2) { cr1.SetDataSource(getDataForAdmin()); } CrystalReportViewer1.ReportSource = cr1; } }
private void frmReportes_Load(object sender, EventArgs e) // cargar reporte al iniciar { comboLiga(); CrystalReport1 rep = new CrystalReport1(); rep.SetDataSource(reportes.CargarArticulos()); crystalReportViewer1.ReportSource = rep; }
private void comboBox2_SelectionChangeCommitted(object sender, EventArgs e)//filtrado de jugadores { Reortes servicios = new Reortes(); Jugadores datos = servicios.FiltrarJugadores(Convert.ToInt32(comboBox2.SelectedValue)); CrystalReport1 report = new CrystalReport1(); report.SetDataSource(datos); crystalReportViewer1.ReportSource = report; }
private void frmReportDoanhThuSanPham_Load(object sender, EventArgs e) { CrystalReport1 cry = new CrystalReport1(); DataTable table = new DataTable(); table = SanPham_BUS.getDoanhThuLoaiSP(); cry.SetDataSource(table); crystalReportViewer1.ReportSource = cry; }
protected void Page_Load(object sender, EventArgs e) { CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None; CrystalReport1 crystalReport = new CrystalReport1(); if (Request["page"] != null && Request["page"].ToString() == "page1") { crystalReport.SetDataSource(SampleData.Persons.Where(r => r.PersonName.StartsWith("廖"))); } else { crystalReport.SetDataSource(SampleData.Persons.Where(r => r.PersonAddress.Contains("台中市"))); } CrystalReportViewer1.ReportSource = crystalReport; CrystalReportViewer1.RefreshReport(); }
private void Form2_Load(object sender, EventArgs e) { RST_DBDataContext db = new RST_DBDataContext(); var d = (from s in db.TblSpareParts select new { s.SPartName, s.SPartCode, s.ModelID, s.SPartLocation, s.SPartActive, newPartSalePrice = s.SPartSalePrice == null ? 0 : s.SPartSalePrice }).ToArray(); CrystalReport1 c = new CrystalReport1(); c.SetDataSource(d); crystalReportViewer1.ReportSource = c; }
private void Rapor3_Load(object sender, EventArgs e) { SqlDataAdapter adtr = new SqlDataAdapter("select * from peryapis", con); adtr.Fill(tablo); CrystalReport1 rapor3 = new CrystalReport1(); rapor3.SetDataSource(tablo); crystalReportViewer1.ReportSource = rapor3; }
private void Rapor5_Load(object sender, EventArgs e) { tablo.Clear(); SqlDataAdapter adtr = new SqlDataAdapter("select * from peryasyer", con); adtr.Fill(tablo); CrystalReport1 rapor5 = new CrystalReport1(); rapor5.SetDataSource(tablo); crystalReportViewer1.ReportSource = rapor5; }
private void Rapor_Load(object sender, EventArgs e) { tablo.Clear(); SqlDataAdapter adtr = new SqlDataAdapter("select * from aldigi_is", bag); adtr.Fill(tablo); CrystalReport1 rapor = new CrystalReport1(); rapor.SetDataSource(tablo); crystalReportViewer1.ReportSource = rapor; }
private void Pruab() { DataSet dataSet = Consulta.Articulo_DataSet(); CrystalReport1 crystalReport1 = new CrystalReport1(); crystalReport1.SetDataSource(dataSet); FormReporteVenta formReporteVenta = new FormReporteVenta(); formReporteVenta.VistaPrevia(crystalReport1); formReporteVenta.ShowDialog(); }
public ReporteClientes() { InitializeComponent(); CrystalReport1 cr = new CrystalReport1(); cr.SetDataSource(Controlador.getControlador().obtenerListaClientes()); cr.SetDatabaseLogon("user", "user"); crystalReportViewer1.ReportSource = cr; crystalReportViewer1.Refresh(); crystalReportViewer1.Show(); }
private string GenerateReceipt(int Paymentid) { try { CrystalReport1 cr = new CrystalReport1(); //this.printDialog1.Document = this.printDocument1; //string PrinterName = this.printDocument1.PrinterSettings.PrinterName; // System.Drawing.Printing.PrinterSettings settings = new PrinterSettings(); string Printer = GetDefaultPrinterName(); //int i=0; //foreach (string Printer_loopVariable in System.Drawing.Printing.PrinterSettings.InstalledPrinters) //{ // if (i == 1) // { // Printer = Printer_loopVariable; // } // i = i + 1; //} //return Printer; // if (Printer == "Error1") // { // return "Error1d"; // } // else // { //cr.PrintOptions.PrinterName = @"\\192.168.102.81\Send To OneNote 2007"; cr.PrintOptions.PrinterName = "Thermal"; //} // System.Drawing.Printing.PrinterSettings oPS = new System.Drawing.Printing.PrinterSettings(); //cr.PrintOptions.PrinterName = oPS.PrinterName; payment_Prop paymentprop = new payment_Prop(); paymentprop.PaymentID = Paymentid; payment_bal paymentbal = new payment_bal(); DataTable dt = paymentbal.PaymentSelect(paymentprop); cr.SetDataSource(dt); TextObject txt = (TextObject)cr.Section3.ReportObjects["txtAmtInWords"]; string AmtinWords = retWord(Convert.ToInt32(Math.Round(Convert.ToDouble(dt.Rows[0]["amount"].ToString()), 0).ToString())); txt.Text = AmtinWords; cr.PrintToPrinter(1, true, 1, 1); string s = cr.PrintOptions.PrinterName.ToString(); return(s); } catch (Exception ex) { return(ex.Message); } }
public void CreateReport(string id) { string KH = (String)id; string KHID = KH.Substring(2); var results = (from sup1 in data.Inf_Customers join sup2 in data.Inf_Repair on sup1.Customer_Id equals sup2.Customer_Id join sup3 in data.Detail_Inf_Repair on sup2.Repair_Id equals sup3.Repair_Id where sup1.Customer_Id == "KH" + KHID select new { sup1.Customer_Name, sup1.Customer_Phone, sup2.Detail_Inf_Repair.Repair_Id, sup2.Staff_Id }); CrystalReport1 rp = new CrystalReport1(); rp.SetDataSource(results); crystalReportViewer1.ReportSource = rp; }
private void Reporte_Load(object sender, EventArgs e) { AccesoDatos datos = new AccesoDatos("Data Source = MARCOS; Initial Catalog = bd_utn_programacion; Integrated Security = True"); CrystalReport1 rpt = new CrystalReport1(); string sql; DataTable dt = new DataTable(); sql = "select d.legajo, p.nombre, p.apellido, td.descripcion, p.num_documento, p.telefono, d.fecha_alta from docentes d join personas p on d.id_persona=p.id_persona join tipos_documentos td on td.id_tipo_doc=p.id_tipo_doc"; dt = datos.consultar(sql); rpt.SetDataSource(dt); crystalReportViewer1.ReportSource = rpt; crystalReportViewer1.Refresh(); crystalReportViewer1.Show(); }
private void InvoiceUI_Load(object sender, EventArgs e) { try { CrystalReport1 objRpt = new CrystalReport1(); objRpt.SetDataSource(aTempOrder); crystalReportViewer1.ReportSource = objRpt; crystalReportViewer1.Refresh(); } catch (Exception exception) { MessageBox.Show(exception.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void RaportForm_Load(object sender, EventArgs e) { CrystalReport1 cr = new CrystalReport1(); string sql = " SELECT * FROM RaportView WHERE DataTimpI BETWEEN '" + datastart + "'AND '" + datasfarsit + "'"; DataSet ds = new DataSet(); SqlDataAdapter adapter = new SqlDataAdapter(sql, con); adapter.Fill(ds, "RaportView1"); cr.SetDataSource(ds.Tables["RaportView1"]); crystalReportViewer1.ReportSource = cr; crystalReportViewer1.Refresh(); }
private void Button1_Click(System.Object sender, System.EventArgs e) { DataSet1 ds = new DataSet1(); DataRow dr = null; dr = ds.Tables[0].NewRow(); string value = "Line 1: This is new line from DVC" + Constants.vbCrLf + "Line 2:" + Constants.vbCrLf + "Line 3:"; dr[0] = value; ds.Tables[0].Rows.Add(dr); ds.Tables[0].AcceptChanges(); Form2 f = new Form2(); CrystalReport1 crpt = new CrystalReport1(); crpt.SetDataSource(ds); f.CrystalReportViewer1.ReportSource = crpt; f.ShowDialog(); }
private void Sales_SubView_Load(object sender, EventArgs e) { string salesid = CodeGenerator.getLastInsertId("sales", "sales_id"); Database db = new Database(); db.openConnection(); SqlConnection conn = db.getConnection(); SqlDataAdapter sda = new SqlDataAdapter("select distinct * from sales s ,salescustomer cs,sales_items si where s.cus_id=cs.cus_id AND s.sales_id=si.sales_id AND s.sales_id ='" + salesid + "'", conn); DataSet dst = new DataSet(); sda.Fill(dst, "sales"); CrystalReport1 cryrpt = new CrystalReport1(); cryrpt.SetDataSource(dst); crystalReportViewer1.ReportSource = cryrpt; db.getConnection().Close(); }
void getype() { SqlConnection con = new SqlConnection(); con.ConnectionString = @"Data Source=MICHAEL-PC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True"; con.Open(); string sql = "SELECT * FROM BeginningInventory"; SqlDataAdapter dscmd = new SqlDataAdapter(sql, con); DataSet ds = new DataSet(); dscmd.Fill(ds, "BeginningInventory"); con.Close(); CrystalReport1 objRpt = new CrystalReport1(); objRpt.SetDataSource(ds.Tables["BeginningInventory"]); crystalReportViewer1.ReportSource = objRpt; crystalReportViewer1.Refresh(); }
void getReport() { SqlConnection cnn; string connectionString = null; string sql = null; connectionString = $@"Data Source=MICHAEL-PC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True"; cnn = new SqlConnection(connectionString); cnn.Open(); sql = "SELECT * FROM BeginningInventory"; SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn); DataSet ds = new DataSet(); dscmd.Fill(ds, "BeginningInventory"); // MessageBox.Show(ds.Tables[1].Rows.Count.ToString()); CrystalReport1 objRpt = new CrystalReport1(); objRpt.SetDataSource(ds); Report.ViewerCore.ReportSource = objRpt; cnn.Close(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["LoginSession"] == null) { Response.Redirect("../HomeView/Home.aspx"); } else { String ID = Session["LoginSession"].ToString(); MsUser user = HomeController.FetchDataForHome(ID); if (user.RoleID == "RL1") { CrystalReport1 report = new CrystalReport1(); DataSet1 dataset = ReportingController.GetDataSet(); report.SetDataSource(dataset); CrystalReportViewer1.ReportSource = report; } else { Response.Redirect("../HomeView/Home.aspx"); } } }
/// <summary> /// Download PDF of all employees /// </summary> /// <returns></returns> public ActionResult ExportEmployees() { List <Employee> allCustomer = new List <Employee>(); allCustomer = db.Employees.ToList(); CrystalReport1 rd = new CrystalReport1(); rd.Load(Path.Combine(Server.MapPath("~/CrystalReports"), "ReportCustomer.rpt")); rd.SetDataSource(allCustomer); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "EmployeeList.pdf")); }
public ActionResult ExportReport() { CrystalReport1 rd = new CrystalReport1(); rd.Load(Path.Combine(Server.MapPath("~/Reports/CrystalReport1.rpt"))); rd.SetDatabaseLogon("sa", "p@ssw0rd"); rd.SetDataSource(context.Positions.ToList()); foreach (Table tbl in rd.Database.Tables) { tbl.LogOnInfo.ConnectionInfo = connectInfo; tbl.ApplyLogOnInfo(tbl.LogOnInfo); } DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); ExportOptions CrExportOptions; PdfRtfWordFormatOptions pdfFormatOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = "D:\\"; CrExportOptions = rd.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = pdfFormatOptions; } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream str = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); str.Seek(0, SeekOrigin.Begin); string savedFileName = string.Format("CrystalReport1_{0}", DateTime.Now); return(File(str, "application/pdf", savedFileName)); }
private void LoadReport(CrystalReport1 report) { DataSet1 dataset = TransactionReportController.getTransactionReportDataSet(); report.SetDataSource(dataset); }
public HttpResponseMessage obtenerReportePlatosVendidos(List <dynamic> data) { DataSet1 ds = new DataSet1(); DataTable t = ds.Tables.Add("Items"); DataRow r; t.Columns.Add("Nombre del plato", Type.GetType("System.String")); t.Columns.Add("Cantidad vendida", Type.GetType("System.Int32")); for (int i = 0; i < data.Count; i++) { Debug.WriteLine("paso por aca"); r = t.NewRow(); r["Cantidad vendida"] = data[i]["Cantidad"]; r["Nombre del plato"] = data[i]["Nombre"]; t.Rows.Add(r); } CrystalReport1 objRpt = new CrystalReport1(); objRpt.SetDataSource(ds.Tables[1]); Debug.WriteLine(objRpt.ReportSource); ReportDocument cryRpt = new ReportDocument(); cryRpt.Load("C:\\Users\\braya\\Desktop\\bases\\Tarea_corta\\Servidor_API\\CReports\\CrystalReport1.rpt"); ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = "C:\\Users\\braya\\Desktop\\bases\\Tarea_corta\\Servidor_API\\CReports\\report.pdf"; CrExportOptions = objRpt.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; } Stream stream = objRpt.ExportToStream(ExportFormatType.PortableDocFormat); objRpt.Export(CrExportOptions); MemoryStream ms = new MemoryStream(); stream.CopyTo(ms); var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(ms.ToArray()) }; result.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment") { FileName = "Report.pdf" }; result.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream"); return(result); }