Ejemplo n.º 1
0
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() {
     SPnl3Month rpt = new SPnl3Month();
     rpt.Site = this.Site;
     return rpt;
 }
 private void btnMath3MonthReport_Click(object sender, EventArgs e)
 {
     DateTime minDate = DateTime.Now;
     DateTime maxDate = DateTime.Today.AddMonths(3);
     TimeSpan spanDay = maxDate - minDate;
     int Day = spanDay.Days;
     List<string> Date = new List<string>();
     List<double> SPnl = new List<double>();
     Main.PGB pgb = new Main.PGB();
     pgb.progressBar1.Minimum = 0;
     pgb.progressBar1.Maximum = Day + 1;
     pgb.progressBar1.Step = 1;
     pgb.Show();
     for (int i = 0; i <= Day; i++)
     {
         DataTable result = GetSQL.Get3MonthSPOdOrderSub(minDate.ToString("yyyy-MM-dd 00:00:00"),
             minDate.ToString("yyyy-MM-dd 23:59:59"));
         if (result.Rows.Count != 0)
         {
             Date.Add(minDate.ToString("yyyy-MM-dd"));
             SPnl.Add(ewMath.SPnlSumByReport(result));
         }
         minDate = minDate.AddDays(1);
         pgb.progressBar1.Value++;
         Application.DoEvents();
         if (pgb.progressBar1.Value == Day + 1)
         {
             pgb.label1.Text = "報表啟動中,請稍候.....";
         }
         
     }
     DataTable mergeResult = new DataTable();
     mergeResult.Columns.Add("Date");
     mergeResult.Columns.Add("SPnl");
     for (int i = 0; i < Date.Count; i++)
     {
         DataRow row = mergeResult.NewRow();
         row["Date"] = Date[i];
         row["SPnl"] = SPnl[i];
         mergeResult.Rows.Add(row);
     }
     DataSet insert = new DataSet();
     insert.Tables.Add(mergeResult);
     insert.WriteXmlSchema("TEMP.xml");
     try
     {
         SPnl3Month report = new SPnl3Month();
         report.SetDataSource(insert);
         rptSPnl3Month rptsp3m = new rptSPnl3Month();
         rptsp3m.crystalReportViewer1.ReportSource = report;
         rptsp3m.Show();
         pgb.Dispose();
     }
     catch (Exception ex)
     {
         sysMessage.SystemEx(ex.Message);
     }
 }