public static void Them(LoaiLaptop entity)
        {
            String sql = "INSERT INTO LoaiLaptop(MaLoai, TenLoai) VALUES(@MaLoai, @TenLoai)";
            SqlCommand Command = new SqlCommand(sql, DB.Connection);
            Command.Parameters.AddWithValue("@MaLoai", entity.MaLoai);
            Command.Parameters.AddWithValue("@TenLoai", entity.TenLoai);

            Command.Connection.Open();
            Command.ExecuteNonQuery();
            Command.Connection.Close();
        }
        public static void Sua(LoaiLaptop entity)
        {
            String sql = "UPDATE LoaiLaptop SET TenLoai = @TenLoai WHERE MaLoai = @MaLoai";
            SqlCommand Command = new SqlCommand(sql, DB.Connection);
            Command.Parameters.AddWithValue("@MaLoai", entity.MaLoai);
            Command.Parameters.AddWithValue("@TenLoai", entity.TenLoai);

            Command.Connection.Open();
            Command.ExecuteNonQuery();
            Command.Connection.Close();
        }
        public static List<LoaiLaptop> TimTheoSql(String sql)
        {
            SqlCommand command = new SqlCommand(sql, DB.Connection);

            command.Connection.Open();
            SqlDataReader Reader = command.ExecuteReader();
            var DSLoaiLaptop = new List<LoaiLaptop>();
            while (Reader.Read())
            {
                var LoaiLaptop = new LoaiLaptop
                {
                    MaLoai = Convert.ToString(Reader["MaLoai"]),
                    TenLoai = Convert.ToString(Reader["TenLoai"])

                };
                DSLoaiLaptop.Add(LoaiLaptop);
            }
            command.Connection.Close();
            return DSLoaiLaptop;
        }
        public static LoaiLaptop Tim(String MaLoai)
        {
            String sql = "SELECT * FROM LoaiLaptop WHERE MaLoai = @MaLoai";
            SqlCommand Command = new SqlCommand(sql, DB.Connection);

            Command.Parameters.AddWithValue("@MaLoai", MaLoai);

            Command.Connection.Open();
            SqlDataReader Reader = Command.ExecuteReader();
            if (Reader.Read())
            {
                var LoaiLaptop = new LoaiLaptop
                {
                    MaLoai = Convert.ToString(Reader["MaLoai"]),
                    TenLoai = Convert.ToString(Reader["TenLoai"]),

                };
                return LoaiLaptop;
            }
            Command.Connection.Close();
            return null;
        }
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (txtMaLoai.Text == "" || txtTenLoai.Text == "")
            {
                MessageBox.Show("Không được để trống thông tin", "Thông Báo");
                return;
            }
            if (MaLT != txtMaLoai.Text)
            {
                MessageBox.Show("Không được thay đổi mã loại", "Thông Báo");
                return;
            }

                var ML = new LoaiLaptop
                {
                    MaLoai = txtMaLoai.Text,
                    TenLoai = txtTenLoai.Text
                };
                LoaiLaptopDAL.Sua(ML);

                bsLoai.DataSource = LoaiLaptopDAL.LietKe();
                MessageBox.Show("Bạn đã thao tác thành công");
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtMaLoai.Text == "" || txtTenLoai.Text == "" )
            {
                MessageBox.Show("Không được để trống thông tin", "Thông Báo");
                    return;
            }
            if (LoaiLaptopDAL.Tim(txtMaLoai.Text) != null)
            {
                MessageBox.Show("Mã loại không được trùng", "Thông Báo");
                return;
            }

            if(MessageBox.Show("Bạn có muốn thêm sản phẩm không?", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                var ML = new LoaiLaptop
                {
                    MaLoai = txtMaLoai.Text,
                    TenLoai = txtTenLoai.Text
                };
                LoaiLaptopDAL.Them(ML);

                bsLoai.DataSource = LoaiLaptopDAL.LietKe();
                MessageBox.Show("Bạn đã thêm thành công", "Thông Báo");
            }
            else
            {
                MessageBox.Show("Mã LapTop đã tồn tại", "Lỗi");
            }
        }