private void btnRelatorio_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         timer1.Enabled = true;
         rptVendas rpt = new rptVendas();
         //The report you created.
         cmd = new SqlCommand();
         SqlDataAdapter myDA = new SqlDataAdapter();
         POS_DBDataSet  myDS = new POS_DBDataSet();
         //The DataSet you created.
         con             = new SqlConnection(cs.DBConn);
         cmd.Connection  = con;
         cmd.CommandText = "SELECT * from invoice_info where InvoiceDate Between @d1 and @d2 order by InvoiceDate";
         cmd.Parameters.Add("@d1", SqlDbType.DateTime, 30, "InvoiceDate").Value = dtpDataFaturaDe.Value.Date;
         cmd.Parameters.Add("@d2", SqlDbType.DateTime, 30, "InvoiceDate").Value = dtpDataFaturaAte.Value.Date;
         cmd.CommandType    = CommandType.Text;
         myDA.SelectCommand = cmd;
         myDA.Fill(myDS, "Invoice_Info");
         rpt.SetDataSource(myDS);
         frmRelatorioVendas frm = new frmRelatorioVendas();
         frm.crystalReportViewer1.ReportSource = rpt;
         frm.Visible = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptVendas rpt = new rptVendas();

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