public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { TaskDuration rpt = new TaskDuration(); rpt.Site = this.Site; return(rpt); }
private void testReportMethod(string qry) { DataTable table = new DataTable(); MySqlDataReader reader = null; table.Columns.Add("Staff_ID", typeof(int)); // table.Columns.Add("task_id", typeof(int)); table.Columns.Add("Task", typeof(string)); table.Columns.Add("Appointed_time", typeof(TimeSpan)); table.Columns.Add("Used_time", typeof(TimeSpan)); //table.Columns.Add("Time_difference", typeof(TimeSpan)); try { reader = DBConnection.getData(qry); if (reader.HasRows) { while (reader.Read()) { table.Rows.Add(reader.GetInt32("event_tech_id"), reader.GetString("task"), reader.GetTimeSpan("appointed_time"), reader.GetTimeSpan("used_time")); } if (reader != null) { if (!reader.IsClosed) { reader.Close(); } } TaskDuration rpt = new TaskDuration(); rpt.Database.Tables["Task"].SetDataSource(table); crystalReportViewer1.ReportSource = null; crystalReportViewer1.ReportSource = rpt; } else { if (reader != null) { if (!reader.IsClosed) { reader.Close(); } } MessageBox.Show("No records yet!", "Event task Reporting", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception exc) { if (reader != null) { if (!reader.IsClosed) { reader.Close(); } } MessageBox.Show("No records yet!\n" + exc, "Event task Reporting", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }