/// <summary>
        /// hàm thực hiện việc cho phép chuyển thông tin xác nhận vào kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdNhapKho.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                if (objTPhieuNhapxuatthuoc != null)
                {
                    string errMsg = "";
                    DateTime _ngayxacnhan = globalVariables.SysDate;
                    if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                    {
                        frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                        _ChonngayXacnhan.pdt_InputDate = objTPhieuNhapxuatthuoc.NgayHoadon;
                        _ChonngayXacnhan.ShowDialog();
                        if (_ChonngayXacnhan.b_Cancel)
                            return;
                        else
                            _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                    }
                    ActionResult actionResult =
                        new XuatThuoc().XacNhanPhieuHuy_thanhly_thuoc(objTPhieuNhapxuatthuoc, _ngayxacnhan, ref errMsg);
                    switch (actionResult)
                    {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Xác nhận phiếu thanh lý thuốc thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 1;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value = _ngayxacnhan;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 1;
                            grdList.CurrentRow.EndEdit();
                            break;
                        case ActionResult.Exceed:
                            Utility.ShowMsg("Không có thuốc trong kho thanh lý nên không thể xác nhận phiếu thanh lý\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Warning);
                            break;
                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc trong kho thanh lý không còn đủ số lượng nên không thể xác nhận phiếu thanh lý\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Warning);
                            break;
                        case ActionResult.Error:
                            break;
                    }
                }

            }
            catch (Exception)
            {

            }
            finally
            {
                ModifyCommand();
            }
        }
        /// <summary>
        /// hàm thực hiện việc cho phép chuyển thông tin xác nhận vào kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
            if (Utility.AcceptQuestion("Bạn có muốn thực hiện trả thuốc từ tủ trực khoa nội trú về kho lẻ hay không?", "Thông báo", true))
            {
                string errMsg = "";
                int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                if (objTPhieuNhapxuatthuoc != null)
                {
                    DateTime _ngayxacnhan = globalVariables.SysDate;
                    if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                    {
                        frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                        _ChonngayXacnhan.pdt_InputDate = objTPhieuNhapxuatthuoc.NgayHoadon;
                        _ChonngayXacnhan.ShowDialog();
                        if (_ChonngayXacnhan.b_Cancel)
                            return;
                        else
                        _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                    }
                    ActionResult actionResult =
                        new CapphatThuocKhoa().XacNhanPhieuTrathuocTutrucKhoaveKho(objTPhieuNhapxuatthuoc, _ngayxacnhan, ref errMsg);
                    switch (actionResult)
                    {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Trả thuốc từ tủ thuốc khoa nội trú về kho thành công",false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 1;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value = _ngayxacnhan;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 1;
                            grdList.CurrentRow.EndEdit();
                            break;
                        case ActionResult.Exceed:
                            Utility.ShowMsg("Không có thuốc trong tủ trực nên không thể xác nhận phiếu trả thuốc\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Warning);
                            break;
                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc trong tủ trực không còn đủ số lượng nên không thể xác nhận phiếu trả thuốc\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Warning);
                            break;
                        case ActionResult.Error:
                            break;
                    }
                }

            }
            ModifyCommand();
        }
        /// <summary>
        /// hàm thực hiện việc xác nhạn thông tin 
        /// trừ vào kho khi xác nhận
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdXacNhan_Click(object sender, EventArgs e)
        {
            try
            {
                cmdXacNhan.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có muốn xác nhận phieus trả thuốc từ kho lẻ về kho chẵn?\nSau khi trả, thuốc sẽ bị trừ khỏi kho lẻ(kho xuất) và cộng vào kho chẵn(kho nhập)", "Thông báo", true))
                {
                    int IDPhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocKholeVekhochan.Columns.IdPhieu), -1);
                    TPhieutrathuocKholeVekhochan objDPhieuNhap = TPhieutrathuocKholeVekhochan.FetchByID(IDPhieuNhap);
                    if (objDPhieuNhap != null)
                    {
                        DateTime _ngayxacnhan = globalVariables.SysDate;
                        if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                        {
                            frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                            _ChonngayXacnhan.pdt_InputDate = objDPhieuNhap.NgayTra.Value;
                            _ChonngayXacnhan.ShowDialog();
                            if (_ChonngayXacnhan.b_Cancel)
                                return;
                            else
                                _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                        }
                        ActionResult actionResult =
                            new PhieuTraLai().XacNhanTraLaiKhoLeVeKhoChan(objDPhieuNhap, _ngayxacnhan);
                        switch (actionResult)
                        {
                            case ActionResult.Success:
                                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Trả thuốc từ kho lẻ về kho chẵn thành công", false);
                                grdList.CurrentRow.BeginEdit();
                                grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.TrangThai].Value = 1;
                                grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.NgayXacnhan].Value = _ngayxacnhan;
                                grdList.CurrentRow.Cells[TPhieutrathuocKholeVekhochan.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                                grdList.CurrentRow.EndEdit();
                                break;
                            case ActionResult.Error:
                                break;
                        }
                    }
                }

            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
        /// <summary>
        /// HÀM THỰC HIỆN VIỆC XÁC NHẬN NHẬP KHO THUỐC
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            Utility.SetMsg(uiStatusBar1.Panels["MSG"], "", false);
            if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "0")
                if (!Utility.AcceptQuestion("Bạn có chắc chắn muốn xác nhận phiếu nhập kho đang chọn hay không?\nSau khi xác nhận, thuốc sẽ được cộng vào trong kho nhập", "Thông báo", true))
                {
                    return;
                }

            int ITPhieuNhapxuatthuoc = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
            TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(ITPhieuNhapxuatthuoc);
            if (objTPhieuNhapxuatthuoc != null)
            {
                DateTime _ngayxacnhan = globalVariables.SysDate;
                if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                {
                    frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                    _ChonngayXacnhan.pdt_InputDate = objTPhieuNhapxuatthuoc.NgayHoadon;
                    _ChonngayXacnhan.ShowDialog();
                    if (_ChonngayXacnhan.b_Cancel)
                        return;
                    else
                        _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                }
                ActionResult actionResult =
                    _NHAPKHO.XacNhanPhieuNhapKho(objTPhieuNhapxuatthuoc, _ngayxacnhan);
                switch (actionResult)
                {
                    case ActionResult.Success:
                        Utility.SetMsg(uiStatusBar1.Panels["MSG"], "Xác nhận phiếu nhập kho thành công", false);
                        grdList.CurrentRow.BeginEdit();
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 1;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value = _ngayxacnhan;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                        grdList.CurrentRow.EndEdit();
                        break;
                    case ActionResult.Error:
                        Utility.ShowMsg("Lỗi khi xác nhận phiếu nhập kho thuốc", "Thông báo lỗi", MessageBoxIcon.Error);
                        break;
                }
            }

            ModifyCommand();
        }
        /// <summary>
        /// hàm thực hiện việc cho phép chuyển thông tin xác nhận vào kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            try
            {
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn đã chắc chắn muốn xác nhận trả thuốc thừa từ phiếu đang chọn hay không?\nSau khi xác nhận, dữ liệu thuốc sẽ được cộng vào kho nhận", "Thông báo", true))
                {
                    string errMsg = "";
                    int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocthua.Columns.Id), -1);
                    TPhieutrathuocthua objTPhieutrathuocthua = TPhieutrathuocthua.FetchByID(IdPhieu);
                    if (objTPhieutrathuocthua != null)
                    {
                        DateTime _ngayxacnhan = globalVariables.SysDate;
                        string _nguoitra = "";
                        frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                        _ChonngayXacnhan.pdt_InputDate = objTPhieutrathuocthua.NgayLapphieu;
                        _ChonngayXacnhan.ShowDialog();
                        if (_ChonngayXacnhan.b_Cancel)
                            return;
                        else
                        {
                            _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                            _nguoitra = _ChonngayXacnhan.txtNhanvien.Text;
                        }
                        objTPhieutrathuocthua.NgayTra = _ngayxacnhan;
                        objTPhieutrathuocthua.NguoiTra = Utility.Int16Dbnull(_ChonngayXacnhan.txtNhanvien.MyID, -1);
                        ActionResult actionResult =
                            new Trathuocthua().Xacnhanphieutrathuocthua(objTPhieutrathuocthua);
                        switch (actionResult)
                        {
                            case ActionResult.Success:
                                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Trả thuốc thừa từ khoa nội trú về kho thành công", false);
                                grdList.CurrentRow.BeginEdit();
                                grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.TrangThai].Value = 1;
                                grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NgayTra].Value = _ngayxacnhan;
                                grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NguoiTra].Value = objTPhieutrathuocthua.NguoiTra;
                                grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NguoiNhan].Value = globalVariables.gv_intIDNhanvien;
                                grdList.CurrentRow.Cells["sngay_tra"].Value = _ngayxacnhan.ToString("dd/MM/yyyy");
                                grdList.CurrentRow.Cells["ten_nguoitra"].Value = _nguoitra;
                                grdList.CurrentRow.Cells["ten_nguoinhan"].Value = Utility.getTenNhanvien();
                                grdList.CurrentRow.EndEdit();
                                grdList.UpdateData();
                                break;
                            case ActionResult.Exceed:
                                Utility.ShowMsg("Một số chi tiết thuốc không tồn tại nên hệ thống không thể xác nhận. Đề nghị bạn kiểm tra lại");
                                break;
                            case ActionResult.DataChanged:
                                Utility.ShowMsg("Dữ liệu cấp phát đã bị thay đổi nên bạn không thể xác nhận. Đề nghị nhấn nút tìm kiếm để lấy lại dữ liệu mới nhất");
                                break;
                            case ActionResult.Error:
                                break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {

                Utility.CatchException(ex);
            }
            finally
            {
                ModifyCommand();
            }
        }
        /// <summary>
        /// hàm thực hiện việc cho phép chuyển thông tin xác nhận vào kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
            TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
            if (objTPhieuNhapxuatthuoc != null)
            {
                string errMsg = "";
                DateTime _ngayxacnhan = globalVariables.SysDate;
                if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                {
                    frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                    _ChonngayXacnhan.pdt_InputDate = objTPhieuNhapxuatthuoc.NgayHoadon;
                    _ChonngayXacnhan.ShowDialog();
                    if (_ChonngayXacnhan.b_Cancel)
                        return;
                    else
                    _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                }
                ActionResult actionResult =
                    new XuatThuoc().XacNhanPhieuHuy_thanhly_thuoc(objTPhieuNhapxuatthuoc, _ngayxacnhan, ref errMsg);
                switch (actionResult)
                {
                    case ActionResult.Success:
                        Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Xác nhận phiếu trả nhà cung cấp thành công", false);
                        grdList.CurrentRow.BeginEdit();
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 1;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value = globalVariables.SysDate;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value = 1;
                        grdList.CurrentRow.EndEdit();
                        break;
                    case ActionResult.Error:
                        Utility.ShowMsg("Lỗi khi xác nhận phiếu trả nhà cung cấp", "Thông báo lỗi", MessageBoxIcon.Error);
                        break;
                }
            }

            ModifyCommand();
        }
        /// <summary>
        /// hàm thực hiện việc cho phép chuyển thông tin xác nhận vào kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdNhapKho.Enabled = false;
                if (Utility.AcceptQuestion("Bạn có chắc chắn muốn xác nhận phiếu cấp phát thuốc-khoa đang chọn hay không?", "Thông báo", true))
                {
                    string errMsg  = "";
                    int    IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        DateTime _ngayxacnhan = globalVariables.SysDate;
                        if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                        {
                            frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                            _ChonngayXacnhan.pdt_InputDate = objTPhieuNhapxuatthuoc.NgayHoadon;
                            _ChonngayXacnhan.ShowDialog();
                            if (_ChonngayXacnhan.b_Cancel)
                            {
                                return;
                            }
                            else
                            {
                                _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                            }
                        }
                        ActionResult actionResult =
                            new CapphatThuocKhoa().XacNhanPhieuCapphatThuoc(objTPhieuNhapxuatthuoc, _ngayxacnhan, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Đã xác nhận phiếu cấp phát thuốc-khoa thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 1;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = _ngayxacnhan;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 1;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Không có thuốc trong kho xuất nên không thể xác nhận phiếu xuất\n" + errMsg);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc trong kho xuất không còn đủ số lượng nên không thể xác nhận phiếu xuất\n" + errMsg);
                            break;

                        case ActionResult.Error:

                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                cmdNhapKho.Enabled = true;
                ModifyCommand();
            }
        }
