private void btnPrint_Click(object sender, EventArgs e) { try { // var rd = new ReportDocument(); // rd.FileName = "crystal files\\OrderReport.rpt"; //// var MainFrmObj = new MainFrm(); // var db = new linqDataContext(); // // rd.SetDataSource(MainFrmObj.common_DBDataSet.ordertbl.DataSet); // rd.SetDataSource(db.ordertbls); // crystalReportViewer.ReportSource = rd; // crystalReportViewer.Show(); // NumberRowOfGridview parametersFields = new CrystalDecisions.Shared.ParameterFields(); parameterField = new CrystalDecisions.Shared.ParameterField(); parameterValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); parameterField.Name = "NumberRowOfGridview"; parameterValue.Value = NumberRowOfGridview; parameterField.CurrentValues.Add(parameterValue); parametersFields.Add(parameterField); crystalReportViewer.ParameterFieldInfo = parametersFields; this.crystalReportViewer.ReportSource = System.IO.Directory.GetCurrentDirectory() + "\\OrderReport.rpt"; // this.crystalReportViewer.RefreshReport(); } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }
public void PrintTicket() { try { CrystalDecisions.CrystalReports.Engine.ReportDocument etq = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string spath = System.Windows.Forms.Application.StartupPath; etq.Load(spath + "\\" + @"\Reports\DRE_v3.RPT"); CrystalDecisions.Shared.IConnectionInfo crConnectionInfo = etq.DataSourceConnections[0]; string DbUser = Properties.Settings.Default.DbUserName; string DbPwd = Properties.Settings.Default.DbPassword; string Server = Properties.Settings.Default.Server; string CompanyDB = Properties.Settings.Default.CompanyDB; crConnectionInfo.SetConnection(Server, CompanyDB, DbUser, DbPwd); //Parametro 0 CrystalDecisions.Shared.ParameterField objParameterField = etq.ParameterFields[0]; CrystalDecisions.Shared.ParameterDiscreteValue objParameterDiscreteValue; objParameterDiscreteValue = new CrystalDecisions.Shared.ParameterDiscreteValue(); objParameterField.CurrentValues.Clear(); objParameterDiscreteValue.Description = "2017-10-01"; objParameterDiscreteValue.Value = "2017-10-01"; objParameterField.CurrentValues.Add(objParameterDiscreteValue); //Parametro 1 CrystalDecisions.Shared.ParameterField objParameterField1 = etq.ParameterFields[1]; CrystalDecisions.Shared.ParameterDiscreteValue objParameterDiscreteValue1; objParameterDiscreteValue1 = new CrystalDecisions.Shared.ParameterDiscreteValue(); objParameterField1.CurrentValues.Clear(); objParameterDiscreteValue1.Description = "2017-10-31"; objParameterDiscreteValue1.Value = "2017-10-31"; objParameterField1.CurrentValues.Add(objParameterDiscreteValue1); //etq.PrintOptions.PrinterName = Properties.Settings.Default.PrinterNameTerra; etq.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, @"C:\Temp\RPT.pdf"); etq.Close(); } catch (Exception ex) { } }
private void Reporte_Load(object sender, EventArgs e) { CrystalReport3 objRpt = new CrystalReport3(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\EXCL.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT * FROM Expediente Where Folio = '" + foliom + "'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable2"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; if (areaaf == "Frente") { appPath = Path.GetDirectoryName(Application.ExecutablePath); appPath = appPath + @"\body1.jpg"; } else if (areaaf == "Espalda") { appPath = Path.GetDirectoryName(Application.ExecutablePath); appPath = appPath + @"\body2.jpg"; } DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
private void ReporteSalidaSeleccionada_Load(object sender, EventArgs e) { string appPath2 = Path.GetDirectoryName(Application.ExecutablePath); ///create the connection string string connString = @"Data Source= " + appPath2 + @"\DBBIT.s3db ;Version=3;"; //create the database query string query = "SELECT * FROM Salidas where Numero = '" + numero + "'"; //create an OleDbDataAdapter to execute the query System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString); //create a command builder System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter); //create a DataTable to hold the query results DataTable dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Update(dTable); DataRow Row = dTable.Rows[0]; System.Byte[] rdr = (System.Byte[])Row["Huella"]; Image imagen = ByteToImage(rdr); imagen.Save(appPath2 + @"\huella.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //-------------------------- CrystalReport8 objRpt = new CrystalReport8(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\DBBIT.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT * FROM Salidas where Numero = " + numero; //String Query1 = "Select * from SRDatosGenerales Where IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRTamanoTipo Where IDFormatoSillas = '"+idformatossillas+"'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable5"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; appPath = appPath + @"\huella.jpg"; DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
private void ReporteSillasR_Load(object sender, EventArgs e) { string appPath2 = Path.GetDirectoryName(Application.ExecutablePath); ///create the connection string string connString = @"Data Source= " + appPath2 + @"\DBESIL.s3db ;Version=3;"; //create the database query string query = "SELECT * FROM SRTamanoTipo where IDFormatoSillas = '"+idformatossillas+"'"; //create an OleDbDataAdapter to execute the query System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString); //create a command builder System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter); //create a DataTable to hold the query results DataTable dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Update(dTable); DataRow Row = dTable.Rows[0]; System.Byte[] rdr = (System.Byte[])Row["Foto"]; Image imagen = ByteToImage(rdr); imagen.Save(appPath2 + @"\perfil.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //-------------------------- CrystalReport4 objRpt = new CrystalReport4(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\DBESIL.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT SRDatosGenerales.IDFormatoSillas as IDFormatoSillas, Fecha, FechadeNacimiento, Edad, Nombre, Genero, ClinicaAsociacionMedica, Direccion, Ciudad, Estado, Pais, Telefono, Fax, Email, TipoDiscapacidad, Estatura, Peso, Coronilla, Hombro, PiernaSuperior, PiernaInferior, Pecho, Cadera, SentarseSinAyuda, SoporteCabeza, SoporteCuerpo, Foto FROM SRDatosGenerales, SRTamanoTipo Where SRDatosGenerales.IDFormatoSillas = '" + idformatossillas + "' AND SRTamanoTipo.IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRDatosGenerales Where IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRTamanoTipo Where IDFormatoSillas = '"+idformatossillas+"'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable3"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; appPath = appPath + @"\perfil.jpg"; DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }
private void ReporteSillasR_Load(object sender, EventArgs e) { string appPath2 = Path.GetDirectoryName(Application.ExecutablePath); ///create the connection string string connString = @"Data Source= " + appPath2 + @"\DBESIL.s3db ;Version=3;"; //create the database query string query = "SELECT * FROM SRTamanoTipo where IDFormatoSillas = '" + idformatossillas + "'"; //create an OleDbDataAdapter to execute the query System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString); //create a command builder System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter); //create a DataTable to hold the query results DataTable dTable = new DataTable(); //fill the DataTable dAdapter.Fill(dTable); dAdapter.Update(dTable); DataRow Row = dTable.Rows[0]; System.Byte[] rdr = (System.Byte[])Row["Foto"]; Image imagen = ByteToImage(rdr); imagen.Save(appPath2 + @"\perfil.jpg", System.Drawing.Imaging.ImageFormat.Jpeg); //-------------------------- CrystalReport4 objRpt = new CrystalReport4(); CrystalDecisions.Shared.ParameterValues RpDatos = new CrystalDecisions.Shared.ParameterValues(); CrystalDecisions.Shared.ParameterDiscreteValue DsCC = new CrystalDecisions.Shared.ParameterDiscreteValue(); CrystalDecisions.Shared.ParameterField paramField = new CrystalDecisions.Shared.ParameterField(); paramField.Name = "Imagen"; string appPath = Path.GetDirectoryName(Application.ExecutablePath); String ConnStr = @"Data Source=" + appPath + @"\DBESIL.s3db ;Version=3;"; System.Data.SQLite.SQLiteConnection myConnection = new System.Data.SQLite.SQLiteConnection(ConnStr); String Query1 = "SELECT SRDatosGenerales.IDFormatoSillas as IDFormatoSillas, Fecha, FechadeNacimiento, Edad, Nombre, Genero, ClinicaAsociacionMedica, Direccion, Ciudad, Estado, Pais, Telefono, Fax, Email, TipoDiscapacidad, Estatura, Peso, Coronilla, Hombro, PiernaSuperior, PiernaInferior, Pecho, Cadera, SentarseSinAyuda, SoporteCabeza, SoporteCuerpo, Foto FROM SRDatosGenerales, SRTamanoTipo Where SRDatosGenerales.IDFormatoSillas = '" + idformatossillas + "' AND SRTamanoTipo.IDFormatoSillas = '" + idformatossillas + "'"; //String Query1 = "Select * from SRDatosGenerales Where IDFormatoSillas = '"+idformatossillas+"'"; //String Query1 = "Select * from SRTamanoTipo Where IDFormatoSillas = '"+idformatossillas+"'"; System.Data.SQLite.SQLiteDataAdapter adapter = new System.Data.SQLite.SQLiteDataAdapter(Query1, ConnStr); DataSet Ds = new DataSet(); // here my_dt is the name of the DataTable which we // created in the designer view. adapter.Fill(Ds, "DataTable3"); // Setting data source of our report object objRpt.SetDataSource(Ds); // Binding the crystalReportViewer with our report object. this.crystalReportViewer1.ReportSource = objRpt; appPath = appPath + @"\perfil.jpg"; DsCC.Value = appPath; RpDatos.Add(DsCC); objRpt.DataDefinition.ParameterFields["Imagen"].ApplyCurrentValues(RpDatos); RpDatos.Clear(); paramField.HasCurrentValue = true; }