Exemple #1
0
        public void SuaBenh()
        {
            BenhDTO b = new BenhDTO();

            bbus      = new BenhBUS();
            b.MaBenh  = "10";
            b.TenBenh = "Ung thu";
            Assert.AreEqual(true, bbus.sua(b, "10"));
        }
Exemple #2
0
        public void XoaBenh()
        {
            BenhDTO b = new BenhDTO();

            bbus     = new BenhBUS();
            b.MaBenh = "11";
            bool kq = bbus.xoa(b);

            Assert.AreEqual(true, kq);
        }
Exemple #3
0
        public void ThemBenh()
        {
            BenhDTO b = new BenhDTO();

            bbus      = new BenhBUS();
            b.MaBenh  = bbus.autogenerate_mabenh().ToString();
            b.TenBenh = "Tieuchay";
            bool kq = bbus.them(b);

            Assert.AreEqual(true, kq);
        }
        private void grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid    gd           = (DataGrid)sender;
            DataRowView row_selected = gd.SelectedItem as DataRowView;

            be = new BenhDTO();
            if (row_selected != null)
            {
                be.TenBenh = row_selected["tenBenh"].ToString();
                be.MaBenh  = row_selected["maBenh"].ToString();
                temp       = be.MaBenh.ToString();
            }
        }
 public async Task <BaseResponse> InsertAll(BenhDTO entity)
 {
     try
     {
         var result = _benhService.InsertAll(entity);
         if (result)
         {
             return(await Task.FromResult(new BaseResponse(result)));
         }
         return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess)));
     }
     catch (Exception e)
     {
         return(await Task.FromResult(new BaseResponse(Message.CreateNotSuccess)));
     }
 }
 public async Task <BaseResponse> Update(BenhDTO benhDTO)
 {
     try
     {
         var result = _benhService.Update(benhDTO);
         if (result)
         {
             return(await Task.FromResult(new BaseResponse(result)));
         }
         return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         return(await Task.FromResult(new BaseResponse(Message.UpdateNotSuccess, false)).ConfigureAwait(false));
     }
 }
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            be        = new BenhDTO();
            be.MaBenh = temp;
            beBus     = new BenhBUS();
            bool kq = beBus.xoa(be);

            if (kq == false)
            {
                MessageBox.Show("Xóa loại bệnh thất bại. Vui lòng kiểm tra lại dũ liệu", "Result", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
            }
            else
            {
                MessageBox.Show("Xóa loại bệnh thành công", "Result");
            }
            load_data();
        }
