Beispiel #1
0
        void ProcessDataInsert(TPhieutrathuocthua _item)
        {
            DataRow drNew = m_dtData.NewRow();

            drNew[TPhieutrathuocthua.Columns.NgayLapphieu]  = _item.NgayLapphieu;
            drNew[TPhieutrathuocthua.Columns.Id]            = _item.Id;
            drNew[TPhieutrathuocthua.Columns.IdKhonhan]     = _item.IdKhonhan;
            drNew[TPhieutrathuocthua.Columns.IdKhoatra]     = _item.IdKhoatra;
            drNew[TPhieutrathuocthua.Columns.NguoiLapphieu] = _item.NguoiLapphieu;
            drNew[TPhieutrathuocthua.Columns.TrangThai]     = _item.TrangThai;
            drNew[TPhieutrathuocthua.Columns.NguoiTao]      = _item.NguoiTao;
            drNew[TPhieutrathuocthua.Columns.NgayTao]       = _item.NgayTao;
            if (m_enAction == action.Update)
            {
                drNew[TPhieutrathuocthua.Columns.NguoiSua] = _item.NguoiSua;
                drNew[TPhieutrathuocthua.Columns.NgaySua]  = _item.NgaySua;
            }
            drNew["ten_khoanoitru"] = txtKhoanoitru.Text;
            drNew["ten_kho"]        = txtKhothuoc.Text;
            drNew["ten_khoanoitru"] = txtKhoanoitru.Text;
            drNew["sngay_lapphieu"] = _item.NgayLapphieu.ToString("dd/MM/yyyy");
            drNew["sngay_tra"]      = "";

            m_dtData.Rows.InsertAt(drNew, 0);
            m_dtData.AcceptChanges();
        }
Beispiel #2
0
        TPhieutrathuocthua getPhieu()
        {
            _item = new TPhieutrathuocthua();
            if (m_enAction == action.Update)
            {
                _item = TPhieutrathuocthua.FetchByID(idPhieutra);
            }
            _item.MaPhieu       = "";
            _item.NgayLapphieu  = dtpInputDate.Value;
            _item.NguoiLapphieu = Utility.Int16Dbnull(txtNhanvien.MyID, -1);
            _item.IdKhoatra     = Utility.Int16Dbnull(txtKhoanoitru.MyID, -1);
            _item.IdKhonhan     = Utility.Int16Dbnull(txtKhothuoc.MyID, -1);

            if (m_enAction == action.Insert)
            {
                _item.KieuThuocVt = kieu_thuoc_vt;
                _item.TrangThai   = 0;
                _item.NguoiTao    = globalVariables.UserName;
                _item.NgayTao     = globalVariables.SysDate;
            }
            else
            {
                _item.NguoiSua = globalVariables.UserName;
                _item.NgaySua  = globalVariables.SysDate;
            }
            return(_item);
        }
 public ActionResult ThemPhieutrathuocthua(TPhieutrathuocthua _phieutra, List <long> lstIdCt)
 {
     try
     {
         using (var Scope = new TransactionScope())
         {
             using (var dbScope = new SharedDbConnectionScope())
             {
                 _phieutra.IsNew = true;
                 _phieutra.Save();
                 if (_phieutra.Id > 0)
                 {
                     new Update(TPhieuCapphatChitiet.Schema)
                     .Set(TPhieuCapphatChitiet.Columns.IdPhieutralai).EqualTo(_phieutra.Id)
                     .Set(TPhieuCapphatChitiet.Columns.TrangthaiTralai).EqualTo(1)
                     .Where(TPhieuCapphatChitiet.Columns.IdChitiet).In(lstIdCt)
                     .Execute();
                 }
             }
             Scope.Complete();
             return(ActionResult.Success);
         }
     }
     catch (Exception ex)
     {
         Utility.CatchException("Lỗi khi thêm phiếu trả thuốc thừa", ex);
         return(ActionResult.Error);
     }
 }
