Ejemplo n.º 1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            Rol_Fornecedores rpt = new Rol_Fornecedores();

            rpt.Site = this.Site;
            return(rpt);
        }
Ejemplo n.º 2
0
        private void Relatorio()
        {
            Db Conexao = new Db();

            Conexao.Conecta();
            string strCommand = "";

            if (string.IsNullOrEmpty(cmbOrdem.Text))
            {
                strCommand = "SELECT * FROM FORNECEDORES ORDER BY ID";
            }
            else if (cmbOrdem.Text == "NOME")
            {
                strCommand = "SELECT * FROM FORNECEDORES ORDER BY NOME";
            }
            else if (cmbOrdem.Text == "CIDADE")
            {
                strCommand = "SELECT * FROM FORNECEDORES ORDER BY CIDADE";
            }
            else if (cmbOrdem.Text == "ESTADO")
            {
                strCommand = "SELECT * FROM FORNECEDORES ORDER BY ESTADO,CIDADE";
            }


            SqlCommand objCommand = new SqlCommand(strCommand.ToString(), Conexao.conn);

            objCommand.CommandType = CommandType.Text;

            SqlDataAdapter   objAdapter = new SqlDataAdapter();
            DataSet          objDataSet = new DataSet();
            Rol_Fornecedores objReport  = new Rol_Fornecedores();

            objCommand.Connection    = Conexao.conn;
            objAdapter.SelectCommand = objCommand;
            objAdapter.Fill(objDataSet, "FORNECEDORES");
            if (!string.IsNullOrEmpty(cmbEstado.Text))
            {
                objReport.RecordSelectionFormula = "{Fornecedores.Estado}='" + cmbEstado.Text + "'";
            }
            objReport.SetDatabaseLogon(Conexao.user.ToString(), Conexao.password.ToString());
            objReport.SetDataSource(objDataSet);
            crystalReportViewer1.ReportSource = objReport;
            crystalReportViewer1.Refresh();

            Conexao.conn.Close();
        }