Пример #1
0
        public static List <ThuocDTO> SelectAllThuoc()
        {
            List <ThuocDTO> listThuoc = null;


            string sql = "Select * from Thuoc";

            DataTable dt = DataProvider.ExecQuery(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                listThuoc = new List <ThuocDTO>();

                foreach (DataRow row in dt.Rows)
                {
                    ThuocDTO Thuoc = new ThuocDTO();
                    Thuoc.MaThuoc  = row.ItemArray[0].ToString();
                    Thuoc.TenThuoc = row.ItemArray[1].ToString();
                    Thuoc.DonVi    = row.ItemArray[2].ToString();
                    Thuoc.CachDung = row.ItemArray[3].ToString();
                    Thuoc.SoLuong  = int.Parse(row.ItemArray[4].ToString());
                    Thuoc.GiaThuoc = int.Parse(row.ItemArray[5].ToString());
                    Thuoc.MoTa     = row.ItemArray[6].ToString();

                    listThuoc.Add(Thuoc);
                }
            }

            return(listThuoc);
        }
Пример #2
0
        private void btnThayDoi_Click(object sender, EventArgs e)
        {
            ThuocDTO Thuoc = new ThuocDTO();

            Thuoc.MaThuoc  = cbbMaThuoc1.Text;
            Thuoc.GiaThuoc = int.Parse(txtGiaThuoc1.Text);
            DbAck ack = ThuocBUS.Update(Thuoc);

            if (ack == DbAck.Ok)
            {
                MessageBox.Show("Thay đổi thành công", "Thông báo");
                LoadListThuoc();
                GetMaThuoc();
                txtGiaThuoc1.Text = null;
            }
            else
            {
                if (ack == DbAck.Unknown)
                {
                    MessageBox.Show("Lỗi không xác định", "Thông báo");
                }
                else
                {
                }
            }
        }
Пример #3
0
        public static DbAck Delete(ThuocDTO Thuoc)
        {
            DbAck result = DbAck.Unknown;

            result = ThuocDAO.Delete(Thuoc);

            return(result);
        }
Пример #4
0
        public void themdonvi_thuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus = new ThuocBUS();
            bool kq = thuocbus.themcd("Vỉ");

            Assert.AreEqual(true, kq);
        }
Пример #5
0
        public void suacachdung_thuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus = new ThuocBUS();
            bool kq = thuocbus.thaydoiCD("Ăn", "Uống");

            Assert.AreEqual(true, kq);
        }
Пример #6
0
        public static DbAck Insert(ThuocDTO Thuoc)
        {
            DbAck result = DbAck.Unknown;

            result = ThuocDAO.Insert(Thuoc);


            return(result);
        }
Пример #7
0
        public void xoacachdung_thuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus = new ThuocBUS();
            bool kq = thuocbus.xoaCD("Ăn");

            Assert.AreEqual(true, kq);
        }
Пример #8
0
        public void suadonvi_thuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus = new ThuocBUS();
            bool kq = thuocbus.thaydoiDV("Bình", "");

            Assert.AreEqual(true, kq);
        }
Пример #9
0
        public void xoadonvi_thuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus = new ThuocBUS();
            bool kq = thuocbus.xoaCD("Vỉ");

            Assert.AreEqual(true, kq);
        }
Пример #10
0
        public void XoaThuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus      = new ThuocBUS();
            thuoc.MaThuoc = "32";
            bool kq = thuocbus.xoa(thuoc);

            Assert.AreEqual(true, kq);
        }
Пример #11
0
        public static DbAck Delete(ThuocDTO Thuoc)
        {
            string sql = "delete from Thuoc where ma_thuoc = @Ma";
            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("@Ma", Thuoc.MaThuoc);

            DbAck result = DataProvider.ExecNonQuery(sql, parameter);

            return(DbAck.Ok);
        }
Пример #12
0
        public void SuaThuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus       = new ThuocBUS();
            thuoc.MaThuoc  = "32";
            thuoc.TenThuoc = "Teroxin";
            thuoc.DonGia   = 40000;
            thuoc.CachDung = "Uống";
            thuoc.DVT      = "Viên";
            Assert.AreEqual(true, thuocbus.sua(thuoc, "32"));
        }
