/// <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)
        {
            DataTable m_dtReport =
                BAOCAO_THUOC.ThuocBaocaoTinhhinhPhatthuocbenhnhan(
                    chkByDate.Checked ? dtFromDate.Value : Convert.ToDateTime("01/01/1900"),
                    chkByDate.Checked ? dtToDate.Value : globalVariables.SysDate,
                    Utility.Int32Dbnull(cboStock.SelectedValue, -1),
                    Utility.Int32Dbnull(cboDoiTuong.SelectedValue, "-1"), chkThongketheongaychot.Checked ? 1 : 0,
                    kieuthuoc_vt);

            Utility.SetDataSourceForDataGridEx(grdList, m_dtReport, false, true, "1=1", "");
            GridEXColumn gridExColumn = grdList.RootTable.Columns["THANH_TIEN"];

            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;
            }
            Utility.AddColumToDataTable(ref m_dtReport, "STT", typeof(Int32));
            int idx = 1;

            foreach (DataRow drv in m_dtReport.Rows)
            {
                drv["STT"] = idx;
                idx++;
            }
            m_dtReport.AcceptChanges();
            Utility.UpdateLogotoDatatable(ref m_dtReport);
            string Condition = string.Format("Từ ngày {0} đến {1}- Đối tượng {2} - Thuộc kho :{3}", dtFromDate.Text,
                                             dtToDate.Text,
                                             cboDoiTuong.SelectedIndex > 0
                                                 ? Utility.sDbnull(cboDoiTuong.Text)
                                                 : "Tất cả",
                                             cboStock.SelectedIndex > 0
                                                 ? Utility.sDbnull(cboStock.Text)
                                                 : "Tất cả");

            //  Utility.AddColumToDataTable(ref m_dtReport, "SO_PHIEU_BARCODE", typeof(byte[]));
            // byte[] arrBarCode = Utility.GenerateBarCode(barcode);
            string StaffName = globalVariables.gv_strTenNhanvien;

            if (string.IsNullOrEmpty(globalVariables.gv_strTenNhanvien))
            {
                StaffName = globalVariables.UserName;
            }
            try
            {
                string tieude = "", reportname = "";
                string reportCode = kieuthuoc_vt == "THUOC"
                                        ? "thuoc_baocao_chitiet_thuoccapphat_benhnhan"
                                        : "vt_baocao_chitiet_vtcapphat_benhnhan";
                ReportDocument crpt = Utility.GetReport(reportCode, ref tieude, ref reportname);
                if (crpt == null)
                {
                    return;
                }
                var objForm = new frmPrintPreview(baocaO_TIEUDE1.txtTieuDe.Text, crpt, true,
                                                  m_dtReport.Rows.Count <= 0 ? false : true);
                //try
                //{
                crpt.SetDataSource(m_dtReport);

                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode     = reportCode;
                //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                // Utility.SetParameterValue(crpt,"ParentBranchName", globalVariables.ParentBranch_Name);
                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", tieude);
                Utility.SetParameterValue(crpt, "sCurrentDate", Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                Utility.SetParameterValue(crpt, "Deparment_Name", globalVariables.KhoaDuoc);
                Utility.SetParameterValue(crpt, "txtTrinhky",
                                          Utility.getTrinhky(objForm.mv_sReportFileName,
                                                             globalVariables.SysDate));
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
                //Utility.DecimaltoDbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_INGIAYXINNOP_TIENTHUOC", "0", false), 0m)
                if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_INGIAYXINNOP_TIENTHUOC", "0", false) == "1")
                {
                    string tieude2 = "", reportname2 = "";
                    string reportCode2 = kieuthuoc_vt == "THUOC"
                                             ? "thuoc_baocao_giayxinnop_tienthuoc"
                                             : "vt_baocao_chitiet_vtcapphat_benhnhan";
                    ReportDocument crpt2 = Utility.GetReport(reportCode2, ref tieude2, ref reportname2);
                    if (crpt2 == null)
                    {
                        return;
                    }
                    var objForm2 = new frmPrintPreview(baocaO_TIEUDE1.txtTieuDe.Text, crpt2, true,
                                                       m_dtReport.Rows.Count <= 0 ? false : true);
                    //try
                    //{
                    crpt2.SetDataSource(m_dtReport);

                    objForm2.mv_sReportFileName = Path.GetFileName(reportname2);
                    objForm2.mv_sReportCode     = reportCode2;
                    //crpt.DataDefinition.FormulaFields["Formula_1"].Text = Strings.Chr(34) + "".Replace("#$X$#", Strings.Chr(34) + "&Chr(13)&" + Strings.Chr(34)) + Strings.Chr(34);
                    // Utility.SetParameterValue(crpt,"ParentBranchName", globalVariables.ParentBranch_Name);
                    Utility.SetParameterValue(crpt2, "StaffName", StaffName);
                    Utility.SetParameterValue(crpt2, "BranchName", globalVariables.Branch_Name);
                    Utility.SetParameterValue(crpt2, "Address", globalVariables.Branch_Address);
                    Utility.SetParameterValue(crpt2, "Phone", globalVariables.Branch_Phone);
                    Utility.SetParameterValue(crpt2, "FromDateToDate", Condition);
                    Utility.SetParameterValue(crpt2, "sTitleReport", tieude2);
                    Utility.SetParameterValue(crpt2, "sCurrentDate",
                                              Utility.FormatDateTimeWithThanhPho(dtNgayInPhieu.Value));
                    Utility.SetParameterValue(crpt2, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                    Utility.SetParameterValue(crpt2, "Deparment_Name", globalVariables.KhoaDuoc);
                    Utility.SetParameterValue(crpt2, "txtTrinhky",
                                              Utility.getTrinhky(objForm2.mv_sReportFileName,
                                                                 globalVariables.SysDate));
                    objForm2.crptViewer.ReportSource = crpt2;
                    objForm2.ShowDialog();
                }
            }
            catch (Exception exception)
            {
                Utility.ShowMsg("Lỗi:" + exception.Message);
            }
        }