Beispiel #4
0
        void cmdPrint_Click(object sender, EventArgs e)
        {
            TPhieutrathuocthua objPhieutrathuocthua = TPhieutrathuocthua.FetchByID(idPhieutra);

            if (objPhieutrathuocthua != null)
            {
                thuoc_baocao.InPhieutrathuocthua(objPhieutrathuocthua, "PHIẾU TRẢ THUỐC THỪA", globalVariables.SysDate);
            }
        }
        void cmdInphieu_Click(object sender, EventArgs e)
        {
            int _Id = Utility.Int32Dbnull(grdList.GetValue(TPhieutrathuocthua.Columns.Id), -1);

            TPhieutrathuocthua objPhieutrathuocthua = TPhieutrathuocthua.FetchByID(_Id);

            if (objPhieutrathuocthua != null)
            {
                thuoc_baocao.InPhieutrathuocthua(objPhieutrathuocthua, "PHIẾU TRẢ THUỐC THỪA", globalVariables.SysDate);
            }
        }
Beispiel #6
0
 void ResetDataByStatus()
 {
     if (m_enAction == action.Update)
     {
         _item = TPhieutrathuocthua.FetchByID(idPhieutra);
     }
     cmdAccept.Tag              = m_enAction == action.Update ? "0" : "1";
     lnkTonghoplai.Visible      = m_enAction == action.Update;
     cmdAccept.ContextMenuStrip = m_enAction == action.Update ? contextMenuStrip2 : null;
     SetStatus();
     ModifyCommands();
 }
        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();
            }
        }
Beispiel #8
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;
        }
Beispiel #9
0
        public ActionResult CappnhatPhieuTrathuocthua(TPhieutrathuocthua _phieutra, List<long> lstIdCt)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {

                        new Update(TPhieutrathuocthua.Schema).Set(TPhieutrathuocthua.NgayLapphieuColumn).EqualTo(_phieutra.NgayLapphieu.Date)
                            .Set(TPhieutrathuocthua.NguoiLapphieuColumn).EqualTo(_phieutra.NguoiLapphieu)
                            .Set(TPhieutrathuocthua.IdKhoatraColumn).EqualTo(_phieutra.IdKhoatra)
                            .Set(TPhieutrathuocthua.IdKhonhanColumn).EqualTo(_phieutra.IdKhonhan)
                             .Set(TPhieutrathuocthua.NgaySuaColumn).EqualTo(_phieutra.NgaySua.Value)
                            .Set(TPhieutrathuocthua.NguoiSuaColumn).EqualTo(_phieutra.NguoiSua)
                            .Where(TPhieutrathuocthua.IdColumn).IsEqualTo(_phieutra.Id).Execute();

                        new Update(TPhieuCapphatChitiet.Schema)
                           .Set(TPhieuCapphatChitiet.Columns.IdPhieutralai).EqualTo(-1)
                            .Set(TPhieuCapphatChitiet.Columns.TrangthaiTralai).EqualTo(0)
                           .Where(TPhieuCapphatChitiet.Columns.IdPhieutralai).IsEqualTo(_phieutra.Id)
                           .Execute();

                        new Update(TPhieuCapphatChitiet.Schema)
                            .Set(TPhieuCapphatChitiet.Columns.IdPhieutralai).EqualTo(_phieutra.Id)
                             .Set(TPhieuCapphatChitiet.Columns.TrangthaiTralai).EqualTo(1)
                            .Where(TPhieuCapphatChitiet.Columns.IdChitiet).In(lstIdCt)
                            .Execute();

                        Scope.Complete();
                    }
                    return ActionResult.Success;
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi cập nhật phiếu trả thuốc thừa", ex);
                return ActionResult.Error;
            }
        }
