コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor         = Cursors.WaitCursor;
         Timer1.Enabled = true;
         RptBookIssueReportStudent rpt          = new RptBookIssueReportStudent();
         SqlConnection             myConnection = default(SqlConnection);
         SqlCommand     MyCommand = new SqlCommand();
         SqlDataAdapter myDA      = new SqlDataAdapter();
         DataSet        myDS      = new DataSet();
         myConnection          = new SqlConnection(cs.DBcon);
         MyCommand.Connection  = myConnection;
         MyCommand.CommandText = "SELECT * FROM BookIssue_Student INNER JOIN Book ON BookIssue_Student.AccessionNo = Book.AccessionNo INNER JOIN Student ON BookIssue_Student.AdmissionNo = Student.AdmissionNo INNER JOIN School ON Student.School_ID = School.SchoolID INNER JOIN ClassSection ON Student.ClassSection_ID = ClassSection.ClassSectionID INNER JOIN Class ON ClassSection.Class_ID = Class.ClassID  INNER JOIN   Section ON ClassSection.Section_ID = Section.SectionID where BookIssue_Student.IssueDate between @d1 and @d2 order by IssueDate";
         MyCommand.Parameters.Add("@d1", SqlDbType.DateTime, 30, "IssueDate").Value = dtpDateFrom.Value.Date;
         MyCommand.Parameters.Add("@d2", SqlDbType.DateTime, 30, "IssueDate").Value = dtpDateTo.Value.Date;
         MyCommand.CommandType = CommandType.Text;
         myDA.SelectCommand    = MyCommand;
         myDA.Fill(myDS, "BookIssue_Student");
         myDA.Fill(myDS, "Book");
         myDA.Fill(myDS, "Student");
         myDA.Fill(myDS, "ClassSection");
         myDA.Fill(myDS, "class");
         myDA.Fill(myDS, "Section");
         myDA.Fill(myDS, "School");
         rpt.SetDataSource(myDS);
         crystalReportViewer1.ReportSource = rpt;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            RptBookIssueReportStudent rpt = new RptBookIssueReportStudent();

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