Пример #13
0
        public static DbAck Update(ThuocDTO Thuoc)
        {
            string sql = "update Thuoc set gia_thuoc = @Gia where ma_thuoc= @Ma";

            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("@Ma", Thuoc.MaThuoc);
            parameter.Add("@Gia", Thuoc.GiaThuoc);


            DbAck result = DataProvider.ExecNonQuery(sql, parameter);

            return(result);
        }
Пример #14
0
 public static bool XoaThuoc(ThuocDTO th)
 {
     try
     {
         string sql = @"DELETE from Thuoc WHERE MaThuoc='" + th.MaThuoc + "' ";
         ConnectionData.ExeNonQuery(sql);
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Пример #15
0
        public void ThemThuoc()
        {
            ThuocDTO thuoc = new ThuocDTO();

            thuocbus       = new ThuocBUS();
            thuoc.MaThuoc  = thuocbus.autogenerate_mathuoc().ToString();
            thuoc.TenThuoc = "Teroxin";
            thuoc.DonGia   = 50000;
            thuoc.CachDung = "Uống";
            thuoc.DVT      = "Viên";
            bool kq = thuocbus.them(thuoc);

            Assert.AreEqual(true, kq);
        }
 public async Task <BaseResponse> Update(ThuocDTO thuocDTO)
 {
     try
     {
         var result = _thuocService.Update(thuocDTO);
         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));
     }
 }
Пример #17
0
 public static bool ThemThuoc(ThuocDTO th)
 {
     try
     {
         string sql = @"INSERT INTO Thuoc (MaThuoc,TenThuoc,MaNhom,MaNSX,DVBan,DonGia,QuyCach) 
                      Values('" + th.MaThuoc + "', N'" + th.TenThuoc + "', '" + th.MaNhom + "', " +
                      "'" + th.MaNSX + "', '" + th.DVBan + "', '" + th.DonGia + "', N'" + th.QuyCach + "')";
         ConnectionData.ExeNonQuery(sql);
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Пример #18
0
 public static bool SuaThuoc(ThuocDTO th)
 {
     try
     {
         string sql = @"UPDATE Thuoc SET TenThuoc= N'" + th.TenThuoc + "', MaNhom= '" + th.MaNhom + "', " +
                      "MaNSX= '" + th.MaNSX + "', DVBan= '" + th.DVBan + "', DonGia= '" + th.DonGia + "', " +
                      "QuyCach= N'" + th.QuyCach + "' WHERE MaThuoc= '" + th.MaThuoc + "'";
         ConnectionData.ExeNonQuery(sql);
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
 public async Task <BaseResponse> Create(ThuocDTO thuocDto)
 {
     try
     {
         var result = _thuocService.Create(thuocDto);
         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)));
     }
 }
Пример #20
0
        private void grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid    gd           = (DataGrid)sender;
            DataRowView row_selected = gd.SelectedItem as DataRowView;

            th = new ThuocDTO();
            if (row_selected != null)
            {
                th.TenThuoc = row_selected["tenThuoc"].ToString();
                th.MaThuoc  = row_selected["maThuoc"].ToString();
                th.DVT      = row_selected["DVT"].ToString();
                th.DonGia   = float.Parse(row_selected["Dongia"].ToString());
                th.CachDung = row_selected["CachDung"].ToString();
                temp        = th.MaThuoc.ToString();
            }
        }
Пример #21
0
        public Int64 Insert(ThuocDTO _nv)
        {
            string[] str = new string[2];
            object[] val = new object[2];

            str[0] = "@tenThuoc";
            str[1] = "@gia";

            val[0] = _nv.tenThuoc;
            val[1] = _nv.gia;


            DataProvider dp = new DataProvider();

            return(dp.WriteDataAddParam("SP_InsertThuoc", str, val, 50));
        }
Пример #22
0
        public Int64 Update(ThuocDTO _nv)
        {
            string[] str = new string[3];
            object[] val = new object[3];

            str[0] = "@tenThuoc";
            str[1] = "@gia";
            str[2] = "@id";

            val[0] = _nv.tenThuoc;
            val[1] = _nv.gia;
            val[2] = _nv.id;

            DataProvider dp = new DataProvider();

            return(dp.WriteDataAddParam("SP_UpdateThuoc", str, val, 50));
        }
Пример #23
0
        private void MenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            th         = new ThuocDTO();
            th.MaThuoc = temp;
            thBus      = new ThuocBUS();
            bool kq = thBus.xoa(th);

            if (kq == false)
            {
                MessageBox.Show("Xóa Thuốc 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 Thuốc thành công", "Result");
            }
            load_data();
        }