Beispiel #10
0
        public ActionResult CappnhatPhieuTrathuocthua(TPhieutrathuocthua _phieutra, List <long> lstIdCt)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        new Update(TPhieutrathuocthua.Schema).Set(TPhieutrathuocthua.NgayLapphieuColumn).EqualTo(_phieutra.NgayLapphieu.Date)
                        .Set(TPhieutrathuocthua.NguoiLapphieuColumn).EqualTo(_phieutra.NguoiLapphieu)
                        .Set(TPhieutrathuocthua.IdKhoatraColumn).EqualTo(_phieutra.IdKhoatra)
                        .Set(TPhieutrathuocthua.IdKhonhanColumn).EqualTo(_phieutra.IdKhonhan)
                        .Set(TPhieutrathuocthua.NgaySuaColumn).EqualTo(_phieutra.NgaySua.Value)
                        .Set(TPhieutrathuocthua.NguoiSuaColumn).EqualTo(_phieutra.NguoiSua)
                        .Where(TPhieutrathuocthua.IdColumn).IsEqualTo(_phieutra.Id).Execute();

                        new Update(TPhieuCapphatChitiet.Schema)
                        .Set(TPhieuCapphatChitiet.Columns.IdPhieutralai).EqualTo(-1)
                        .Set(TPhieuCapphatChitiet.Columns.TrangthaiTralai).EqualTo(0)
                        .Where(TPhieuCapphatChitiet.Columns.IdPhieutralai).IsEqualTo(_phieutra.Id)
                        .Execute();

                        new Update(TPhieuCapphatChitiet.Schema)
                        .Set(TPhieuCapphatChitiet.Columns.IdPhieutralai).EqualTo(_phieutra.Id)
                        .Set(TPhieuCapphatChitiet.Columns.TrangthaiTralai).EqualTo(1)
                        .Where(TPhieuCapphatChitiet.Columns.IdChitiet).In(lstIdCt)
                        .Execute();

                        Scope.Complete();
                    }
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi cập nhật phiếu trả thuốc thừa", ex);
                return(ActionResult.Error);
            }
        }
 void ResetDataByStatus()
 {
     if (m_enAction == action.Update) _item = TPhieutrathuocthua.FetchByID(idPhieutra);
     cmdAccept.Tag = m_enAction == action.Update ? "0" : "1";
     lnkTonghoplai.Visible = m_enAction == action.Update;
     cmdAccept.ContextMenuStrip = m_enAction == action.Update ? contextMenuStrip2 : null;
     SetStatus();
     ModifyCommands();
 }
