public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            rptSubjectInfo rpt = new rptSubjectInfo();

            rpt.Site = this.Site;
            return(rpt);
        }
Esempio n. 2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (Course.Text == "")
            {
                MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Course.Focus();
                return;
            }
            if (Branch.Text == "")
            {
                MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Branch.Focus();
                return;
            }
            try
            {
                Cursor         = Cursors.WaitCursor;
                timer1.Enabled = true;
                rptSubjectInfo rpt = new rptSubjectInfo();
                //The report you created.
                SqlConnection  myConnection = default(SqlConnection);
                SqlCommand     MyCommand    = new SqlCommand();
                SqlDataAdapter myDA         = new SqlDataAdapter();
                CMS_DBDataSet  myDS         = new CMS_DBDataSet();
                //The DataSet you created.

                myConnection          = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;");
                MyCommand.Connection  = myConnection;
                MyCommand.CommandText = "select * from subjectinfo where coursename = '" + Course.Text + "' and branch ='" + Branch.Text + "'  order by Semester";

                MyCommand.CommandType = CommandType.Text;
                myDA.SelectCommand    = MyCommand;
                myDA.Fill(myDS, "SubjectInfo");
                rpt.SetDataSource(myDS);
                crystalReportViewer1.ReportSource = rpt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }