Exemple #1
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"));
        }
Exemple #2
0
        private void Sua_Click(object sender, RoutedEventArgs e)
        {
            bool kt;

            try
            {
                float.Parse(dongia.Text);
                kt = true;
            }
            catch (Exception)
            {
                MessageBox.Show("Vui lòng nhập số và không được để trống", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                kt = false;
            }
            if (kt == false)
            {
                dongia.Text = "";
                dongia.Focus();
            }
            else if (mathuoc.Text == null || tenthuoc.Text == null || 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.DVT      = donvi.Text;
                th.CachDung = cachdung.Text;

                thBus = new ThuocBUS();
                bool kq = thBus.sua(th, temp);
                if (kq == false)
                {
                    MessageBox.Show("Sử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("Sửa Thuốc thành công", "Result");
                }
            }
        }
Exemple #3
0
        private void tb_luu_Click(object sender, EventArgs e)
        {
            if (tb_mathuoc.Text == "" || cbb_donvi.Text == "" || tb_dongia.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin.");
            }
            else if (flag == "Thêm")
            {
                if (string.IsNullOrEmpty(tb_mathuoc.Text))
                {
                    return;
                }
                //1. Map data from GUI
                ThuocDTO thDTO = new ThuocDTO();
                thDTO.MaThuoc1  = tb_mathuoc.Text;
                thDTO.TenThuoc1 = tb_tenthuoc.Text;
                thDTO.MaDV1     = cbb_donvi.SelectedValue.ToString();
                thDTO.DonGia1   = int.Parse(tb_dongia.Text);
                thDTO.NSX1      = nsx.Value;
                thDTO.HSD1      = hsd.Value;
                //2. Kiểm tra data hợp lệ or not

                //3. Thêm vào DB
                bool kq = bus.them(thDTO);
                if (kq == false)
                {
                    MessageBox.Show("Thêm thuốc thất bại. Vui lòng kiểm tra lại dũ liệu");
                }
                else
                {
                    MessageBox.Show("Thêm thuốc thành công");

                    dataGridView1.DataSource = bus.loadDuLieuThuoc();//load lại dữ liệu cho datagridview
                    dataGridView1.Enabled    = true;
                    KhoaButton();
                }
            }
            else if (flag == "Sửa")
            {
                if (string.IsNullOrEmpty(tb_mathuoc.Text))
                {
                    return;
                }
                ThuocDTO thDTO = new ThuocDTO();
                thDTO.MaThuoc1  = tb_mathuoc.Text;
                thDTO.TenThuoc1 = tb_tenthuoc.Text;
                thDTO.MaDV1     = cbb_donvi.SelectedValue.ToString();
                thDTO.DonGia1   = int.Parse(tb_dongia.Text);
                thDTO.NSX1      = nsx.Value;
                thDTO.HSD1      = hsd.Value;
                //2. Kiểm tra data hợp lệ or not

                //3. Thêm vào DB
                bool kq = bus.sua(thDTO);
                if (kq == false)
                {
                    MessageBox.Show("Sửa thông tin thuốc thất bại. Vui lòng kiểm tra lại dũ liệu");
                }

                else
                {
                    MessageBox.Show("Sửa thông tin thuốc thành công");
                    dataGridView1.DataSource = bus.loadDuLieuThuoc();//load lại dữ liệu cho datagridview
                    dataGridView1.Enabled    = true;
                    KhoaButton();
                }
            }
        }