private void ShowData() { try { // Lấy dữ liệu từ form điều kiện List <HT_BAOCAO_TSO> listHtBaoCaoTso = new List <HT_BAOCAO_TSO>(); DatabaseConstant.Action action = DatabaseConstant.Action.TRUY_VAN; DataSet ds = null; // Lấy báo cáo được chọn từ grid DataRowView dr = (DataRowView)grDSBaoCao.SelectedItem; int idBaoCao = int.Parse(dr[0].ToString()); int idBaoCaoCha = int.Parse(dr[4].ToString()); string maBaoCao = dr[2].ToString(); string responseMessage = ""; if (idBaoCao > 0) { MethodInfo mi = uc.GetType().GetMethod("GetParameters"); Delegate dieuKienBaoCao = Delegate.CreateDelegate(typeof(DieuKienBaoCao), uc, mi); if (!LObject.IsNullOrEmpty(dieuKienBaoCao)) { KhaiThacDuLieuProcess process = new KhaiThacDuLieuProcess(); DieuKienBaoCao dlgdieukienBaoCao = (DieuKienBaoCao)dieuKienBaoCao; List <Tuple <string, string> > dsDieuKienBC; dlgdieukienBaoCao(out dsDieuKienBC); foreach (Tuple <string, string> tuple in dsDieuKienBC) { HT_BAOCAO_TSO tso = new HT_BAOCAO_TSO(); tso.MA_TSO = tuple.Item2; tso.LOAI_TSO = ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri(); tso.GTRI_TSO = tuple.Item1; listHtBaoCaoTso.Add(tso); } if (process.DuLieuChiTieu(action, idBaoCao, ref htBaoCao, ref listHtBaoCaoTso, ref ds, ref responseMessage) == ApplicationConstant.ResponseStatus.THANH_CONG) { mi = uc.GetType().GetMethod("BuildData"); Delegate buildDLBaoCao = Delegate.CreateDelegate(typeof(BuildDuLieuBaoCao), uc, mi); if (!LObject.IsNullOrEmpty(buildDLBaoCao)) { BuildDuLieuBaoCao dlgbuildDLBaoCao = (BuildDuLieuBaoCao)buildDLBaoCao; dlgbuildDLBaoCao(ds); } } } } } catch (System.Exception ex) { CommonFunction.ThongBaoLoi(ex); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); } }
private void tlbTongHop_Click(object sender, RoutedEventArgs e) { try { AutoCompleteEntry auBaoCao = listBaoCao.ElementAt(cmbLoaiBieu.SelectedIndex); AutoCompleteEntry auChiNhanh = lstSourceChiNhanh.ElementAt(cmbChiNhanh.SelectedIndex); AutoCompleteEntry auPhongGD = lstSourcePhongGD_Select.ElementAt(cmbPhongGD.SelectedIndex); List <ThamSoBaoCao> listThamSoBaoCao = new List <ThamSoBaoCao>(); listThamSoBaoCao.Add(new ThamSoBaoCao("@MaBaoCao", auBaoCao.KeywordStrings[0], ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@NgayBaoCao", LDateTime.DateToString(raddtNgayChotSoLieu.Value.GetValueOrDefault(), ApplicationConstant.defaultDateTimeFormat), ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@NgayCuoiThang", LDateTime.DateToString(raddtNgayChotSoLieu.Value.GetValueOrDefault().GetLastDateOfMonth(), ApplicationConstant.defaultDateTimeFormat), ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@MaChiNhanh", auChiNhanh.KeywordStrings[0], ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@MaPhongGD", auPhongGD.KeywordStrings[0], ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@DinhKy", "1", ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@DonViTinh", numDonViTinh.Value.GetValueOrDefault().ToString(), ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); listThamSoBaoCao.Add(new ThamSoBaoCao("@VonTuCo", numVonTuCo.Value.GetValueOrDefault().ToString(), ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); // Chuẩn bị điều kiện cho báo cáo if (listThamSoBaoCao != null && listThamSoBaoCao.Count > 0) { if (lstHtBaoCaoTso.Where(t => t.LOAI_TSO == ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri() && t.MA_TSO.Equals("@DT_THAMSO")).Count() > 0) { lstHtBaoCaoTso = new List <HT_BAOCAO_TSO>(); foreach (ThamSoBaoCao thamSoBaoCao in listThamSoBaoCao) { HT_BAOCAO_TSO tso = new HT_BAOCAO_TSO(); tso.MA_TSO = thamSoBaoCao.MaThamSo; tso.LOAI_TSO = thamSoBaoCao.LoaiThamSo; tso.GTRI_TSO = thamSoBaoCao.GiaTriThamSo; lstHtBaoCaoTso.Add(tso); } } else { foreach (HT_BAOCAO_TSO htBaoCaoTso in lstHtBaoCaoTso) { foreach (ThamSoBaoCao thamSoBaoCao in listThamSoBaoCao) { if (htBaoCaoTso.MA_TSO.Equals(thamSoBaoCao.MaThamSo) && htBaoCaoTso.LOAI_TSO.Equals(thamSoBaoCao.LoaiThamSo)) { htBaoCaoTso.GTRI_TSO = thamSoBaoCao.GiaTriThamSo; break; } if (!LObject.IsNullOrEmpty(thamSoBaoCao.DsThamSo)) { ds = thamSoBaoCao.DsThamSo; } } } } } ds = process.LayDuLieuBaoCaoTKe(idBaoCao, maBaoCao, ref objBieuMau, htBaoCao, lstHtBaoCaoTso); BuildData(); } catch (System.Exception ex) { Mouse.OverrideCursor = Cursors.Arrow; CommonFunction.ThongBaoLoi(ex); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); } finally { } }
/// <summary> /// Chung cho thực hiện các thông tin, báo cáo in ngay /// </summary> /// <param name="maBaoCao"></param> /// <param name="listThamSoBaoCao"></param> public void LayDuLieu(string maBaoCao, List <ThamSoBaoCao> listThamSoBaoCao) { try { DatabaseConstant.Action action = DatabaseConstant.Action.IN; // Lấy thông tin báo cáo và tham số BaoCaoProcess process = new BaoCaoProcess(); int idBaoCao = 0; HT_BAOCAO htBaoCao = null; List <HT_BAOCAO_TSO> lstHtBaoCaoTso = null; process.LayThongTinBaoCao(idBaoCao, maBaoCao, ref htBaoCao, ref lstHtBaoCaoTso); List <HT_BAOCAO_TSO> listHtBaoCaoTso = lstHtBaoCaoTso; DataSet ds = new DataSet(); // Chuẩn bị điều kiện cho báo cáo if (listThamSoBaoCao != null && listThamSoBaoCao.Count > 0) { if (listHtBaoCaoTso.Where(t => t.LOAI_TSO == ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri() && t.MA_TSO.Equals("@DT_THAMSO")).Count() > 0) { listHtBaoCaoTso = new List <HT_BAOCAO_TSO>(); foreach (ThamSoBaoCao thamSoBaoCao in listThamSoBaoCao) { HT_BAOCAO_TSO tso = new HT_BAOCAO_TSO(); tso.MA_TSO = thamSoBaoCao.MaThamSo; tso.LOAI_TSO = thamSoBaoCao.LoaiThamSo; tso.GTRI_TSO = thamSoBaoCao.GiaTriThamSo; listHtBaoCaoTso.Add(tso); } } else { foreach (HT_BAOCAO_TSO htBaoCaoTso in listHtBaoCaoTso) { foreach (ThamSoBaoCao thamSoBaoCao in listThamSoBaoCao) { if (htBaoCaoTso.MA_TSO.Equals(thamSoBaoCao.MaThamSo) && htBaoCaoTso.LOAI_TSO.Equals(thamSoBaoCao.LoaiThamSo)) { htBaoCaoTso.GTRI_TSO = thamSoBaoCao.GiaTriThamSo; break; } if (!LObject.IsNullOrEmpty(thamSoBaoCao.DsThamSo)) { ds = thamSoBaoCao.DsThamSo; } } } } } else { return; } ApplicationConstant.ResponseStatus retStatus = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG; FileBase fileResponse = new FileBase(); List <FileBase> lstFileResponse = new List <FileBase>(); string responseMessage = null; retStatus = process.LayDuLieu(htBaoCao, listHtBaoCaoTso, ref fileResponse, ref responseMessage, ds, action); if (retStatus == ApplicationConstant.ResponseStatus.THANH_CONG) { string fileReport = ClientInformation.TempDir + "\\" + fileResponse.FileName + "." + fileResponse.FileFormat;; LFile.WriteFileFromByteArray(fileResponse.FileData, fileReport); // show file Stream stream = LFile.ConvertByteArrayToStream(fileResponse.FileData); System.Diagnostics.Process.Start(fileReport); } else { LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Error); return; } } catch (System.Exception ex) { LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); GC.Collect(); CommonFunction.ThongBaoLoi(ex); } }
private void tlbView_Click(object sender, RoutedEventArgs e) { try { Mouse.OverrideCursor = Cursors.Wait; // Lấy dữ liệu từ form điều kiện List <HT_BAOCAO_TSO> listHtBaoCaoTso = lstHtBaoCaoTso; List <ThamSoBaoCao> listThamSoBaoCao = new List <ThamSoBaoCao>(); DatabaseConstant.Action action = DatabaseConstant.Action.IN; MethodInfo mi; if (uc != null) { mi = uc.GetType().GetMethod("GetParameters"); } else { Mouse.OverrideCursor = Cursors.Arrow; LMessage.ShowMessage("Missing report conditional form", LMessage.MessageBoxType.Error); return; } object ret = mi.Invoke(uc, null); if (ret != null) { listThamSoBaoCao = (List <ThamSoBaoCao>)ret; } else { Mouse.OverrideCursor = Cursors.Arrow; return; } DataSet ds = new DataSet(); // Chuẩn bị điều kiện cho báo cáo if (listThamSoBaoCao != null && listThamSoBaoCao.Count > 0) { if (listHtBaoCaoTso.Where(t => t.LOAI_TSO == ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri() && t.MA_TSO.Equals("@DT_THAMSO")).Count() > 0) { listHtBaoCaoTso = new List <HT_BAOCAO_TSO>(); foreach (ThamSoBaoCao thamSoBaoCao in listThamSoBaoCao) { HT_BAOCAO_TSO tso = new HT_BAOCAO_TSO(); tso.MA_TSO = thamSoBaoCao.MaThamSo; tso.LOAI_TSO = thamSoBaoCao.LoaiThamSo; tso.GTRI_TSO = thamSoBaoCao.GiaTriThamSo; listHtBaoCaoTso.Add(tso); if (!LObject.IsNullOrEmpty(thamSoBaoCao.DsThamSo)) { ds = thamSoBaoCao.DsThamSo; } } } else { foreach (HT_BAOCAO_TSO htBaoCaoTso in listHtBaoCaoTso) { foreach (ThamSoBaoCao thamSoBaoCao in listThamSoBaoCao) { if (htBaoCaoTso.MA_TSO.Equals(thamSoBaoCao.MaThamSo) && htBaoCaoTso.LOAI_TSO.Equals(thamSoBaoCao.LoaiThamSo)) { htBaoCaoTso.GTRI_TSO = thamSoBaoCao.GiaTriThamSo; break; } if (!LObject.IsNullOrEmpty(thamSoBaoCao.DsThamSo)) { ds = thamSoBaoCao.DsThamSo; } } } } } ApplicationConstant.ResponseStatus retStatus = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG; FileBase fileResponse = new FileBase(); List <FileBase> lstFileResponse = new List <FileBase>(); string responseMessage = null; if (htBaoCao.MA_BAOCAO.Equals(DatabaseConstant.DanhSachBaoCaoTheoDinhKy.TDVM_PHIEU_THEO_DOI_HOAN_TRA_TVIEN.layMaBaoCao())) { retStatus = process.LayDuLieu(htBaoCao, listHtBaoCaoTso, ref lstFileResponse, ref responseMessage, ds, action); } else if (htBaoCao.MA_BAOCAO.Equals(DatabaseConstant.LayMaBaoCaoBTV(DatabaseConstant.DanhSachBaoCaoBTV.TDVM_LICH_THU_NO))) { retStatus = process.LayDuLieu(htBaoCao, listHtBaoCaoTso, ref fileResponse, ref responseMessage, ds, action); } else { retStatus = process.LayDuLieu(htBaoCao, listHtBaoCaoTso, ref fileResponse, ref responseMessage, ds, action); } if (retStatus == ApplicationConstant.ResponseStatus.THANH_CONG) { string fileReport = ""; string folderReport = ClientInformation.TempDir; if (htBaoCao.MA_BAOCAO.Equals(DatabaseConstant.DanhSachBaoCaoTheoDinhKy.TDVM_PHIEU_THEO_DOI_HOAN_TRA_TVIEN.layMaBaoCao())) { folderReport = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); folderReport = folderReport + "\\Hoan_Tra_TV"; if (!lstFileResponse.IsNullOrEmpty() && lstFileResponse.Count > 0) { if (Directory.Exists(folderReport)) { LFile.DeleteFolder(folderReport); Directory.CreateDirectory(folderReport); } else { Directory.CreateDirectory(folderReport); } foreach (FileBase item in lstFileResponse) { ShowFile(ref folderReport, ref fileReport, false, item, mi, listThamSoBaoCao); } //OnShowResult if (uc != null) { mi = uc.GetType().GetMethod("OnShowResult"); //Object[] paras = new Object[] { fileReport}; object retShowResult = mi.Invoke(uc, new Object[] { fileReport }); } } else { ShowFile(ref folderReport, ref fileReport, true, fileResponse, mi, listThamSoBaoCao); } } else if (htBaoCao.MA_BAOCAO.Equals(DatabaseConstant.DanhSachBaoCaoTheoDinhKy.GDKT_KET_XUAT_BCDKT_THEO_CAU_TRUC.layMaBaoCao())) { folderReport = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); ShowFile(ref folderReport, ref fileReport, true, fileResponse, mi, listThamSoBaoCao); } else { ShowFile(ref folderReport, ref fileReport, true, fileResponse, mi, listThamSoBaoCao); } } else { Mouse.OverrideCursor = Cursors.Arrow; LMessage.ShowMessage(responseMessage, LMessage.MessageBoxType.Error); return; } /* * FileBase fileResponse = process.LayDuLieuBaoCao(); * string fileReport = ClientInformation.TempDir + "\\" + fileResponse.FileName + ".pdf"; * LFile.WriteFileFromByteArray(fileResponse.FileData, fileReport); * * // show file * Stream stream = LFile.ConvertByteArrayToStream(fileResponse.FileData); * * System.Diagnostics.Process.Start(fileReport); */ } catch (System.Exception ex) { Mouse.OverrideCursor = Cursors.Arrow; CommonFunction.ThongBaoLoi(ex); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); } }
/// <summary> /// Thuc hien tong hop /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tlbView_Click(object sender, RoutedEventArgs e) { try { Mouse.OverrideCursor = Cursors.Wait; // Lấy dữ liệu từ form điều kiện List <HT_BAOCAO_TSO> listHtBaoCaoTso = lstHtBaoCaoTso; List <ThamSoBaoCao> listThamSoBaoCao = new List <ThamSoBaoCao>(); DatabaseConstant.Action action = DatabaseConstant.Action.IN; listThamSoBaoCao = this.GetParameters(); int soNgayTongHop = LDateTime.CountDayBetweenDates( LDateTime.StringToDate(TuNgay, ApplicationConstant.defaultDateTimeFormat), LDateTime.StringToDate(DenNgay, ApplicationConstant.defaultDateTimeFormat)); progbarTongHop.Minimum = 0; progbarTongHop.Maximum = soNgayTongHop + INT_ONE; progbarTongHop.Value = 0; UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(progbarTongHop.SetValue); string tuNgay = TuNgay; double value = INT_ZERO; progbarPercent.Content = "0%"; do { processDate.Content = LDateTime.StringToDate(tuNgay, ApplicationConstant.defaultDateTimeFormat).DateToString("dd/MM/yyyy"); DataSet ds = new DataSet(); // Chuẩn bị điều kiện cho báo cáo if (listThamSoBaoCao != null && listThamSoBaoCao.Count > 0) { listHtBaoCaoTso = new List <HT_BAOCAO_TSO>(); foreach (ThamSoBaoCao thamSoBaoCao in listThamSoBaoCao) { HT_BAOCAO_TSO tso = new HT_BAOCAO_TSO(); tso.MA_TSO = thamSoBaoCao.MaThamSo; tso.LOAI_TSO = thamSoBaoCao.LoaiThamSo; if (tso.MA_TSO != "@TuNgay" && tso.MA_TSO != "@DenNgay") { tso.GTRI_TSO = thamSoBaoCao.GiaTriThamSo; } else { tso.GTRI_TSO = tuNgay; } listHtBaoCaoTso.Add(tso); if (!LObject.IsNullOrEmpty(thamSoBaoCao.DsThamSo)) { ds = thamSoBaoCao.DsThamSo; } } } ApplicationConstant.ResponseStatus retStatus = ApplicationConstant.ResponseStatus.KHONG_THANH_CONG; FileBase fileResponse = new FileBase(); List <FileBase> lstFileResponse = new List <FileBase>(); string responseMessage = null; retStatus = process.LayDuLieu(htBaoCao, listHtBaoCaoTso, ref fileResponse, ref responseMessage, ds, action); if (retStatus == ApplicationConstant.ResponseStatus.THANH_CONG) { value++; Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, new object[] { ProgressBar.ValueProperty, value }); progbarPercent.Content = LNumber.Rounding((decimal)((progbarTongHop.Value / progbarTongHop.Maximum) * 100), 0).ToString() + "%"; tuNgay = LDateTime.PlusDays(LDateTime.StringToDate(tuNgay, ApplicationConstant.defaultDateTimeFormat), INT_ONE) .DateToString(ApplicationConstant.defaultDateTimeFormat); } else { LMessage.ShowMessage("M.DungChung.LoiChung", LMessage.MessageBoxType.Error); return; } }while (progbarTongHop.Value != progbarTongHop.Maximum); Mouse.OverrideCursor = Cursors.Arrow; LMessage.ShowMessage("M.DungChung.Result.ThanhCong", LMessage.MessageBoxType.Information); } catch (System.Exception ex) { Mouse.OverrideCursor = Cursors.Arrow; CommonFunction.ThongBaoLoi(ex); LLogging.WriteLog(System.Reflection.MethodInfo.GetCurrentMethod().ToString(), LLogging.LogType.ERR, ex); } }