Beispiel #12
0
        public ActionResult Xacnhanphieutrathuocthua(TPhieutrathuocthua _phieutrathuocthua)
        {
            ActionResult _result = ActionResult.Success;

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        long     idphieu    = _phieutrathuocthua.Id;
                        short    ID_KHO     = _phieutrathuocthua.IdKhonhan;
                        DateTime ngaytra    = _phieutrathuocthua.NgayTra.Value;
                        int      idnguoitra = _phieutrathuocthua.NguoiTra.Value;

                        TPhieuCapphatChitietCollection lstChitiet = new Select().From(TPhieuCapphatChitiet.Schema)
                                                                    .Where(TPhieuCapphatChitiet.Columns.IdPhieutralai).IsEqualTo(idphieu).ExecuteAsCollection <TPhieuCapphatChitietCollection>();

                        bool codulieu = false;
                        //Xác nhận từng đơn thuốc nội trú
                        foreach (TPhieuCapphatChitiet _item in lstChitiet)
                        {
                            codulieu = true;
                            KcbDonthuocChitiet objDetail = new Select().From(KcbDonthuocChitiet.Schema)
                                                           .Where(KcbDonthuocChitiet.Columns.IdChitietdonthuoc).IsEqualTo(_item.IdChitietdonthuoc)
                                                           .ExecuteSingle <KcbDonthuocChitiet>();
                            TPhieuXuatthuocBenhnhanChitiet PhieuXuatBnhanCt = new Select().From(TPhieuXuatthuocBenhnhanChitiet.Schema)
                                                                              .Where(TPhieuXuatthuocBenhnhanChitiet.Columns.IdChitietdonthuoc).IsEqualTo(objDetail.IdChitietdonthuoc)
                                                                              .ExecuteSingle <TPhieuXuatthuocBenhnhanChitiet>();

                            TPhieuXuatthuocBenhnhan objPhieuXuatBnhan = TPhieuXuatthuocBenhnhan.FetchByID(PhieuXuatBnhanCt.IdPhieu);

                            if (objDetail == null)
                            {
                                return(ActionResult.Exceed);
                            }

                            //Cộng vào kho nhận
                            long            id_Thuockho_new = -1;
                            long            iTThuockho_old  = PhieuXuatBnhanCt.IdThuockho.Value;
                            StoredProcedure sp = SPs.ThuocNhapkhoOutput(PhieuXuatBnhanCt.NgayHethan, PhieuXuatBnhanCt.GiaNhap, PhieuXuatBnhanCt.GiaBan,
                                                                        _item.SoLuongtralai, Utility.DecimaltoDbnull(PhieuXuatBnhanCt.Vat),
                                                                        PhieuXuatBnhanCt.IdThuoc, PhieuXuatBnhanCt.IdKho,
                                                                        PhieuXuatBnhanCt.MaNhacungcap, PhieuXuatBnhanCt.SoLo, PhieuXuatBnhanCt.SoDky, PhieuXuatBnhanCt.SoQdinhthau,
                                                                        PhieuXuatBnhanCt.IdThuockho.Value, id_Thuockho_new, PhieuXuatBnhanCt.NgayNhap,
                                                                        PhieuXuatBnhanCt.GiaBhyt, PhieuXuatBnhanCt.PhuthuDungtuyen, PhieuXuatBnhanCt.PhuthuTraituyen, _phieutrathuocthua.KieuThuocVt);
                            sp.Execute();

                            id_Thuockho_new = Utility.Int32Dbnull(sp.OutputValues[0]);
                            //Cập nhật lại ID Thuốc kho(Có thể xóa mất dòng số lượng =0 nên khi nhập kho tạo ra dòng mới)
                            if (id_Thuockho_new != -1) //Gặp trường hợp khi xuất hết thuốc thì xóa kho-->Khi hủy thì tạo ra dòng thuốc kho mới
                            {
                                objDetail.IdThuockho = id_Thuockho_new;
                                //Cập nhật tất cả các bảng liên quan
                                new Update(KcbDonthuocChitiet.Schema)
                                .Set(KcbDonthuocChitiet.Columns.IdThuockho).EqualTo(id_Thuockho_new)
                                .Where(KcbDonthuocChitiet.Columns.IdThuockho).IsEqualTo(iTThuockho_old).
                                Execute();

                                new Update(TBiendongThuoc.Schema)
                                .Set(TBiendongThuoc.Columns.IdThuockho).EqualTo(id_Thuockho_new)
                                .Where(TBiendongThuoc.Columns.IdThuockho).IsEqualTo(iTThuockho_old).
                                Execute();

                                new Update(TPhieuXuatthuocBenhnhanChitiet.Schema)
                                .Set(TPhieuXuatthuocBenhnhanChitiet.Columns.IdThuockho).EqualTo(id_Thuockho_new)
                                .Where(TPhieuXuatthuocBenhnhanChitiet.Columns.IdThuockho).IsEqualTo(iTThuockho_old).
                                Execute();

                                new Update(TPhieuCapphatChitiet.Schema)
                                .Set(TPhieuXuatthuocBenhnhanChitiet.Columns.IdThuockho).EqualTo(id_Thuockho_new)
                                .Where(TPhieuXuatthuocBenhnhanChitiet.Columns.IdThuockho).IsEqualTo(iTThuockho_old).
                                Execute();
                            }
                            //Cập nhật số lượng thực lĩnh theo Id chi tiết
                            //objDetail.SluongLinh = _item.ThucLinh;
                            //objDetail.MarkOld();
                            //objDetail.IsNew = false;
                            //objDetail.Save();
                            //Cập nhật trạng thái trả lại
                            _item.TrangthaiTralai = 2;
                            _item.IsNew           = false;
                            _item.MarkOld();
                            _item.Save();

                            //Insert bảng biến động liên quan đến kho nhập
                            TBiendongThuoc objNhapXuat = new TBiendongThuoc();
                            objNhapXuat.NgayHethan         = objDetail.NgayHethan;
                            objNhapXuat.IdThuockho         = objDetail.IdThuockho;
                            objNhapXuat.SoLo               = objDetail.SoLo;
                            objNhapXuat.SoDky              = objDetail.SoDky;
                            objNhapXuat.SoQdinhthau        = objDetail.SoQdinhthau;
                            objNhapXuat.MaNhacungcap       = objDetail.MaNhacungcap;
                            objNhapXuat.Vat                = (int)objDetail.Vat;
                            objNhapXuat.QuayThuoc          = objPhieuXuatBnhan.QuayThuoc;
                            objNhapXuat.MaPhieu            = Utility.sDbnull(_phieutrathuocthua.MaPhieu);
                            objNhapXuat.Noitru             = objPhieuXuatBnhan.Noitru;
                            objNhapXuat.NgayHoadon         = ngaytra;
                            objNhapXuat.NgayBiendong       = ngaytra;
                            objNhapXuat.NgayTao            = globalVariables.SysDate;
                            objNhapXuat.NguoiTao           = globalVariables.UserName;
                            objNhapXuat.SoLuong            = Utility.Int32Dbnull(_item.SoLuongtralai);
                            objNhapXuat.DonGia             = Utility.DecimaltoDbnull(PhieuXuatBnhanCt.DonGia);
                            objNhapXuat.GiaBan             = Utility.DecimaltoDbnull(PhieuXuatBnhanCt.GiaBan);
                            objNhapXuat.GiaNhap            = Utility.DecimaltoDbnull(PhieuXuatBnhanCt.GiaNhap);
                            objNhapXuat.PhuThu             = objDetail.PhuThu;
                            objNhapXuat.SoHoadon           = "-1";
                            objNhapXuat.IdThuoc            = Utility.Int32Dbnull(PhieuXuatBnhanCt.IdThuoc);
                            objNhapXuat.IdPhieu            = (int)_phieutrathuocthua.Id;
                            objNhapXuat.IdPhieuChitiet     = (int)_item.IdChitiet;
                            objNhapXuat.IdNhanvien         = globalVariables.gv_intIDNhanvien;
                            objNhapXuat.NgayNhap           = ngaytra;
                            objNhapXuat.GiaPhuthuTraituyen = objDetail.PhuthuTraituyen;
                            objNhapXuat.GiaPhuthuDungtuyen = objDetail.PhuthuDungtuyen;
                            objNhapXuat.MaNhacungcap       = PhieuXuatBnhanCt.MaNhacungcap;
                            objNhapXuat.IdKho              = _phieutrathuocthua.IdKhonhan;
                            objNhapXuat.MaLoaiphieu        = Utility.ByteDbnull(LoaiPhieu.Phieutrathuocthua);
                            objNhapXuat.TenLoaiphieu       = Utility.TenLoaiPhieu(LoaiPhieu.Phieutrathuocthua);
                            objNhapXuat.IdKhoaLinh         = _phieutrathuocthua.IdKhoatra;
                            objNhapXuat.KieuThuocvattu     = _phieutrathuocthua.KieuThuocVt;
                            objNhapXuat.ThanhTien          = Utility.DecimaltoDbnull(PhieuXuatBnhanCt.DonGia) *
                                                             Utility.Int32Dbnull(_item.SoLuongtralai);
                            objNhapXuat.IsNew = true;
                            objNhapXuat.Save();
                        }
                        if (!codulieu)
                        {
                            return(ActionResult.DataChanged);
                        }
                        //Cập nhật trạng thái cấp phát của phiếu đề nghị=1
                        new Update(TPhieutrathuocthua.Schema)
                        .Set(TPhieutrathuocthua.TrangThaiColumn.ColumnName).EqualTo(1)
                        .Set(TPhieutrathuocthua.NgayTraColumn.ColumnName).EqualTo(ngaytra)
                        .Set(TPhieutrathuocthua.NguoiNhanColumn.ColumnName).EqualTo(globalVariablesPrivate.objNhanvien != null ? globalVariablesPrivate.objNhanvien.IdNhanvien : globalVariables.gv_intIDNhanvien)
                        .Set(TPhieutrathuocthua.NguoiTraColumn.ColumnName).EqualTo(idnguoitra)
                        .Set(TPhieutrathuocthua.NgaySuaColumn.ColumnName).EqualTo(globalVariables.SysDate)
                        .Set(TPhieutrathuocthua.NguoiSuaColumn.ColumnName).EqualTo(globalVariables.UserName)
                        .Where(TPhieutrathuocthua.IdColumn).IsEqualTo(idphieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi xác nhận phiếu trả thuốc thừa", ex);
                return(ActionResult.Error);
            }
        }
