private void tlbBaoCaoTheThuong_Click(object sender, RoutedEventArgs e) { if (!Validation()) { return; } DataRowView drv = (DataRowView)grid.SelectedItem; machinhanh = lstSourceChiNhanh.ElementAt(cmbChiNhanh.SelectedIndex).KeywordStrings.FirstOrDefault(); maphonggd = lstSourcePhongGD_Select.ElementAt(cmbPhongGD.SelectedIndex).KeywordStrings.FirstOrDefault(); maloaitien = lstSourceLoaiTien.ElementAt(cmbLoaiTien.SelectedIndex).KeywordStrings.FirstOrDefault(); tungay = Convert.ToDateTime(raddtTuNgay.Value).ToString(ApplicationConstant.defaultDateTimeFormat); denngay = Convert.ToDateTime(raddtDenNgay.Value).ToString(ApplicationConstant.defaultDateTimeFormat); ngaybaocao = Convert.ToDateTime(raddtNgayBaoCao.Value).ToString(ApplicationConstant.defaultDateTimeFormat); string maCanBo = drv["MA_HSO"].ToString(); string tenCanBo = drv["TEN_HSO"].ToString(); string chucVu = drv["MA_CHUC_VU"].ToString(); string duNoRuiRo = Convert.ToDecimal(drv["DU_NO_RUI_RO"]).ToString(); string duNoRuiRoSoTien = Convert.ToDecimal(drv["DU_NO_RUI_RO_STIEN"]).ToString(); string tyLeBenVung = Convert.ToDecimal(drv["TY_LE_BEN_VUNG_STIEN"]).ToString(); string soKHTang = Convert.ToDecimal(drv["SO_KH_TANG_STIEN"]).ToString(); string duNoBinhQuan = Convert.ToDecimal(drv["DU_NO_BINH_QUAN"]).ToString(); string duNoBinhQuanSoTien = Convert.ToDecimal(drv["DU_NO_BINH_QUAN_STIEN"]).ToString(); string tong = Convert.ToDecimal(drv["TONG"]).ToString(); List <ThamSoBaoCao> lstThamSo = new List <ThamSoBaoCao>(); lstThamSo.Add(new ThamSoBaoCao("@MaChiNhanh", machinhanh, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@MaPhongGD", maphonggd, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@TuNgay", tungay, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@DenNgay", tungay, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@NgayBaoCao", ngaybaocao, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("TuNgay", tungay, ApplicationConstant.LoaiThamSoBaoCao.GUI.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("DenNgay", denngay, ApplicationConstant.LoaiThamSoBaoCao.GUI.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@MaCanBo", maCanBo, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@TenCanBo", tenCanBo, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@ChucVu", chucVu, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@DuNoRuiRo", duNoRuiRo, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@DuNoRuiRoSoTien", duNoRuiRoSoTien, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@TyLeBenVung", tyLeBenVung, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@SoKHTang", soKHTang, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@DuNoBinhQuan", duNoBinhQuan, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@DuNoBinhQuanSoTien", duNoBinhQuanSoTien, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); lstThamSo.Add(new ThamSoBaoCao("@Tong", tong, ApplicationConstant.LoaiThamSoBaoCao.SQL.layGiaTri())); string maBaoCao = DatabaseConstant.LayMaBaoCaoBTV(DatabaseConstant.DanhSachBaoCaoBTV.NSTL_THE_THUONG); VanHanhGiaoDich xemBaoCao = new VanHanhGiaoDich(); xemBaoCao.LayDuLieu(maBaoCao, lstThamSo); }
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); } }