示例#8
0
        /// <summary>
        /// hàm thực hiện việc cho phép chuyển thông tin xác nhận vào kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdNhapKho.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                if (objTPhieuNhapxuatthuoc != null)
                {
                    if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 1)
                    {
                        return;
                    }
                    string   errMsg       = "";
                    DateTime _ngayxacnhan = globalVariables.SysDate;
                    if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_HIENTHI_NGAYXACNHAN", "0", false) == "1")
                    {
                        frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                        _ChonngayXacnhan.pdt_InputDate = objTPhieuNhapxuatthuoc.NgayHoadon;
                        _ChonngayXacnhan.ShowDialog();
                        if (_ChonngayXacnhan.b_Cancel)
                        {
                            return;
                        }
                        else
                        {
                            _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                        }
                    }
                    ActionResult actionResult =
                        new XuatThuoc().XacNhanPhieuHuy_thanhly_thuoc(objTPhieuNhapxuatthuoc, _ngayxacnhan, ref errMsg);
                    switch (actionResult)
                    {
                    case ActionResult.Success:
                        Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Xác nhận phiếu thanh lý thuốc thành công", false);
                        grdList.CurrentRow.BeginEdit();
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 1;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = _ngayxacnhan;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = globalVariables.UserName;
                        grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 1;
                        grdList.CurrentRow.EndEdit();
                        break;

                    case ActionResult.Exceed:
                        Utility.ShowMsg("Không có thuốc trong kho thanh lý nên không thể xác nhận phiếu thanh lý\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Warning);
                        break;

                    case ActionResult.NotEnoughDrugInStock:
                        Utility.ShowMsg("Thuốc trong kho thanh lý không còn đủ số lượng nên không thể xác nhận phiếu thanh lý\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Warning);
                        break;

                    case ActionResult.Error:
                        break;
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
        /// <summary>
        /// hàm thực hiện việc cho phép chuyển thông tin xác nhận vào kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdNhapKho_Click(object sender, EventArgs e)
        {
            try
            {
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn đã chắc chắn muốn xác nhận trả thuốc thừa từ phiếu đang chọn hay không?\nSau khi xác nhận, dữ liệu thuốc sẽ được cộng vào kho nhận", "Thông báo", true))
                {
                    string             errMsg  = "";
                    int                IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocthua.Columns.Id), -1);
                    TPhieutrathuocthua objTPhieutrathuocthua = TPhieutrathuocthua.FetchByID(IdPhieu);
                    if (objTPhieutrathuocthua != null)
                    {
                        DateTime            _ngayxacnhan     = globalVariables.SysDate;
                        string              _nguoitra        = "";
                        frm_ChonngayXacnhan _ChonngayXacnhan = new frm_ChonngayXacnhan();
                        _ChonngayXacnhan.pdt_InputDate = objTPhieutrathuocthua.NgayLapphieu;
                        _ChonngayXacnhan.ShowDialog();
                        if (_ChonngayXacnhan.b_Cancel)
                        {
                            return;
                        }
                        else
                        {
                            _ngayxacnhan = _ChonngayXacnhan.pdt_InputDate;
                            _nguoitra    = _ChonngayXacnhan.txtNhanvien.Text;
                        }
                        objTPhieutrathuocthua.NgayTra  = _ngayxacnhan;
                        objTPhieutrathuocthua.NguoiTra = Utility.Int16Dbnull(_ChonngayXacnhan.txtNhanvien.MyID, -1);
                        ActionResult actionResult =
                            new Trathuocthua().Xacnhanphieutrathuocthua(objTPhieutrathuocthua);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Trả thuốc thừa từ khoa nội trú về kho thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.TrangThai].Value = 1;
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NgayTra].Value   = _ngayxacnhan;
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NguoiTra].Value  = objTPhieutrathuocthua.NguoiTra;
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NguoiNhan].Value = globalVariables.gv_intIDNhanvien;
                            grdList.CurrentRow.Cells["sngay_tra"].Value     = _ngayxacnhan.ToString("dd/MM/yyyy");
                            grdList.CurrentRow.Cells["ten_nguoitra"].Value  = _nguoitra;
                            grdList.CurrentRow.Cells["ten_nguoinhan"].Value = Utility.getTenNhanvien();
                            grdList.CurrentRow.EndEdit();
                            grdList.UpdateData();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Một số chi tiết thuốc không tồn tại nên hệ thống không thể xác nhận. Đề nghị bạn kiểm tra lại");
                            break;

                        case ActionResult.DataChanged:
                            Utility.ShowMsg("Dữ liệu cấp phát đã bị thay đổi nên bạn không thể xác nhận. Đề nghị nhấn nút tìm kiếm để lấy lại dữ liệu mới nhất");
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
                ModifyCommand();
            }
        }