private void getData()
 {
     if (m_enAction == action.Update)
     {
         TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
         if (objPhieuNhap != null)
         {
             txtIDPhieuNhapKho.Text = objPhieuNhap.IdPhieu.ToString();
             dtNgayNhap.Value       = objPhieuNhap.NgayHoadon;
             txtMaPhieu.Text        = Utility.sDbnull(objPhieuNhap.MaPhieu);
             if (Utility.Int32Dbnull(objPhieuNhap.IdKhoxuat) > 0)
             {
                 cboKhohuy.SelectedValue = Utility.sDbnull(objPhieuNhap.IdKhoxuat);
             }
             if (Utility.Int32Dbnull(objPhieuNhap.IdNhanvien) > 0)
             {
                 cboNhanVien.SelectedValue = Utility.sDbnull(objPhieuNhap.IdNhanvien);
             }
             txtMotathem.Text     = objPhieuNhap.MotaThem;
             txtHoidong.Rtf       = objPhieuNhap.HoidongThanhly;
             m_dtDataPhieuChiTiet =
                 new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
             Utility.SetDataSourceForDataGridEx_Basic(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, true, true, "1=1", "");
         }
     }
     if (m_enAction == action.Insert)
     {
         m_dtDataPhieuChiTiet =
             new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(-100);
         Utility.SetDataSourceForDataGridEx_Basic(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, true, true, "SO_LUONG>0", "");
     }
     UpdateWhenChanged();
 }
        private void getData()
        {
            if (m_enAction == action.Update)
            {
                TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                if (objPhieuNhap != null)
                {
                    dtNgayNhap.Value = objPhieuNhap.NgayHoadon;
                    txtMaPhieu.Text  = Utility.sDbnull(objPhieuNhap.MaPhieu);
                    dtNgayNhap.Value = Convert.ToDateTime(objPhieuNhap.NgayHoadon);
                    txtNhacungcap.SetCode(objPhieuNhap.MaNhacungcap);
                    txtLyDoNhap._Text = objPhieuNhap.MotaThem;
                    if (Utility.Int32Dbnull(objPhieuNhap.IdKhoxuat) > 0)
                    {
                        cboKhoXuat.SelectedValue = Utility.sDbnull(objPhieuNhap.IdKhoxuat);
                    }

                    if (Utility.Int32Dbnull(objPhieuNhap.IdNhanvien) > 0)
                    {
                        cboNhanVien.SelectedValue = Utility.sDbnull(objPhieuNhap.IdNhanvien);
                    }

                    m_dtDataPhieuChiTiet =
                        new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                    Utility.SetDataSourceForDataGridEx(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, false, true, "1=1", "");
                }
            }
            if (m_enAction == action.Insert)
            {
                m_dtDataPhieuChiTiet =
                    new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(-100);
                Utility.SetDataSourceForDataGridEx(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, false, true, "SO_LUONG>0", "");
            }
            UpdateWhenChanged();
        }
