Ejemplo n.º 1
0
        /// <summary>
        /// hàm thực hiện việc hủy thanh toán
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            if (objLuotkham.TrangthaiNoitru >= Utility.Int32Dbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("KCB_THANHTOAN_CHAN_THANHTOANNGOAITRU", "2", false), 2))
            {
                Utility.ShowMsg("Bệnh nhân này đã ở trạng thái nội trú nên hệ thống không cho phép hủy phiếu chi ngoại trú nữa");
                return;
            }
            KcbThanhtoan objPayment = KcbThanhtoan.FetchByID(v_Payment_Id);
            //Kiểm tra ngày hủy
            int KCB_THANHTOAN_SONGAY_HUYTHANHTOAN = Utility.Int32Dbnull(THU_VIEN_CHUNG.Laygiatrithamsohethong("KCB_THANHTOAN_SONGAY_HUYTHANHTOAN", "0", true), 0);
            int Chenhlech = (int)Math.Ceiling((globalVariables.SysDate.Date - objPayment.NgayThanhtoan.Date).TotalDays);

            if (Chenhlech > KCB_THANHTOAN_SONGAY_HUYTHANHTOAN)
            {
                Utility.ShowMsg(string.Format("Ngày thanh toán {0} - Ngày hủy thanh toán {1}. Hệ thống không cho phép bạn hủy thanh toán đã quá {2} ngày. Cần liên hệ quản trị hệ thống để được trợ giúp", objPayment.NgayThanhtoan.ToString("dd/MM/yyyy"), globalVariables.SysDate.ToString("dd/MM/yyyy"), KCB_THANHTOAN_SONGAY_HUYTHANHTOAN.ToString()));
                return;
            }
            if (PropertyLib._ThanhtoanProperties.Hoitruockhihuythanhtoan)
            {
                if (!Utility.AcceptQuestion(string.Format("Bạn có muốn hủy lần thanh toán với Mã thanh toán {0}", v_Payment_Id.ToString()), "Thông báo", true))
                {
                    return;
                }
            }
            if (THU_VIEN_CHUNG.Laygiatrithamsohethong("KCB_THANHTOAN_BATNHAPLYDO_HUYTHANHTOAN", "1", false) == "1")
            {
                frm_Chondanhmucdungchung _Nhaplydohuythanhtoan = new frm_Chondanhmucdungchung("LYDOHUYTHANHTOAN", "Hủy thanh toán tiền Bệnh nhân", "Nhập lý do hủy thanh toán trước khi thực hiện...", "Lý do hủy thanh toán");
                _Nhaplydohuythanhtoan.ShowDialog();
                m_blnCancel = _Nhaplydohuythanhtoan.m_blnCancel;
                if (m_blnCancel)
                {
                    return;
                }
                ma_lydohuy = _Nhaplydohuythanhtoan.ma;
            }
            bool HUYTHANHTOAN_HUYBIENLAI = THU_VIEN_CHUNG.Laygiatrithamsohethong("HUYTHANHTOAN_HUYBIENLAI", "1", true) == "1";

            actionResult = _THANHTOAN.HuyThanhtoan(objPayment, objLuotkham, ma_lydohuy, Utility.Int32Dbnull(grdPaymentDetail.CurrentRow.Cells[KcbThanhtoan.Columns.IdHdonLog], -1), HUYTHANHTOAN_HUYBIENLAI);
            int record = -1;

            switch (actionResult)
            {
            case ActionResult.Success:
                ModifyComamd();
                Utility.ShowMsg("Bạn hủy thông tin thanh toán thành công", "Thông báo");
                m_blnCancel = false;
                cmdExit.PerformClick();
                break;

            case ActionResult.ExistedRecord:
                Utility.ShowMsg("Thuốc đã cấp phát cho Bệnh nhân nên cần trả lại thuốc bên Dược mới có thể thực hiện hủy thanh toán", "Thông báo", MessageBoxIcon.Warning);
                break;

            case ActionResult.Error:
                Utility.ShowMsg("Lỗi trong quá trình hủy thông tin thanh toán", "Thông báo", MessageBoxIcon.Error);
                break;
            }
        }