Beispiel #13
0
        public ActionResult ThemPhieutrathuocthua(TPhieutrathuocthua _phieutra, List<long> lstIdCt)
        {
            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        _phieutra.IsNew = true;
                        _phieutra.Save();
                        if (_phieutra.Id > 0)
                        {
                            new Update(TPhieuCapphatChitiet.Schema)
                            .Set(TPhieuCapphatChitiet.Columns.IdPhieutralai).EqualTo(_phieutra.Id)
                            .Set(TPhieuCapphatChitiet.Columns.TrangthaiTralai).EqualTo(1)
                            .Where(TPhieuCapphatChitiet.Columns.IdChitiet).In(lstIdCt)
                            .Execute();
                        }

                    }
                    Scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi thêm phiếu trả thuốc thừa", ex);
                return ActionResult.Error;
            }
        }
        void ProcessDataInsert(TPhieutrathuocthua _item)
        {
            DataRow drNew = m_dtData.NewRow();
            drNew[TPhieutrathuocthua.Columns.NgayLapphieu] = _item.NgayLapphieu;
            drNew[TPhieutrathuocthua.Columns.Id] = _item.Id;
            drNew[TPhieutrathuocthua.Columns.IdKhonhan] = _item.IdKhonhan;
            drNew[TPhieutrathuocthua.Columns.IdKhoatra] = _item.IdKhoatra;
            drNew[TPhieutrathuocthua.Columns.NguoiLapphieu] = _item.NguoiLapphieu;
            drNew[TPhieutrathuocthua.Columns.TrangThai] = _item.TrangThai;
            drNew[TPhieutrathuocthua.Columns.NguoiTao] = _item.NguoiTao;
            drNew[TPhieutrathuocthua.Columns.NgayTao] = _item.NgayTao;
            if (m_enAction == action.Update)
            {
                drNew[TPhieutrathuocthua.Columns.NguoiSua] = _item.NguoiSua;
                drNew[TPhieutrathuocthua.Columns.NgaySua] = _item.NgaySua;
            }
            drNew["ten_khoanoitru"] = txtKhoanoitru.Text;
            drNew["ten_kho"] = txtKhothuoc.Text;
            drNew["ten_khoanoitru"] = txtKhoanoitru.Text;
            drNew["sngay_lapphieu"] = _item.NgayLapphieu.ToString("dd/MM/yyyy");
            drNew["sngay_tra"] = "";

            m_dtData.Rows.InsertAt(drNew, 0);
            m_dtData.AcceptChanges();
        }
        TPhieutrathuocthua getPhieu()
        {
            _item = new TPhieutrathuocthua();
            if (m_enAction == action.Update) _item = TPhieutrathuocthua.FetchByID(idPhieutra);
            _item.MaPhieu = "";
            _item.NgayLapphieu = dtpInputDate.Value;
            _item.NguoiLapphieu =Utility.Int16Dbnull( txtNhanvien.MyID,-1);
            _item.IdKhoatra = Utility.Int16Dbnull(txtKhoanoitru.MyID, -1);
            _item.IdKhonhan = Utility.Int16Dbnull(txtKhothuoc.MyID, -1);

            if (m_enAction == action.Insert)
            {
                _item.KieuThuocVt = kieu_thuoc_vt;
                _item.TrangThai = 0;
                _item.NguoiTao = globalVariables.UserName;
                _item.NgayTao = globalVariables.SysDate;

            }
            else
            {
                _item.NguoiSua = globalVariables.UserName;
                _item.NgaySua = globalVariables.SysDate;
            }
            return _item;
        }
