Exemplo n.º 1
0
        //thêm loại bệnh
        private void button1_Click(object sender, EventArgs e)
        {
            LoaiBenhDTO loaiBenh = new LoaiBenhDTO();

            loaiBenh.Ma  = txtMaLoaiBenh.Text;
            loaiBenh.Ten = txtTenLoaiBenh.Text;


            DbAck ack = LoaiBenhBUS.Insert(loaiBenh);

            if (ack == DbAck.Ok)
            {
                MessageBox.Show("Thêm thành công", "Thông báo");
            }
            else
            {
                if (ack == DbAck.Unknown)
                {
                    MessageBox.Show("Lỗi không xác định", "Thông báo");
                }
                else
                {
                }
            }
            loadListLoaiBenh();
            txtMaLoaiBenh.Text  = null;
            txtTenLoaiBenh.Text = null;
        }
Exemplo n.º 2
0
        public static List <LoaiBenhDTO> SelectAllLoaiBenh()
        {
            List <LoaiBenhDTO> listLoaiBenh = null;


            string sql = "Select * from LoaiBenh";

            DataTable dt = DataProvider.ExecQuery(sql);

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

                foreach (DataRow row in dt.Rows)
                {
                    LoaiBenhDTO loaibenh = new LoaiBenhDTO();
                    loaibenh.Ma  = row.ItemArray[0].ToString();
                    loaibenh.Ten = row.ItemArray[1].ToString();

                    listLoaiBenh.Add(loaibenh);
                }
            }

            return(listLoaiBenh);
        }
Exemplo n.º 3
0
        public static DbAck Delete(LoaiBenhDTO LoaiBenh)
        {
            DbAck result = DbAck.Unknown;

            result = LoaiBenhDAO.Delete(LoaiBenh);

            return(result);
        }
Exemplo n.º 4
0
        public static DbAck Update(LoaiBenhDTO LoaiBenh)
        {
            // Xu ly kiem tra va tinh toan
            DbAck result = DbAck.Unknown;

            result = LoaiBenhDAO.Update(LoaiBenh);


            return(result);
        }
Exemplo n.º 5
0
        public static DbAck Delete(LoaiBenhDTO LoaiBenh)
        {
            string sql = "delete from LoaiBenh where ma_loai_benh = @Ma";
            Dictionary <string, object> parameter = new Dictionary <string, object>();

            parameter.Add("@Ma", LoaiBenh.Ma);

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

            return(DbAck.Unknown);
        }
Exemplo n.º 6
0
        public Int64 Insert(LoaiBenhDTO _nv)
        {
            string[] str = new string[1];
            object[] val = new object[1];

            str[0] = "@ten";
            val[0] = _nv.ten;

            DataProvider dp = new DataProvider();

            return(dp.WriteDataAddParam("SP_InsertLoaiBenh", str, val, 50));
        }
Exemplo n.º 7
0
        public static DbAck Update(LoaiBenhDTO LoaiBenh)
        {
            string sql = "update LoaiBenh set ten_loai_benh = @Ten where ma_loai_benh= @Ma";

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

            parameter.Add("@Ma", LoaiBenh.Ma);
            parameter.Add("@Ten", LoaiBenh.Ten);


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

            return(result);
        }
        private void btnLuu_Click_1(object sender, EventArgs e)
        {
            if (flag == "Thêm")
            {
                //1. Map data from GUI
                LoaiBenhDTO lbDTO = new LoaiBenhDTO();
                lbDTO.MaLB        = txtMaLoaiBenh.Text;
                lbDTO.TenLoaiBenh = txtTenLoaiBenh.Text;
                lbDTO.TrieuChung  = txtTrieuChung.Text;
                //2. Kiểm tra data hợp lệ or not

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

                    dataGridViewBenh.DataSource = lbBUS.loadDuLieuLoaiBenh();//load lại dữ liệu cho datagridview
                    dataGridViewBenh.Enabled    = true;
                }
            }
            if (flag == "Sửa")
            {
                //1. Map data from GUI
                LoaiBenhDTO lbDTO = new LoaiBenhDTO();
                lbDTO.MaLB        = txtMaLoaiBenh.Text;
                lbDTO.TenLoaiBenh = txtTenLoaiBenh.Text;
                lbDTO.TrieuChung  = txtTrieuChung.Text;
                //2. Kiểm tra data hợp lệ or not

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

                    dataGridViewBenh.DataSource = lbBUS.loadDuLieuLoaiBenh();//load lại dữ liệu cho datagridview
                    dataGridViewBenh.Enabled    = true;
                }
            }
            KhoaButton();
        }