Пример #24
0
        private void Them_Click(object sender, RoutedEventArgs e)
        {
            bool kt;

            try
            {
                float.Parse(dongia.Text);
                kt = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Vui lòng nhập số trên trường đơn giá và không được để trống", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                kt = false;
            }
            if (kt == false)
            {
                dongia.Text = "";
                dongia.Focus();
            }
            else if (mathuoc.Text == "" || tenthuoc.Text == "" || cachdung.Text == "" || donvi.Text == "")
            {
                MessageBox.Show("Vui lòng nhập đầy đủ thông tin loại thuốc");
            }
            else
            {
                ThuocDTO th = new ThuocDTO();
                th.MaThuoc  = mathuoc.Text;
                th.TenThuoc = tenthuoc.Text;
                th.DonGia   = float.Parse(dongia.Text);
                th.CachDung = cachdung.Text;
                th.DVT      = donvi.Text;

                thBus = new ThuocBUS();
                bool kq = thBus.them(th);
                if (kq == false)
                {
                    MessageBox.Show("Thêm Thuốc thất bại. Vui lòng kiểm tra lại dũ liệu", "Result", MessageBoxButton.OKCancel, MessageBoxImage.Warning);
                }
                else
                {
                    MessageBox.Show("Thêm Thuốc thành công", "Result");
                }
            }
        }
Пример #25
0
        public static DbAck Insert(ThuocDTO Thuoc)
        {
            string sql = "insert into Thuoc(ma_thuoc,ten_thuoc,don_vi,cach_dung,so_luong,gia_thuoc,mo_ta) values(@Ma,@Ten,@DonVi,@CachDung,@Sl,@Gia,@Mota)";

            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("@Ma", Thuoc.MaThuoc);
            parameter.Add("@Ten", Thuoc.TenThuoc);
            parameter.Add("@DonVi", Thuoc.DonVi);
            parameter.Add("@CachDung", Thuoc.CachDung);
            parameter.Add("@SL", Thuoc.SoLuong);
            parameter.Add("@Gia", Thuoc.GiaThuoc);
            parameter.Add("@Mota", Thuoc.MoTa);


            DbAck result = DataProvider.ExecNonQuery(sql, parameter);

            return(result);
        }
Пример #26
0
        public bool Create(ThuocDTO thuocDto)
        {
            try
            {
                var item = CheckExistsTenThuoc(thuocDto.TenThuoc);
                if (item)
                {
                    return(false);
                }
                var thuoc = new Thuoc
                {
                    MaThuoc  = Guid.NewGuid(),
                    TenThuoc = thuocDto.TenThuoc,
                    CongDung = thuocDto.CongDung,
                    CachDung = thuocDto.CachDung,
                    HinhAnh  = thuocDto.HinhAnh,
                    LuuY     = thuocDto.LuuY,
                    LieuDung = thuocDto.LieuDung
                };
                _thuocRepository.Insert(thuoc);
                _unitOfWork.Commit();

                if (thuocDto.MaBenhs != null)
                {
                    foreach (var mabenh in thuocDto.MaBenhs)
                    {
                        var thuocdieutri = new ThuocDieuTri
                        {
                            MaThuoc = thuoc.MaThuoc,
                            MaBenh  = new Guid(mabenh)
                        };
                        _thuocdieutriRepository.Insert(thuocdieutri);
                    }
                    _unitOfWork.Commit();
                }
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Пример #27
0
        private void tb_xoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn muốn xóa thông tin thuốc?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                ThuocDTO thDTO = new ThuocDTO();
                thDTO.MaThuoc1 = tb_mathuoc.Text;

                bool kq = bus.xoa(thDTO);
                if (kq == false)
                {
                    MessageBox.Show("Xóa thông tin thuốc thất bại.");
                }

                else
                {
                    MessageBox.Show("Xóa thông tin thuốc thành công");
                    dataGridView1.DataSource = bus.loadDuLieuThuoc();//load lại dữ liệu cho datagridview
                }
                KhoaButton();
            }
        }