Beispiel #16
0
        public static void InPhieutrathuocthuaTonghop(TPhieutrathuocthua objPhieutrathuocthua, string sTitleReport, DateTime NgayIn)
        {
            DataTable m_dtReport = SPs.ThuocNoitruInTonghopPhieutrathuocthua(objPhieutrathuocthua.Id).GetDataSet().Tables[0];
            if (m_dtReport.Rows.Count <= 0)
            {
                Utility.ShowMsg("Không tìm thấy thông tin ", "Thông báo", MessageBoxIcon.Warning);
                return;
            }
            THU_VIEN_CHUNG.CreateXML(m_dtReport, "thuoc_noitru_phieutrathuocthua");
            string tieude = "", reportname = "";
            var crpt = Utility.GetReport("thuoc_noitru_phieutrathuocthua", ref tieude, ref reportname);

            if (crpt == null) return;
            Utility.UpdateLogotoDatatable(ref m_dtReport);
            frmPrintPreview objForm = new frmPrintPreview(sTitleReport, crpt, true, true);

            try
            {
                m_dtReport.AcceptChanges();
                crpt.SetDataSource(m_dtReport);
                objForm.mv_sReportFileName = Path.GetFileName(reportname);
                objForm.mv_sReportCode = "thuoc_noitru_phieutrathuocthua";

                Utility.SetParameterValue(crpt, "ParentBranchName", globalVariables.ParentBranch_Name);
                Utility.SetParameterValue(crpt, "BranchName", globalVariables.Branch_Name);
                Utility.SetParameterValue(crpt, "sTitleReport", tieude);
                Utility.SetParameterValue(crpt, "BottomCondition", THU_VIEN_CHUNG.BottomCondition());
                objForm.crptViewer.ReportSource = crpt;
                objForm.ShowDialog();
            }
            catch (Exception ex)
            {
                Utility.CatchException(ex);
            }
        }