Exemplo n.º 3
0
 private void getData()
 {
     if (m_enAction == action.Update)
     {
         TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
         if (objPhieuNhap != null)
         {
             dtNgayNhap.Value          = objPhieuNhap.NgayHoadon;
             txtMaPhieu.Text           = Utility.sDbnull(objPhieuNhap.MaPhieu);
             dtNgayNhap.Value          = Convert.ToDateTime(objPhieuNhap.NgayHoadon);
             cboKhoaTra.SelectedIndex  = Utility.GetSelectedIndex(cboKhoaTra, Utility.sDbnull(objPhieuNhap.IdKhoalinh));
             cboKhoNhan.SelectedIndex  = Utility.GetSelectedIndex(cboKhoNhan, Utility.sDbnull(objPhieuNhap.IdKhonhap));
             cboNhanVien.SelectedIndex = Utility.GetSelectedIndex(cboNhanVien, Utility.sDbnull(objPhieuNhap.IdNhanvien));
             txtNo.Text           = objPhieuNhap.TkNo;
             txtCo.Text           = objPhieuNhap.TkCo;
             txtSoCT.Text         = objPhieuNhap.SoChungtuKemtheo;
             txtNguoinhan._Text   = objPhieuNhap.NguoiNhan;
             txtNguoigiao._Text   = objPhieuNhap.NguoiGiao;
             txtLyDoXuat._Text    = objPhieuNhap.MotaThem;
             m_dtDataPhieuChiTiet =
                 new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
             Utility.SetDataSourceForDataGridEx_Basic(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, true, true, "1=1", "");
         }
     }
     if (m_enAction == action.Insert)
     {
         m_dtDataPhieuChiTiet =
             new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(-100);
         Utility.SetDataSourceForDataGridEx_Basic(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, true, true, "SO_LUONG>0", "");
     }
     UpdateWhenChanged();
 }
        private void getData()
        {
            if (m_enAction == action.Update)
            {
                TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                if (objPhieuNhap != null)
                {
                    dtNgayNhap.Value          = objPhieuNhap.NgayHoadon;
                    txtMaPhieu.Text           = Utility.sDbnull(objPhieuNhap.MaPhieu);
                    cboKhoaTra.SelectedIndex  = Utility.GetSelectedIndex(cboKhoaTra, objPhieuNhap.IdKhoalinh.ToString());
                    cboKhoXuat.SelectedIndex  = Utility.GetSelectedIndex(cboKhoXuat, objPhieuNhap.IdKhoxuat.ToString());
                    cboKhoNhap.SelectedIndex  = Utility.GetSelectedIndex(cboKhoNhap, objPhieuNhap.IdKhonhap.ToString());
                    cboNhanVien.SelectedIndex = Utility.GetSelectedIndex(cboNhanVien, objPhieuNhap.IdNhanvien.ToString());



                    m_dtDataPhieuChiTiet =
                        new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                    Utility.SetDataSourceForDataGridEx(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, false, true, "1=1", "");
                }
            }
            if (m_enAction == action.Insert)
            {
                m_dtDataPhieuChiTiet =
                    new THUOC_NHAPKHO().LaythongtinChitietPhieunhapKho(-100);
                Utility.SetDataSourceForDataGridEx(grdPhieuXuatChiTiet, m_dtDataPhieuChiTiet, false, true, "SO_LUONG>0", "");
            }
            UpdateWhenChanged();
        }
