/// <summary>
        /// hàm thực hiện xóa thông tin của hiếu nhập chi tiết
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdXoaPhieuNhap_Click(object sender, EventArgs e)
        {
            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
            int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocthua.Columns.Id), -1);

            if (!InValiUpdateXoa())
            {
                return;
            }
            if (Utility.AcceptQuestion(string.Format("Bạn có muốn xóa phiếu trả thuốc thừa với mã phiếu {0}\n hay không?", IdPhieu), "Thông báo", true))
            {
                ActionResult actionResult = new Trathuocthua().XoaPhieuTrathuocthua(IdPhieu);
                switch (actionResult)
                {
                case ActionResult.Success:
                    grdList.CurrentRow.Delete();
                    grdList.UpdateData();
                    m_dtPhieutrathuocthua.AcceptChanges();
                    Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Bạn xóa thông tin phiếu trả thuốc thừa thành công", false);
                    break;

                case ActionResult.Error:
                    break;
                }
            }
            ModifyCommand();
        }
        void mnuHuyLinhthuocCurrent_Click(object sender, EventArgs e)
        {
            try
            {
                if (!Utility.isValidGrid(grdPres))
                {
                    return;
                }
                List <int> lstNoValidData = new List <int>();
                List <int> lstID_Donthuoc = new List <int>()
                {
                    Utility.Int32Dbnull(grdPres.GetValue("id_donthuoc"), -1)
                };
                if (Utility.AcceptQuestion("Bạn có chắc chắn hủy lĩnh thuốc cho Bệnh nhân đang chọn hay không?", "Thông báo", true))
                {
                    if (Trathuocthua.ThuocNoitruKiemtraThuoctralai(idPhieucapphat, Utility.Int64Dbnull(grdPres.GetValue("id_donthuoc"))))
                    {
                        Utility.ShowMsg("Đơn thuốc của bệnh nhân bạn đang chọn đã có chi tiết được tổng hợp trả thuốc thừa nên không thể đánh dấu hủy lĩnh thuốc được.\nĐề nghị bạn kiểm tra lại!");
                        return;
                    }
                    if (CapphatThuocKhoa.BenhNhanLinhThuoc(idPhieucapphat, lstID_Donthuoc, 0, ref lstNoValidData) == ActionResult.Success)
                    {
                        grdPres.CurrentRow.BeginEdit();
                        grdPres.CurrentRow.Cells["da_linh"].Value = 0;
                        if (lstNoValidData.Count > 0 && lstNoValidData.Contains(Utility.Int32Dbnull(grdPres.CurrentRow.Cells["id_donthuoc"].Value, -1)))
                        {
                            grdPres.CurrentRow.Cells["not_valid"].Value = 1;
                        }
                        grdPres.CurrentRow.EndEdit();
                        grdPres.Refetch();
                        Utility.SetMsg(uiStatusBar2.Panels["Msg"], "Hủy lĩnh thuốc thành công!", false);
                    }
                    else
                    {
                        Utility.SetMsg(uiStatusBar2.Panels["Msg"], "Hủy lĩnh thuốc không thành công!Liên hệ VMS để được trợ giúp", true);
                    }



                    mnuHuyLinhthuocAll.Enabled     = m_Donthuoc.Select("da_linh=1").Length > 0;
                    mnuLinhthuocAll.Enabled        = m_Donthuoc.Select("da_linh=0").Length > 0;
                    mnuHuyLinhthuocCurrent.Enabled = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("da_linh"), "-1") == "1";
                    mnuLinhthuocCurrent.Enabled    = Utility.isValidGrid(grdPres) && Utility.sDbnull(grdPres.GetValue("da_linh"), "-1") == "0";
                    if (lstNoValidData.Count > 0)
                    {
                        Utility.ShowMsg("Chú ý: Một số đơn thuốc bạn chọn chứa thuốc trả lại đã được tổng hợp trong phiếu trả thuốc thừa nên hệ thống bỏ qua không thực hiện và đánh dấu màu đỏ. Đề nghị bạn kiểm tra lại");
                    }
                    //}
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void cmdHuychuyenkho_Click(object sender, EventArgs e)
        {
            try
            {
                if (Utility.AcceptQuestion("Bạn có muốn hủy xác nhận phiếu trả thuốc từ khoa nội trú về kho hay không?", "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)
                    {
                        ActionResult actionResult =
                            new Trathuocthua().HuyXacnhanphieuphieutrathuocthua(objTPhieutrathuocthua, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.ShowMsg("Bạn thực hiện hủy xác nhận phiếu trả thuốc thừa từ khoa nội trú về kho thành công", "Thông báo");
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.TrangThai].Value = 0;
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NgayTra].Value   = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NguoiTra].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieutrathuocthua.Columns.NguoiNhan].Value = DBNull.Value;
                            grdList.CurrentRow.Cells["sngay_tra"].Value     = "";
                            grdList.CurrentRow.Cells["ten_nguoitra"].Value  = "";
                            grdList.CurrentRow.Cells["ten_nguoinhan"].Value = "";
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Thuốc trong kho nhận đã được sử dụng hết nên bạn không thể hủy phiếu trả thuốc thừa");
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc trong kho nhận đã sử dụng gần hết nên không còn đủ số lượng để hoàn trả lại khoa");
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
                ModifyCommand();
            }
        }
示例#4
0
        void cmdSave_Click(object sender, EventArgs e)
        {
            if (!IsValidData())
            {
                return;
            }
            List <long>        lstItems = getDetails();
            TPhieutrathuocthua _item    = getPhieu();
            ActionResult       act      = ActionResult.Success;

            if (m_enAction == action.Insert)
            {
                act = new Trathuocthua().ThemPhieutrathuocthua(_item, lstItems);
                if (act == ActionResult.Success)
                {
                    idPhieutra       = _item.Id;
                    cmdPrint.Enabled = true;
                    ProcessDataInsert(_item);
                    if (_OnInsertCompleted != null)
                    {
                        _OnInsertCompleted(idPhieutra);
                    }
                    cmdPrint.Focus();
                    if (chkInngaysaukhiluu.Checked)
                    {
                        cmdPrint_Click(cmdPrint, e);
                    }
                }
            }
            else
            {
                act = new Trathuocthua().CappnhatPhieuTrathuocthua(_item, lstItems);
            }
            if (PropertyLib._TrathuocthuaProperties.ThoatsaukhiLuu == 0)
            {
                m_enAction = action.Update;
            }
            else if (PropertyLib._TrathuocthuaProperties.ThoatsaukhiLuu == 1)
            {
                this.Close();
            }
            else
            {
                m_enAction = action.Insert;
                idPhieutra = -1;
            }
            lnkTonghoplai.Visible      = m_enAction == action.Update;
            cmdAccept.ContextMenuStrip = m_enAction == action.Update ? contextMenuStrip2 : null;
        }
        /// <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();
            }
        }