Пример #1
0
        // lưu đơn thuốc
        public string SaveDonthuoc(DonThuocDTO donThuoc, List <ChiTietDonThuocDTO> chiTietDonThuocs)
        {
            DonThuocBUS        donThuocBUS        = new DonThuocBUS();
            ChiTietDonThuocBUS chiTietDonThuocBUS = new ChiTietDonThuocBUS();
            HoSoBenhAnBUS      hoSoBenhAnBUS      = new HoSoBenhAnBUS();

            using (QLPHONGKHAMEntities db = new QLPHONGKHAMEntities())
            {
                using (var trans = db.Database.BeginTransaction())
                {
                    string maDonThuoc = donThuocBUS.getMaDonThuoc(db);
                    donThuoc.MaDonThuoc = maDonThuoc;
                    if (donThuocBUS.SaveDonThuoc(db, donThuoc).Equals(Constant.RES_FAI))
                    {
                        trans.Rollback();
                        return(Constant.RES_FAI);
                    }

                    foreach (var ct in chiTietDonThuocs)
                    {
                        ct.MaDonThuoc = maDonThuoc;
                        if (chiTietDonThuocBUS.SaveChiTietDonThuoc(db, ct).Equals(Constant.RES_FAI))
                        {
                            trans.Rollback();
                            return(Constant.RES_FAI);
                        }
                    }
                    trans.Commit();
                }
                db.SaveChanges();
            }
            return(Constant.RES_SUC);
        }
Пример #2
0
        public void GetInformation_TestCase2()
        {
            DonThuocDTO donThuocDTO = null;
            DonThuocBUS donThuocBUS = new DonThuocBUS();
            string      actual      = donThuocBUS.GetInformationDonThuocWithId(db, "1234567890", out donThuocDTO);

            string expected = "0000";

            Assert.Equals(actual, expected);
        }
Пример #3
0
        // Test insert without MaDonThuoc or MaHoSo
        public void Save_TestCase2()
        {
            DonThuocDTO donThuocDTO = new DonThuocDTO
            {
                NgayLap = TestCommon.LEN_8,
                GhiChu  = TestCommon.LEN_250
            };
            DonThuocBUS donThuocBUS = new DonThuocBUS();
            // execute
            string actual   = donThuocBUS.SaveDonThuoc(db, donThuocDTO);
            string expected = "1111";

            // compare
            Assert.Equals(actual, expected);
        }
Пример #4
0
        public void Save_TestCase3()
        {
            DonThuocDTO donThuocDTO = new DonThuocDTO
            {
                MaDonThuoc = TestCommon.LEN_10,
                MaHoSo     = "123",
            };
            DonThuocBUS donThuocBUS = new DonThuocBUS();
            // execute
            string actual   = donThuocBUS.SaveDonThuoc(db, donThuocDTO);
            string expected = "1111";

            // compare
            Assert.Equals(actual, expected);
        }
Пример #5
0
        // Lay thong tin don thuoc
        public string GetDonThuoc(string MaHoSo, out DonThuocDTO donThuoc, out List <ChiTietDonThuocDTO> chiTietDonThuocs)
        {
            donThuoc         = new DonThuocDTO();
            chiTietDonThuocs = new List <ChiTietDonThuocDTO>();
            DonThuocBUS        donThuocBUS        = new DonThuocBUS();
            ChiTietDonThuocBUS chiTietDonThuocBUS = new ChiTietDonThuocBUS();

            using (QLPHONGKHAMEntities db = new QLPHONGKHAMEntities())
            {
                if (donThuocBUS.GetInformationDonThuocWithId(db, MaHoSo, out donThuoc) == Constant.RES_FAI)
                {
                    return(Constant.RES_FAI);
                }
                if (chiTietDonThuocBUS.GetListWithIdDonThuoc(db, donThuoc.MaDonThuoc, out chiTietDonThuocs) == Constant.RES_FAI)
                {
                    return(Constant.RES_FAI);
                }
            }
            return(Constant.RES_SUC);
        }
Пример #6
0
        // XÓA ĐƠN THUỐC
        public string DeleteDonThuoc(DonThuocDTO donThuoc)
        {
            DonThuocBUS        donThuocBUS        = new DonThuocBUS();
            ChiTietDonThuocBUS chiTietDonThuocBUS = new ChiTietDonThuocBUS();
            HoSoBenhAnBUS      hoSoBenhAnBUS      = new HoSoBenhAnBUS();

            using (QLPHONGKHAMEntities db = new QLPHONGKHAMEntities())
            {
                using (var trans = db.Database.BeginTransaction())
                {
                    // xoá tất cả ctdt
                    if (chiTietDonThuocBUS.DeleteAllWithId(db, donThuoc.MaDonThuoc) == Constant.RES_FAI)
                    {
                        trans.Rollback();
                        return(Constant.RES_FAI);
                    }
                    // Xóa đơn thuốc
                    if (donThuocBUS.Delete(db, donThuoc.MaDonThuoc) == Constant.RES_FAI)
                    {
                        trans.Rollback();
                        return(Constant.RES_FAI);
                    }
                    HoSoBenhAnDTO hoSo = new HoSoBenhAnDTO();
                    if (hoSoBenhAnBUS.GetInfomationHoSo(db, donThuoc.MaHoSo, out hoSo) == Constant.RES_FAI)
                    {
                        trans.Rollback();
                        return(Constant.RES_FAI);
                    }
                    hoSo.CoKeDon = false;
                    if (hoSoBenhAnBUS.UpdateHoSoBenhAn(db, hoSo) == Constant.RES_FAI)
                    {
                        trans.Rollback();
                        return(Constant.RES_FAI);
                    }
                    trans.Commit();
                }
                db.SaveChanges();
            }
            return(Constant.RES_SUC);
        }
Пример #7
0
        public void GetInformation_TestCase1()
        {
            // create data search
            db.DONTHUOCs.Add(new DONTHUOC {
                MaHoSo = "1234567890"
            });
            db.DONTHUOCs.Add(new DONTHUOC {
                MaHoSo = "1234567891"
            });
            db.DONTHUOCs.Add(new DONTHUOC {
                MaHoSo = "1234567892"
            });

            DonThuocDTO donThuocDTO = null;
            DonThuocBUS donThuocBUS = new DonThuocBUS();

            string actual = donThuocBUS.GetInformationDonThuocWithId(db, "1234567890", out donThuocDTO);

            string expected = "0000";

            Assert.Equals(actual, expected);
        }