public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { rpt_SkeKhoanh rpt = new rpt_SkeKhoanh(); rpt.Site = this.Site; return(rpt); }
private void OK_OnClick(object sender, RoutedEventArgs e) { try { cls.ClsConnect(); int thamso = 3; string[] bien = new string[thamso]; object[] giatri = new object[thamso]; bien[0] = "@MaPos"; giatri[0] = bll.Left(CboPos.SelectedValue.ToString().Trim(), 6); bien[1] = "@Ngay"; if (DtpNgay.SelectedDate != null) { giatri[1] = DtpNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); bien[2] = "@DenNgay"; if (DtpDenNgay.SelectedDate != null) { giatri[2] = DtpDenNgay.SelectedDate.Value.ToString("yyyy-MM-dd"); dt = cls.LoadDataProcPara("usp_SkeDnKhoanh", bien, giatri, thamso); if (dt.Rows.Count > 0) { if (RadioButton1.IsChecked == true) { rpt_SkeKhoanh rpt = new rpt_SkeKhoanh(); RPUtility.ShowRp(rpt, dt, this, srv.DbSourceSerVer(), srv.DbNameSerVer(), srv.DbUserSerVer(), srv.DbPassSerVer()); } else { FileName = Thumuc + "\\" + bll.Left(CboPos.SelectedValue.ToString().Trim(), 6) + "_" + DtpDenNgay.SelectedDate.Value.ToString("ddMMyyyy") + "_Ske_Khoanh.csv"; /*bll.WriteDataTableToExcel(dt, "Person Details", FileName, "Details"); * bll.ExportToExcel(dt, FileName); * MessageBox.Show("OK đã xuất file Excel " + FileName, "Mess", MessageBoxButton.OK, MessageBoxImage.Information); * bll.OpenExcel(FileName); */ //FileStream fs = new FileStream(FileName, FileMode.Create); //StreamWriter sw = new StreamWriter(fs, Encoding.Unicode); //bll.ToCSV(dt, sw, true); bll.ExportToExcel(dt, FileName); MessageBox.Show("Export to Excel : " + FileName, "Thông báo"); bll.OpenExcel(FileName); } } else { MessageBox.Show("Không có dữ liệu", "Mess", MessageBoxButton.OK, MessageBoxImage.Warning); } } } } catch (Exception ex) { MessageBox.Show("Error \n" + ex.Message, "Mess", MessageBoxButton.OK, MessageBoxImage.Error); } finally { cls.DongKetNoi(); } }