예제 #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            RelatorioEntradaGadoFim rpt = new RelatorioEntradaGadoFim();

            rpt.Site = this.Site;
            return(rpt);
        }
예제 #2
0
        public void carregarRelatorioEntrada(DateTime dateDe, DateTime dataAte)
        {
            dsTernakan ds = new dsTernakan();

            try
            {
                //Codigo para o relatorio
                Cursor.Current = Cursors.WaitCursor;

                DataTable    t = ds.Tables["GADO"];
                DataRow      rDataSet;
                FbConnection fbConn = new FbConnection(frmHome.strConn);
                string       query;

                query = string.Format("SELECT NOME, NUMERO, PRECO, VENDEDOR, SEXO FROM GADO WHERE ((TIPO_CADASTRO = 'Compra') AND (DATA_ENTRADA >= '{0}') AND (DATA_ENTRADA <= '{1}') AND (ID_FAZENDA = {2}))",
                                      dateDe.ToString("MM/dd/yyyy"), dataAte.ToString("MM/dd/yyyy"), frmHome.IDFazendaSelecionada);


                FbCommand fbCmd = new FbCommand(query, fbConn);
                try
                {
                    fbConn.Open();

                    FbDataReader r = fbCmd.ExecuteReader();

                    while (r.Read())
                    {
                        rDataSet = t.NewRow();

                        rDataSet["NOME"]     = r["NOME"];
                        rDataSet["NUMERO"]   = r["NUMERO"];
                        rDataSet["PRECO"]    = r["PRECO"];
                        rDataSet["VENDEDOR"] = r["VENDEDOR"];
                        rDataSet["SEXO"]     = r["SEXO"];
                        t.Rows.Add(rDataSet);
                    }
                }
                catch (FbException fbex)
                {
                    MessageBox.Show("Erro ao acessar o Banco de Dados:\n" + fbex.Message, "Erro");
                }
                finally
                {
                    fbConn.Close();
                }

                dsFazendasEUsuarios dsFazenda = new dsFazendasEUsuarios();
                DataTable           tFazenda  = dsFazenda.Tables["FAZENDA"];
                tFazenda.Rows.Add(retornarFazendaRow(tFazenda));

                RelatorioEntradaGadoFim objRpt = new RelatorioEntradaGadoFim();
                objRpt.Database.Tables[0].SetDataSource(t);
                //  objRpt.SetDataSource(ds);
                objRpt.Subreports[0].Database.Tables[0].SetDataSource(tFazenda);
                crystalReportViewer1.ReportSource = objRpt;
                crystalReportViewer1.Refresh();
            }
            catch (Exception ee)
            {
                MessageBox.Show("Erro ao carregar o relatório\n" + ee.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }