Tuesday, January 29, 2013

Common Report Viewer for All CrystalReport


namespace Barcodes.Reports
{
    public partial class frmReportViewer : Form
    {
        public string paramvalue;
        public int reportFlag,paramvalueId;

        public frmReportViewer( )
        {
            InitializeComponent();
       
        }

        private void frmReportViewer_Load(object sender, EventArgs e)
        {

            TAGGING_CommonVariable objVar = new TAGGING_CommonVariable();
            objVar.servername = @"SATYA";
            objVar.DatabaseName = "Admission";
            objVar.username = "sa";
            objVar.password = "sql";        

            if (reportFlag == 0)//IssueToQualityControl
            {
                crReport objCr = new crReport();               
                CrystalDecisions.Shared.TableLogOnInfo tliCurrent = default(CrystalDecisions.Shared.TableLogOnInfo);
                try
                {
                    foreach (CrystalDecisions.CrystalReports.Engine.Table tbCurrent in objCr.Database.Tables)
                    {
                        tliCurrent = tbCurrent.LogOnInfo;
                        var _with1 = tliCurrent.ConnectionInfo;
                        _with1.ServerName = objVar.servername;
                        _with1.DatabaseName = objVar.DatabaseName;                      
                        _with1.UserID = objVar.username;
                        _with1.Password = objVar.password;
                        _with1.IntegratedSecurity = false;
                        tbCurrent.ApplyLogOnInfo(tliCurrent);
                    }

                    this.crystalReportViewerAll.ReportSource = objCr;
                    objCr.SetParameterValue(0, paramvalue);
                    objCr.SetParameterValue(1, paramvalueId);
                    crystalReportViewerAll.Show();

                }                 

                catch
                {
                }

            }
             }
}

No comments:

Post a Comment