Exemplo n.º 9
0
        public static DbAck Insert(LoaiBenhDTO LoaiBenh)
        {
            string sql = "insert into LoaiBenh(ma_loai_benh,ten_loai_benh) values(@Ma,@Ten)";

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

            parameter.Add("@Ma", LoaiBenh.Ma);
            parameter.Add("@Ten", LoaiBenh.Ten);


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

            return(result);
        }
Exemplo n.º 10
0
        public Int64 Update(LoaiBenhDTO _nv)
        {
            string[] str = new string[2];
            object[] val = new object[2];

            str[0] = "@ten";
            val[0] = _nv.ten;

            str[1] = "@id";
            val[1] = _nv.id;

            DataProvider dp = new DataProvider();

            return(dp.WriteDataAddParam("SP_UpdateLoaiBenh", str, val, 50));
        }
Exemplo n.º 11
0
        //xoá
        private void button3_Click(object sender, EventArgs e)
        {
            LoaiBenhDTO loaiBenh = new LoaiBenhDTO();

            loaiBenh.Ma = txtMaLoaiBenh.Text;
            DbAck ack = LoaiBenhBUS.Delete(loaiBenh);

            if (ack == DbAck.Ok)
            {
                MessageBox.Show("Lỗi không xác định", "Thông báo");
            }
            else
            {
                if (ack == DbAck.Unknown)
                {
                    MessageBox.Show("Xoá thành công", "Thông báo");
                }
                else
                {
                }
            }
            loadListLoaiBenh();
        }
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn muốn xóa thông tin loại bệnh?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
            {
                LoaiBenhDTO lbDTO = new LoaiBenhDTO();
                lbDTO.MaLB        = txtMaLoaiBenh.Text;
                lbDTO.TenLoaiBenh = txtTenLoaiBenh.Text;
                lbDTO.TrieuChung  = txtTrieuChung.Text;

                bool kq = lbBUS.xoa(lbDTO);
                if (kq == false)
                {
                    MessageBox.Show("Xóa loại bệnh thất bại.");
                }

                else
                {
                    MessageBox.Show("Xóa loại bệnh thành công");
                    dataGridViewBenh.DataSource = lbBUS.loadDuLieuLoaiBenh();//load lại dữ liệu cho datagridview
                }
                KhoaButton();
            }
        }
        public bool sua(LoaiBenhDTO lb)
        {
            bool re = bdal.sua(lb);

            return(re);
        }
        public bool them(LoaiBenhDTO lb)
        {
            bool re = bdal.them(lb);

            return(re);
        }
Exemplo n.º 15
0
 public Int64 Delete(LoaiBenhDTO _nv)
 {
     return(nvDAO.Delete(_nv.id));
 }
Exemplo n.º 16
0
 public Int64 Update(LoaiBenhDTO _nv)
 {
     return(nvDAO.Update(_nv));
 }
Exemplo n.º 17
0
 public Int64 Insert(LoaiBenhDTO _nv)
 {
     return(nvDAO.Insert(_nv));
 }
Exemplo n.º 18
0
 private void SetDataIndex(int _id)
 {
     itemIndex = new LoaiBenhDTO(_id, txtTen.Text.Trim());
 }