public void Insert(TheLoai info) { string sqlQuery = "insert into TheLoai values ('" + info.MaTheLoai + "',N'" + info.TenTheLoai + "',N'" + info.GhiChu + "')"; ExecuteNonQuery(sqlQuery); }
public void Update(TheLoai info) { string sqlQuery = "update TheLoai" + " set TenTheLoai=N'" + info.TenTheLoai + "'," + "GhiChu=N'" + info.GhiChu + "' " + "where MaTheLoai='" + info.MaTheLoai + "'"; ExecuteNonQuery(sqlQuery); }
private void btSua_Click(object sender, RoutedEventArgs e) { TheLoai theLoai = new TheLoai() { MaTheLoai = tbMaTheLoai.Text, TenTheLoai = tbTenTheLoai.Text, GhiChu = tbGhiChu.Text }; TheLoaiBUS bus = new TheLoaiBUS(); try { bus.Update(theLoai); MessageBox.Show("Sửa thành công !"); } catch (Exception) { MessageBox.Show("Sửa thất bại !"); } LoadData(); }
private void btThem_Click(object sender, RoutedEventArgs e) { TheLoai theLoai = new TheLoai() { MaTheLoai = (++id).ToString(), TenTheLoai = tbTenTheLoai.Text, GhiChu = tbGhiChu.Text }; TheLoaiBUS bus = new TheLoaiBUS(); try { bus.Insert(theLoai); MessageBox.Show("Thêm thành công !"); } catch (Exception) { MessageBox.Show("Thêm thất bại !"); } LoadData(); }
public List<TheLoai> GetList() { List<TheLoai> list = new List<TheLoai>(); string sqlQuery = "select * from TheLoai"; reader = ExecuteReader(sqlQuery); while (reader.Read()) { TheLoai tacGia = new TheLoai(); tacGia.MaTheLoai = reader["MaTheLoai"].ToString(); tacGia.TenTheLoai = reader["TenTheLoai"].ToString(); tacGia.GhiChu = reader["GhiChu"].ToString(); list.Add(tacGia); } return list; }
public void Update(TheLoai info) { data.Update(info); }
public void Insert(TheLoai info) { data.Insert(info); }