/// <summary> /// hàm thực hiên viecj in báo cáo doanh thu tiền khám chữa bệnh viện phí /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmdInPhieuXN_Click(object sender, EventArgs e) { _mabschidinh = "-1"; _idThuoc = -1; // Lấy Id Bác sỹ if (!string.IsNullOrEmpty(cboBacSyChiDinh.Text)) { var query = (from chk in cboBacSyChiDinh.CheckedValues.AsEnumerable() let x = Utility.sDbnull(chk) select x).ToArray(); if (query.Count() > 0) { _mabschidinh = string.Join(",", query); } } //Truyền dữ liệu vào datatable DataTable m_dtReport = BAOCAO_THUOC.ThuocBaocaoTinhhinhkedonthuocTheobacsy(Utility.Int32Dbnull(cboStock.SelectedValue, -1), Utility.Int32Dbnull(cboDoiTuong.SelectedValue, -1), _mabschidinh, _idThuoc, chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"), chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate, Utility.Int16Dbnull(cboTrangthai.SelectedValue, -1)); if (m_dtReport == null) { return; } THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_baocaokedon_theobacsy.xml"); //Kiểm tra dữ liệu if (m_dtReport.Rows.Count <= 0) { Utility.ShowMsg("Không tìm thấy dữ liệu cho báo cáo", "Thông báo", MessageBoxIcon.Warning); return; } //Truyền tổng tiền vào text và chuyển qua tiền bằng chữ Janus.Windows.GridEX.GridEXColumn gridExColumnTong = grdList.RootTable.Columns["thanh_tien"]; decimal tong = Utility.DecimaltoDbnull(grdList.GetTotal(gridExColumnTong, Janus.Windows.GridEX.AggregateFunction.Sum)); m_dtReport.AcceptChanges(); Utility.UpdateLogotoDatatable(ref m_dtReport); //Truyền dữ liệu vào datagrid-view Utility.SetDataSourceForDataGridEx(grdList, m_dtReport, false, true, "1=1", ""); //Lấy chuỗi condition truyền vào biến ?FromDateToDate trên crpt string Condition = string.Format("Từ ngày {0} đến {1}- Đối tượng {2} - Thuộc kho :{3} - Bác sỹ: {4}", dtFromDate.Text, dtToDate.Text, cboDoiTuong.SelectedIndex > 0 ? Utility.sDbnull(cboDoiTuong.SelectedValue) : "Tất cả", cboStock.SelectedIndex > 0 ? Utility.sDbnull(cboStock.SelectedValue) : "Tất cả", string.IsNullOrEmpty(cboBacSyChiDinh.Text) ? "Tất cả" : cboBacSyChiDinh.Text); //Lấy tên người tạo báo cáo và gọi crpt string StaffName = globalVariables.gv_strTenNhanvien; string tieude = "", reportname = ""; var crpt = Utility.GetReport("thuoc_baocaokedon_theobacsy", ref tieude, ref reportname); if (crpt == null) { return; } if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien)) { StaffName = globalVariables.UserName; } try { frmPrintPreview objForm = new frmPrintPreview(baocaO_TIEUDE1.TIEUDE, crpt, true, m_dtReport.Rows.Count <= 0 ? false : true); crpt.SetDataSource(m_dtReport); objForm.mv_sReportFileName = Path.GetFileName(reportname); objForm.mv_sReportCode = "thuoc_baocaokedon_theobacsy"; Utility.SetParameterValue(crpt, "StaffName", StaffName); Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name); Utility.SetParameterValue(crpt, "Address", globalVariables.Branch_Address); Utility.SetParameterValue(crpt, "Phone", globalVariables.Branch_Phone); Utility.SetParameterValue(crpt, "FromDateToDate", Condition); Utility.SetParameterValue(crpt, "sTitleReport", baocaO_TIEUDE1.TIEUDE); Utility.SetParameterValue(crpt, "TienBangChu", _moneyByLetter.sMoneyToLetter(tong.ToString())); Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value)); Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition()); Utility.SetParameterValue(crpt, "Department_Name", globalVariables.KhoaDuoc); Utility.SetParameterValue(crpt, "txtTrinhky", Utility.getTrinhky(objForm.mv_sReportFileName, globalVariables.SysDate)); objForm.crptViewer.ReportSource = crpt; objForm.ShowDialog(); } catch (Exception exception) { } }