Пример #28
0
        public bool Update(ThuocDTO thuocDto)
        {
            try
            {
                var thuoc = _thuocRepository.GetById(thuocDto.MaThuoc);
                if (thuoc == null)
                {
                    return(false);
                }
                // Update chi tiet
                thuoc.MaThuoc  = thuocDto.MaThuoc;
                thuoc.TenThuoc = thuocDto.TenThuoc.ToLower();
                thuoc.CongDung = thuocDto.CongDung;
                thuoc.CachDung = thuocDto.CachDung;
                thuoc.HinhAnh  = thuocDto.HinhAnh;
                thuoc.LuuY     = thuocDto.LuuY;
                thuoc.LieuDung = thuocDto.LieuDung;
                //update thuốc điều trị
                var thuocdieutriOld = _thuocdieutriRepository.GetMany(p => p.MaThuoc == thuoc.MaThuoc).ToList();
                _thuocdieutriRepository.RemoveMultiple(thuocdieutriOld);

                var benhs = _benhRepository.GetMany(r => thuocDto.MaBenhs.Contains(r.MaBenh.ToString()));
                foreach (var benh in benhs)
                {
                    var thuocdieutri = new ThuocDieuTri {
                        MaBenh = benh.MaBenh, MaThuoc = thuoc.MaThuoc
                    };

                    _thuocdieutriRepository.Insert(thuocdieutri);
                }
                // update user
                _thuocRepository.Update(thuoc);
                _unitOfWork.Commit();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Пример #29
0
        //thêm
        private void btnThem_Click(object sender, EventArgs e)
        {
            ThuocDTO Thuoc = new ThuocDTO();

            Thuoc.MaThuoc  = txtMaThuoc.Text;
            Thuoc.TenThuoc = txtTenThuoc.Text;
            Thuoc.DonVi    = cbbDonVi.Text;
            Thuoc.CachDung = cbbCachDung.Text;
            Thuoc.SoLuong  = int.Parse(txtSoLuong.Text);
            Thuoc.GiaThuoc = int.Parse(txtGiaThuoc.Text);
            Thuoc.MoTa     = txtMoTa.Text;


            DbAck ack = ThuocBUS.Insert(Thuoc);

            if (ack == DbAck.Ok)
            {
                MessageBox.Show("Thêm thành công", "Thông báo");
                LoadListThuoc();
                GetMaThuoc();
                txtMaThuoc.Text  = null;
                txtTenThuoc.Text = null;
                cbbDonVi.Text    = null;
                cbbCachDung.Text = null;
                txtSoLuong.Text  = null;
                txtGiaThuoc.Text = null;
            }
            else
            {
                if (ack == DbAck.Unknown)
                {
                    MessageBox.Show("Lỗi không xác định", "thông báo");
                }
                else
                {
                }
            }
        }
Пример #30
0
        public string GetListThuoc(QLPHONGKHAMEntities db, out List <ThuocDTO> ListThuocEntity)
        {
            ListThuocEntity = new List <ThuocDTO>();
            List <THUOC> listObjectDAO = null;

            if (donThuocService.Select(db, out listObjectDAO) == Constant.RES_FAI)
            {
                return(Constant.RES_FAI);
            }
            if (listObjectDAO == null)
            {
                return(Constant.RES_FAI);
            }
            foreach (var thuoc in listObjectDAO)
            {
                // tạo đối tượng entity
                ThuocDTO thuocEntity = new ThuocDTO();
                // copy property
                BUS.Com.Utils.CopyPropertiesFrom(thuoc, thuocEntity);
                // add vào list ouput
                ListThuocEntity.Add(thuocEntity);
            }
            return(Constant.RES_SUC);
        }