Exemple #8
0
        public bool Create(BenhDTO benhDto)
        {
            try
            {
                var item = CheckExistsTenbenh(benhDto.TenBenh);
                if (item)
                {
                    return(false);
                }
                var benh = new Benh
                {
                    MaBenh      = Guid.NewGuid(),
                    TenBenh     = benhDto.TenBenh,
                    NguyenNhan  = benhDto.NguyenNhan,
                    CachDieuTri = benhDto.CachDieuTri,
                    MoTa        = benhDto.MoTa,
                    HinhAnh     = benhDto.HinhAnh,
                };
                _benhRepository.Insert(benh);
                _unitOfWork.Commit();

                if (benhDto.MaThuocs != null)
                {
                    foreach (var mathuoc in benhDto.MaThuocs)
                    {
                        var thuocdieutri = new ThuocDieuTri
                        {
                            MaBenh  = benh.MaBenh,
                            MaThuoc = new Guid(mathuoc),
                        };
                        _unitOfWork.Commit();
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemple #9
0
        public bool Update(BenhDTO benhDto)
        {
            try
            {
                var benh = _benhRepository.GetById(benhDto.MaBenh);
                if (benh == null)
                {
                    return(false);
                }
                // Update chi tiet
                benh.MaBenh      = benhDto.MaBenh;
                benh.TenBenh     = benhDto.TenBenh.ToLower();
                benh.NguyenNhan  = benhDto.NguyenNhan;
                benh.CachDieuTri = benhDto.CachDieuTri;
                benh.MoTa        = benhDto.MoTa;
                benh.HinhAnh     = benhDto.HinhAnh;

                //update thuốc điều trị
                var thuocdieutriOld = _thuocdieutriRepository.GetMany(p => p.MaBenh == benh.MaBenh).ToList();
                _thuocdieutriRepository.RemoveMultiple(thuocdieutriOld);

                var thuocs = _thuocRepository.GetMany(r => benhDto.MaThuocs.Contains(r.MaThuoc.ToString()));
                foreach (var thuoc in thuocs)
                {
                    var thuocdieutri = new ThuocDieuTri {
                        MaBenh = benh.MaBenh, MaThuoc = thuoc.MaThuoc
                    };

                    _thuocdieutriRepository.Insert(thuocdieutri);
                }
                // update user
                _benhRepository.Update(benh);
                _unitOfWork.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #10
0
 private void Sua_Click(object sender, RoutedEventArgs e)
 {
     if (mabenh.Text == null || tenbenh.Text == "")
     {
         MessageBox.Show("Vui lòng nhập đầy đủ thông tin loại bệnh");
     }
     else
     {
         BenhDTO be = new BenhDTO();
         be.MaBenh  = mabenh.Text;
         be.TenBenh = tenbenh.Text;
         beBus      = new BenhBUS();
         bool kq = beBus.sua(be, temp);
         if (kq == false)
         {
             MessageBox.Show("Sửa Bệnh thất bại. Vui lòng kiểm tra lại dũ liệu", "Result", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
         }
         else
         {
             MessageBox.Show("Sửa Bệnh thành công", "Result");
         }
     }
 }
Exemple #11
0
        public bool xoa(BenhDTO be)
        {
            bool re = beDAL.xoa(be);

            return(true);
        }
Exemple #12
0
        public bool sua(BenhDTO be, string maBenhold)
        {
            bool re = beDAL.sua(be, maBenhold);

            return(re);
        }
Exemple #13
0
        public bool them(BenhDTO be)
        {
            bool re = beDAL.them(be);

            return(re);
        }
Exemple #14
0
        public bool InsertAll(BenhDTO userRoleDataPopups)
        {
            var item = CheckExistsTenbenh(userRoleDataPopups.TenBenh);

            if (item)
            {
                return(false);
            }
            var benh = new Benh
            {
                MaBenh      = Guid.NewGuid(),
                TenBenh     = userRoleDataPopups.TenBenh,
                NguyenNhan  = userRoleDataPopups.NguyenNhan,
                CachDieuTri = userRoleDataPopups.CachDieuTri,
                MoTa        = userRoleDataPopups.MoTa,
                HinhAnh     = userRoleDataPopups.HinhAnh,
            };

            _benhRepository.Insert(benh);
            _unitOfWork.Commit();

            if (userRoleDataPopups.MaThuocs != null)
            {
                foreach (var mathuoc in userRoleDataPopups.MaThuocs)
                {
                    var thuocdieutri = new ThuocDieuTri {
                        MaBenh = benh.MaBenh, MaThuoc = new Guid(mathuoc)
                    };
                    _thuocdieutriRepository.Insert(thuocdieutri);
                }
                _unitOfWork.Commit();
            }


            if (userRoleDataPopups.MaTrieuChungs != null)
            {
                foreach (var matrieuchung in userRoleDataPopups.MaTrieuChungs)
                {
                    var trieuchungbenh = new TrieuChungBenh {
                        MaBenh = benh.MaBenh, MaTrieuChung = new Guid(matrieuchung)
                    };
                    _trieuchungbenhRepository.Insert(trieuchungbenh);
                }
                _unitOfWork.Commit();
            }

            // liệu trình

            //if (userRoleDataPopups.ListLieuTrinhs.Count <= 0)
            //{
            //    return true;
            //}
            ////insert new record
            //for (int i = 0; i < userRoleDataPopups.ListLieuTrinhs.Count; i++)
            //{
            //    var roleViewModel = userRoleDataPopups.ListLieuTrinhs[i];


            //    //if (LieuTrinhConstant.MaLieuTrinh_Empty.Equals(roleViewModel.MaLieuTrinh.ToString()))
            //    //{
            //        roleViewModel.MaBenh = benh.MaBenh;
            //        roleViewModel.MaLieuTrinh = Guid.NewGuid();
            //    //    continue;
            //    //}
            //    var lstLieuTrinhs = _lieutrinhRepository.GetAll()
            //        .Where(p => p.MaLieuTrinh == roleViewModel.MaLieuTrinh && p.MaBenh == roleViewModel.MaBenh).ToList();
            //    LieuTrinh LieuTrinh = null;
            //    switch (lstLieuTrinhs.Count)
            //    {
            //        case 0:
            //            LieuTrinh = new LieuTrinh
            //            {
            //                MaBenh = roleViewModel.MaBenh,
            //                MaLieuTrinh = roleViewModel.MaLieuTrinh,
            //                TenLieuTrinh = roleViewModel.TenLieuTrinh,
            //                MoTaLieuTrinh = roleViewModel.MoTaLieuTrinh
            //            };
            //            _lieutrinhRepository.Insert(LieuTrinh);
            //            break;
            //        default:
            //            LieuTrinh = lstLieuTrinhs[0];

            //            _lieutrinhRepository.Update(LieuTrinh);
            //            break;
            //    }

            //}

            // delete record

            //  DeleteRecord(userId, lstData);
            //  _unitOfWork.Commit();
            return(true);
        }