Example #1
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptFactura rpt = new rptFactura();
         //The report you created.
         cmd = new SqlCommand();
         SqlDataAdapter myDA = new SqlDataAdapter();
         DataSet        myDS = new DataSet();
         //The DataSet you created.
         con            = new SqlConnection(cs.DBConn);
         cmd.Connection = con;
         // de inlocuit
         cmd.CommandText = "SELECT Nr_factura,Data_factura,Subtotal,TVA_per,Valoare_TVA,Reducere_per,Valoare_reducere,Total_general,Cash,Change,Opinii,Id_moneda,Id_restaurant,Id_factura,Id_produs,Nume_produs,Cantitate,Pret,Valoare_totala,Nume_moneda,Nume_restaurant, Adresa, Mobil, Mobil_director, Email, Serie, Id_nr from Informatii_facturi,Produse_vandute,Moneda,Informatii_restaurante where Informatii_facturi.Id=Produse_vandute.Id_factura and Informatii_facturi.Id_moneda=Moneda.Id and Informatii_facturi.Id_restaurant=Informatii_restaurante.Id and Informatii_facturi.Nr_factura='" + txtBillNo.Text + "'";
         // de inlocuit
         cmd.CommandType    = CommandType.Text;
         myDA.SelectCommand = cmd;
         myDA.Fill(myDS, "Informatii_facturi");
         myDA.Fill(myDS, "Produse_vandute");
         myDA.Fill(myDS, "Informatii_restaurante");
         myDA.Fill(myDS, "Moneda");
         rpt.SetDataSource(myDS);
         RaportFactura frm = new RaportFactura();
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptFactura rpt = new rptFactura();

            rpt.Site = this.Site;
            return(rpt);
        }