Beispiel #17
0
 public static void InPhieutrathuocthua(TPhieutrathuocthua objPhieutrathuocthua, string sTitleReport, DateTime NgayIn)
 {
     if (PropertyLib._TrathuocthuaProperties.Kieuin == LoaiphieuIn.Tonghop)
         InPhieutrathuocthuaTonghop(objPhieutrathuocthua, sTitleReport, NgayIn);
     else if (PropertyLib._TrathuocthuaProperties.Kieuin == LoaiphieuIn.Chitiet)
         InPhieutrathuocthuaChitiet(objPhieutrathuocthua, sTitleReport, NgayIn);
     else
     {
         InPhieutrathuocthuaTonghop(objPhieutrathuocthua, sTitleReport, NgayIn);
         InPhieutrathuocthuaChitiet(objPhieutrathuocthua, sTitleReport, NgayIn);
     }
 }
Beispiel #18
0
        public ActionResult HuyXacnhanphieuphieutrathuocthua(TPhieutrathuocthua _phieutrathuocthua, ref string errMsg)
        {
            ActionResult _result = ActionResult.Success;

            try
            {
                using (var Scope = new TransactionScope())
                {
                    using (var dbScope = new SharedDbConnectionScope())
                    {
                        bool codulieu = false;

                        long  idphieu = _phieutrathuocthua.Id;
                        short ID_KHO  = _phieutrathuocthua.IdKhonhan;
                        TPhieuCapphatChitietCollection lstChitiet = new Select().From(TPhieuCapphatChitiet.Schema)
                                                                    .Where(TPhieuCapphatChitiet.Columns.IdPhieutralai).IsEqualTo(idphieu).ExecuteAsCollection <TPhieuCapphatChitietCollection>();
                        ActionResult _Kiemtrathuochuyxacnhan = Kiemtratonthuoc(lstChitiet, ID_KHO);
                        if (_Kiemtrathuochuyxacnhan != ActionResult.Success)
                        {
                            return(_Kiemtrathuochuyxacnhan);
                        }
                        foreach (TPhieuCapphatChitiet _item in lstChitiet)
                        {
                            codulieu = true;
                            KcbDonthuocChitiet objDetail = new Select().From(KcbDonthuocChitiet.Schema)
                                                           .Where(KcbDonthuocChitiet.Columns.IdChitietdonthuoc).IsEqualTo(_item.IdChitietdonthuoc)
                                                           .ExecuteSingle <KcbDonthuocChitiet>();
                            TPhieuXuatthuocBenhnhanChitiet PhieuXuatBnhanCt = new Select().From(TPhieuXuatthuocBenhnhanChitiet.Schema)
                                                                              .Where(TPhieuXuatthuocBenhnhanChitiet.Columns.IdChitietdonthuoc).IsEqualTo(objDetail.IdChitietdonthuoc)
                                                                              .ExecuteSingle <TPhieuXuatthuocBenhnhanChitiet>();

                            TPhieuXuatthuocBenhnhan objPhieuXuatBnhan = TPhieuXuatthuocBenhnhan.FetchByID(PhieuXuatBnhanCt.IdPhieu);

                            StoredProcedure sp = SPs.ThuocXuatkho(Utility.Int32Dbnull(_phieutrathuocthua.IdKhonhan),
                                                                  Utility.Int32Dbnull(_item.IdThuoc, -1),
                                                                  objDetail.NgayHethan, objDetail.GiaNhap, Utility.DecimaltoDbnull(objDetail.GiaBan),
                                                                  Utility.DecimaltoDbnull(objDetail.Vat), _item.SoLuongtralai, objDetail.IdThuockho, objDetail.MaNhacungcap, objDetail.SoLo, PropertyLib._HisDuocProperties.XoaDulieuKhiThuocDaHet ? 1 : 0, errMsg);

                            sp.Execute();
                            //Cập nhật trạng thái trả lại
                            _item.TrangthaiTralai = 1;
                            _item.IsNew           = false;
                            _item.MarkOld();
                            _item.Save();
                        }
                        //Xóa trong bảng biến động
                        new Delete().From(TBiendongThuoc.Schema).Where(TBiendongThuoc.Columns.IdPhieu).IsEqualTo(_phieutrathuocthua.Id)
                        .And(TBiendongThuoc.Columns.MaLoaiphieu).IsEqualTo(LoaiPhieu.Phieutrathuocthua)
                        .Execute();
                        if (!codulieu)
                        {
                            return(ActionResult.DataChanged);
                        }
                        //Cập nhật trạng thái phiếu trả thuốc về 0//Chưa trả
                        new Update(TPhieutrathuocthua.Schema)
                        .Set(TPhieutrathuocthua.TrangThaiColumn.ColumnName).EqualTo(0)
                        .Set(TPhieutrathuocthua.NgayTraColumn.ColumnName).EqualTo(null)
                        .Set(TPhieutrathuocthua.NguoiNhanColumn.ColumnName).EqualTo(-1)
                        .Set(TPhieutrathuocthua.NguoiTraColumn.ColumnName).EqualTo(-1)
                        .Set(TPhieutrathuocthua.NgaySuaColumn.ColumnName).EqualTo(null)
                        .Set(TPhieutrathuocthua.NguoiSuaColumn.ColumnName).EqualTo("")
                        .Where(TPhieutrathuocthua.IdColumn).IsEqualTo(idphieu).Execute();
                    }
                    Scope.Complete();
                    return(ActionResult.Success);
                }
            }
            catch (Exception ex)
            {
                Utility.CatchException("Lỗi khi hủy xác nhận phiếu trả thuốc thừa", ex);
                errMsg = ex.Message;
                return(ActionResult.Exception);
            }
        }
        public void Insert(string MaPhieu,DateTime NgayLapphieu,short NguoiLapphieu,DateTime? NgayTra,short? NguoiTra,short? NguoiNhan,short IdKhoatra,short IdKhonhan,string KieuThuocVt,byte TrangThai,string NguoiTao,DateTime NgayTao,string NguoiSua,DateTime? NgaySua)
        {
            TPhieutrathuocthua item = new TPhieutrathuocthua();

            item.MaPhieu = MaPhieu;

            item.NgayLapphieu = NgayLapphieu;

            item.NguoiLapphieu = NguoiLapphieu;

            item.NgayTra = NgayTra;

            item.NguoiTra = NguoiTra;

            item.NguoiNhan = NguoiNhan;

            item.IdKhoatra = IdKhoatra;

            item.IdKhonhan = IdKhonhan;

            item.KieuThuocVt = KieuThuocVt;

            item.TrangThai = TrangThai;

            item.NguoiTao = NguoiTao;

            item.NgayTao = NgayTao;

            item.NguoiSua = NguoiSua;

            item.NgaySua = NgaySua;

            item.Save(UserName);
        }
        /// <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();
            }
        }