Exemplo n.º 5
0
        /// <summary>
        /// hàm thực hiện việc thêm phiếu nhập kho thuốc
        /// </summary>
        private void ThemPhieuthanhly()
        {
            TPhieuNhapxuatthuoc objPhieuNhap = CreatePhieuNhapKho();

            ActionResult actionResult = new XuatThuoc().ThemPhieuXuatKho(objPhieuNhap, CreateArrPhieuChiTiet());

            switch (actionResult)
            {
            case ActionResult.Success:
                txtIDPhieuNhapKho.Text = Utility.sDbnull(objPhieuNhap.IdPhieu);
                txtMaPhieu.Text        = Utility.sDbnull(objPhieuNhap.MaPhieu);
                TPhieuNhapxuatthuoc objPhieu = TPhieuNhapxuatthuoc.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                DataRow             newDr    = p_mDataPhieuNhapKho.NewRow();
                Utility.FromObjectToDatarow(objPhieu, ref newDr);
                TDmucKho objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhohuy.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["ten_khoxuat"] = Utility.sDbnull(objKho.TenKho);
                }
                p_mDataPhieuNhapKho.Rows.Add(newDr);
                Utility.GonewRowJanus(grdList, TPhieuNhapxuatthuoc.Columns.IdPhieu, Utility.sDbnull(txtIDPhieuNhapKho.Text));
                //Utility.ShowMsg("Bạn thêm mới phiếu chuyển kho thành công", "Thông báo");
                m_enAction = action.Insert;

                b_Cancel = true;
                this.Close();
                break;

            case ActionResult.Error:
                Utility.ShowMsg("Lỗi trong quá trình thêm phiếu", "Thông báo lỗi", MessageBoxIcon.Error);
                break;
            }
        }
        /// <summary>
        /// hà thực hiện việc in phiêu xuat kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuNhapKho_Click(object sender, EventArgs e)
        {
            int IDPhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);

            TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(IDPhieuNhap);

            if (objPhieuNhap != null)
            {
                if (Utility.Byte2Bool(objPhieuNhap.DuTru.Value))
                {
                    VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuDutru(IDPhieuNhap, "PHIẾU DỰ TRÙ", globalVariables.SysDate);
                }
                else
                {
                    if (THU_VIEN_CHUNG.Laygiatrithamsohethong("THUOC_INPHIEUXUATKHO _2LIEN", "0", false) == "1")
                    {
                        VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuXuatkho_2lien(IDPhieuNhap, "phiếu trả thuốc THUỐC TỦ TRỰC", globalVariables.SysDate);
                    }
                    else
                    {
                        VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuXuatkho(IDPhieuNhap, "phiếu trả thuốc THUỐC TỦ TRỰC", globalVariables.SysDate);
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <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)
        {
            try
            {
                cmdNhapKho.Enabled = false;
                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;
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
Exemplo n.º 8
0
        private void cmdHuychuyenkho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuychuyenkho.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có chắc chắn muốn hủy xác nhận phiếu chuyển kho đang chọn hay không?", "Thông báo", true))
                {
                    int    IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    string khoxuat = Utility.sDbnull(grdList.CurrentRow.Cells["ten_khoxuat"].Value, "");
                    string khonhap = Utility.sDbnull(grdList.CurrentRow.Cells["ten_khonhap"].Value, "");
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 0)
                        {
                            return;
                        }
                        string       errMsg       = "";
                        ActionResult actionResult =
                            new XuatThuoc().HuyXacNhanPhieuXuatKho(objTPhieuNhapxuatthuoc, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Bạn thực hiện hủy xác nhận phiếu chuyển kho thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            THU_VIEN_CHUNG.Log(this.Name, globalVariables.UserName,
                                               string.Format(
                                                   "Xóa phiếu chuyển kho với số phiếu là :{0} - Từ kho {1} đến kho {2}",
                                                   id_PhieuNhap, khoxuat, khonhap), action.Update);
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("" + ten_kieuthuoc_vt + " nhập từ phiếu này đã được sử dụng hết nên bạn không thể hủy xác nhận phiếu\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("" + ten_kieuthuoc_vt + " nhập từ phiếu này đã gần hết nên bạn không thể hủy xác nhận phiếu\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
                ModifyCommand();
            }
        }
Exemplo n.º 9
0
        private void cmdHuyXacnhan_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuyXacnhan.Enabled = false;
                Utility.SetMsg(uiStatusBar1.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có muốn hủy xác nhận phiếu nhập kho đang chọn hay không?\nSau khi hủy, thuốc sẽ được trừ ra khỏi kho nhập", "Thông báo", true))
                {
                    int    ITPhieuNhapxuatthuoc = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    string khonhap = Utility.sDbnull(grdList.CurrentRow.Cells["ten_khonhap"].Value, "");
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(ITPhieuNhapxuatthuoc);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 0)
                        {
                            return;
                        }
                        string       errMsg       = "";
                        ActionResult actionResult =
                            _NHAPKHO.HuyXacNhanPhieuNhapKho(objTPhieuNhapxuatthuoc, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar1.Panels["MSG"], "Bạn thực hiện hủy nhập kho thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            THU_VIEN_CHUNG.Log(this.Name, globalVariables.UserName,
                                               string.Format(
                                                   "Hủy phiếu nhập kho với số phiếu là :{0} - Tại kho {1}",
                                                   ITPhieuNhapxuatthuoc, khonhap), action.Update);
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Thuốc nhập đã được sử dụng hết nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc nhập đã được sử dụng nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
                ModifyCommand();
            }
        }
Exemplo n.º 10
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;
                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 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;
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
        /// <summary>
        /// hàm thực hiện việc in phiếu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuNhap_Click(object sender, EventArgs e)
        {
            int IDPhieuNhap = Utility.Int32Dbnull(txtIDPhieuNhapKho.Text, -1);
            TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(IDPhieuNhap);

            if (objPhieuNhap != null)
            {
                VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuXuatkho(IDPhieuNhap, "PHIẾU XUẤT", globalVariables.SysDate);
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// hà thực hiện việc in phiêu xuat kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuNhapKho_Click(object sender, EventArgs e)
        {
            int IDPhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);

            TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(IDPhieuNhap);

            if (objPhieuNhap != null)
            {
                VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuTraKholeVeKhochan(IDPhieuNhap, "PHIẾU NHẬP TRẢ", globalVariables.SysDate);
            }
        }
        /// <summary>
        /// hà thực hiện việc in phiêu xuat kho
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuNhapKho_Click(object sender, EventArgs e)
        {
            id_PhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);

            TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(id_PhieuNhap);

            if (objPhieuNhap != null)
            {
                VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuThanhly(id_PhieuNhap, "BIÊN BẢN THANH LÝ", globalVariables.SysDate);
            }
        }
Exemplo n.º 14
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)
        {
            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 XuatThuocAo().XacNhanPhieuXuatKho(objTPhieuNhapxuatthuoc, _ngayxacnhan, ref errMsg);
                switch (actionResult)
                {
                case ActionResult.Success:
                    Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Xác nhận phiếu chuyển 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ó " + ten_kieuthuoc_vt + " trong kho xuất nên không thể xác nhận phiếu xuất\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Warning);
                    break;

                case ActionResult.NotEnoughDrugInStock:
                    Utility.ShowMsg("" + ten_kieuthuoc_vt + " 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, "Thông báo lỗi", MessageBoxIcon.Warning);
                    break;

                case ActionResult.Error:
                    break;
                }
            }

            ModifyCommand();
        }
Exemplo n.º 15
0
        private void cmdHuychuyenkho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuychuyenkho.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có chắc chắn muốn hủy xác nhận phiếu trả thuốc đang chọn hay không?", "Thông báo", true))
                {
                    int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 0)
                        {
                            return;
                        }
                        string       errMsg       = "";
                        ActionResult actionResult =
                            new PhieuTraLai().HuyXacNhanPhieuTralaiKho(objTPhieuNhapxuatthuoc, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Hủy trả thuốc từ kho lẻ về kho chẵn thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.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ả", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc trong kho nhận(chẵn) đã được sử dụng nên không đủ số lượng để hoàn trả lại kho xuất(lẻ)", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
            finally
            {
                ModifyCommand();
            }
        }
Exemplo n.º 16
0
        private void cmdHuychuyenkho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuychuyenkho.Enabled = false;
                if (Utility.AcceptQuestion("Bạn có muốn hủy xác nhận phiếu trả nhà cung cấp đang chọn hay không?", "Thông báo", true))
                {
                    int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 0)
                        {
                            return;
                        }
                        string       ErrMsg       = "";
                        ActionResult actionResult =
                            new XuatThuoc().HuyXacNhanPhieuHuy_thanhly_Thuoc(objTPhieuNhapxuatthuoc, ref ErrMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Hủy xác nhận phiếu trả thuốc thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Thuốc nhập từ phiếu này đã được sử dụng hết nên bạn không thể hủy phiếu trả", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc nhập từ phiếu này đã gần hết nên bạn không thể hủy phiếu trả", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.Error:
                            Utility.ShowMsg("Lỗi trong quá trình hủy phiếu trả nhà cung cấp", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
Exemplo n.º 17
0
        private void cmdHuychuyenkho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuychuyenkho.Enabled = false;
                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(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 0)
                        {
                            return;
                        }
                        ActionResult actionResult =
                            new CapphatThuocKhoa().HuyXacNhanPhieuTrathuocTutrucKhoaVeKho(objTPhieuNhapxuatthuoc, 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 từ khoa nội trú về kho thành công", "Thông báo");
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Thuốc trong kho lẻ(nhận) đã được sử dụng hết nên bạn không thể hủy phiếu trả thuốc ", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

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

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
Exemplo n.º 18
0
        private void cmdHuychuyenkho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuychuyenkho.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có chắc chắn muốn hủy xác nhận phiếu chuyển kho đang chọn hay không?", "Thông báo", true))
                {
                    int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        string       errMsg       = "";
                        ActionResult actionResult =
                            new XuatThuoc().HuyXacNhanPhieuXuatKho(objTPhieuNhapxuatthuoc, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Bạn thực hiện hủy xác nhận phiếu chuyển kho thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("" + ten_kieuthuoc_vt + " nhập từ phiếu này đã được sử dụng hết nên bạn không thể hủy xác nhận phiếu\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("" + ten_kieuthuoc_vt + " nhập từ phiếu này đã gần hết nên bạn không thể hủy xác nhận phiếu\n" + errMsg, "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// hàm thực hiện viêc in phiếu nhập kho thuốc
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdInPhieuNhapKho_Click(object sender, EventArgs e)
 {
     try
     {
         int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
         TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
         if (objPhieuNhap != null)
         {
             VNS.HIS.UI.Baocao.thuoc_phieuin_nhapxuat.InphieuNhapkho(IdPhieu, "PHIẾU NHẬP", globalVariables.SysDate);
         }
     }
     catch (Exception ex)
     {
         Utility.ShowMsg("Lỗi khi in phiếu nhập kho:\n" + ex.Message);
     }
 }
        private void UpdatePhieuXuatKho()
        {
            TPhieuNhapxuatthuoc objPhieuNhap = CreatePhieuNhapKho();

            ActionResult actionResult = new XuatThuoc().UpdatePhieuXuatKho(objPhieuNhap, CreateArrPhieuChiTiet());

            switch (actionResult)
            {
            case ActionResult.Success:
                TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                DataRow[]           arrDr =
                    p_mDataPhieuNhapKho.Select(string.Format("{0}={1}", TPhieuNhapxuatthuoc.Columns.IdPhieu,
                                                             Utility.Int32Dbnull(txtIDPhieuNhapKho.Text)));
                if (arrDr.GetLength(0) > 0)
                {
                    arrDr[0].Delete();
                }
                DataRow newDr = p_mDataPhieuNhapKho.NewRow();
                Utility.FromObjectToDatarow(objTPhieuNhapxuatthuoc, ref newDr);
                TDmucKho objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhoNhap.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["TEN_KHO_NHAP"] = Utility.sDbnull(objKho.TenKho);
                }
                objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhoXuat.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["TEN_KHO_XUAT"] = Utility.sDbnull(objKho.TenKho);
                }
                newDr["ID_KHOA_LINH"] = Utility.Int16Dbnull(cboKhoaTra.SelectedValue, 0);
                newDr["TEN_KHOA"]     = cboKhoaTra.Text;
                p_mDataPhieuNhapKho.Rows.Add(newDr);

                Utility.GonewRowJanus(grdList, TPhieuNhapxuatthuoc.Columns.IdPhieu, Utility.sDbnull(txtIDPhieuNhapKho.Text));
                Utility.ShowMsg("Bạn sửa  phiếu trả thành công", "Thông báo");
                m_enAction = action.Insert;

                b_Cancel = true;
                break;

            case ActionResult.Error:
                Utility.ShowMsg("Lỗi trong quá trình sửa phiếu", "Thông báo lỗi", MessageBoxIcon.Error);
                break;
            }
        }
Exemplo n.º 21
0
        private void cmdHuyXacnhan_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuyXacnhan.Enabled = false;
                Utility.SetMsg(uiStatusBar1.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có muốn hủy xác nhận phiếu nhập kho đang chọn hay không?\nSau khi hủy, thuốc sẽ được trừ ra khỏi kho nhập", "Thông báo", true))
                {
                    int ITPhieuNhapxuatthuoc = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(ITPhieuNhapxuatthuoc);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        string       errMsg       = "";
                        ActionResult actionResult =
                            _NHAPKHO.HuyXacNhanPhieuNhapKho(objTPhieuNhapxuatthuoc, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar1.Panels["MSG"], "Bạn thực hiện hủy nhập kho thành công", false);
                            grdList.CurrentRow.BeginEdit();
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.TrangThai].Value    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Exceed:
                            Utility.ShowMsg("Thuốc nhập đã được sử dụng hết nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.NotEnoughDrugInStock:
                            Utility.ShowMsg("Thuốc nhập đã được sử dụng nên bạn không thể hủy phiếu nhập", "Thông báo lỗi", MessageBoxIcon.Error);
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
                ModifyCommand();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// hàm thực hiện việc in phiếu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdInPhieuNhap_Click(object sender, EventArgs e)
        {
            int IDPhieuNhap = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
            TPhieuNhapxuatthuoc objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(IDPhieuNhap);

            if (objPhieuNhap != null)
            {
                //switch (THU_VIEN_CHUNG.LayMaDviLamViec())
                //{
                //    case "NOITIET":
                //        VNS.HIS.UI.BaoCao.CLS.INPHIEU_XUATKHO_THUOC.LAOKHOA_PHIEUXUAT_KHOLE_TOIKHOA(IDPhieuNhap, "PHIẾU CẤP PHÁT THUỐC CHO KHOA", globalVariables.SysDate);
                //        break;
                //    default:
                //        VNS.HIS.UI.BaoCao.CLS.INPHIEU_XUATKHO_THUOC.LAOKHOA_PHIEUXUAT_KHOTHUOC(IDPhieuNhap, "PHIẾU CẤP PHÁT THUỐC CHO KHOA", globalVariables.SysDate);
                //        break;
                //}
            }
        }
Exemplo n.º 23
0
        private void cmdHuychuyenkho_Click(object sender, EventArgs e)
        {
            try
            {
                cmdHuychuyenkho.Enabled = false;
                Utility.SetMsg(uiStatusBar2.Panels["MSG"], "", false);
                if (Utility.AcceptQuestion("Bạn có muốn hủy xác nhận phiếu thanh lý thuốc đang chọn này không?", "Thông báo", true))
                {
                    int IdPhieu = Utility.Int32Dbnull(grdList.GetValue(TPhieuNhapxuatthuoc.Columns.IdPhieu), -1);
                    TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(IdPhieu);
                    if (objTPhieuNhapxuatthuoc != null)
                    {
                        if (Utility.ByteDbnull(objTPhieuNhapxuatthuoc.TrangThai, 0) == 0)
                        {
                            return;
                        }
                        string       errMsg       = "";
                        ActionResult actionResult =
                            new XuatThuoc().HuyXacNhanPhieuHuy_thanhly_Thuoc(objTPhieuNhapxuatthuoc, ref errMsg);
                        switch (actionResult)
                        {
                        case ActionResult.Success:
                            Utility.SetMsg(uiStatusBar2.Panels["MSG"], "Bạn thực hiện hủy 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    = 0;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NgayXacnhan].Value  = DBNull.Value;
                            grdList.CurrentRow.Cells[TPhieuNhapxuatthuoc.Columns.NguoiXacnhan].Value = DBNull.Value;
                            grdList.CurrentRow.EndEdit();
                            break;

                        case ActionResult.Error:
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }
        private void UpdatePhieuXuatKho()
        {
            TPhieuNhapxuatthuoc objPhieuNhap = CreatePhieuNhapKho();

            ActionResult actionResult = new XuatThuoc().UpdatePhieuXuatKho(objPhieuNhap, CreateArrPhieuChiTiet());

            switch (actionResult)
            {
            case ActionResult.Success:
                TPhieuNhapxuatthuoc objTPhieuNhapxuatthuoc = TPhieuNhapxuatthuoc.FetchByID(Utility.Int32Dbnull(txtIDPhieuNhapKho.Text));
                DataRow[]           arrDr =
                    p_mDataPhieuNhapKho.Select(string.Format("{0}={1}", TPhieuNhapxuatthuoc.Columns.IdPhieu,
                                                             Utility.Int32Dbnull(txtIDPhieuNhapKho.Text)));
                if (arrDr.GetLength(0) > 0)
                {
                    arrDr[0].Delete();
                }
                DataRow newDr = p_mDataPhieuNhapKho.NewRow();
                Utility.FromObjectToDatarow(objTPhieuNhapxuatthuoc, ref newDr);
                DmucChung objNhaCC = THU_VIEN_CHUNG.LaydoituongDmucChung("NHACUNGCAP", txtNhacungcap.myCode);
                if (objNhaCC != null)
                {
                    newDr["ten_nhacungcap"] = Utility.sDbnull(objNhaCC.Ten);
                }
                TDmucKho objKho = TDmucKho.FetchByID(Utility.Int32Dbnull(cboKhoXuat.SelectedValue, -1));
                if (objKho != null)
                {
                    newDr["ten_khoxuat"] = Utility.sDbnull(objKho.TenKho);
                }
                p_mDataPhieuNhapKho.Rows.Add(newDr);

                Utility.GonewRowJanus(grdList, TPhieuNhapxuatthuoc.Columns.IdPhieu, Utility.sDbnull(txtIDPhieuNhapKho.Text));
                //Utility.ShowMsg("Bạn sửa  phiếu thành công", "Thông báo");
                m_enAction = action.Insert;
                this.Close();
                b_Cancel = true;
                break;

            case ActionResult.Error:
                Utility.ShowMsg("Lỗi trong quá trình sửa phiếu", "Thông báo lỗi", MessageBoxIcon.Error);
                break;
            }
        }
Exemplo n.º 25
0
        /// <summary>
        /// hàm thực hiện việc thêm phiếu nhập kho thuốc
        /// </summary>
        /// <param name="objPhieuNhap"></param>
        /// <param name="arrPhieuNhapCts"></param>
        /// <returns></returns>
        public ActionResult ThemPhieuXuatKho(TPhieuNhapxuatthuoc objPhieuNhap, TPhieuNhapxuatthuocChitiet[] arrPhieuNhapCts)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        objPhieuNhap.NgayTao  = globalVariables.SysDate;
                        objPhieuNhap.NguoiTao = globalVariables.UserName;
                        objPhieuNhap.MaPhieu  = Utility.sDbnull(THU_VIEN_CHUNG.MaNhapKho(Utility.Int32Dbnull(objPhieuNhap.LoaiPhieu)));
                        objPhieuNhap.TongTien = arrPhieuNhapCts.Sum(c => c.ThanhTien);
                        objPhieuNhap.IsNew    = true;
                        objPhieuNhap.Save();

                        objPhieuNhap = TPhieuNhapxuatthuoc.FetchByID(objPhieuNhap.IdPhieu);
                        if (objPhieuNhap != null)
                        {
                            foreach (TPhieuNhapxuatthuocChitiet objPhieuNhapCt in arrPhieuNhapCts)
                            {
                                objPhieuNhapCt.IdPhieu = Utility.Int32Dbnull(objPhieuNhap.IdPhieu, -1);
                                objPhieuNhapCt.IsNew   = true;
                                objPhieuNhapCt.Save();
                            }
                        }
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception exception)
            {
                log.Error("Loi trong qua trinh them :{0}", exception);
                return(ActionResult.Error);
            }
        }
        /// <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);
                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;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
            finally
            {
                ModifyCommand();
            }
        }