private void btnSua_Click(object sender, EventArgs e) { try { DTO_TheLoai tl = new DTO_TheLoai(int.Parse(txtMatl.Text), txtTentl.Text); bUS_TheLoai.UpdateTheLoai(tl); MessageBox.Show("Sửa thành công"); LoadData(); } catch (Exception) { MessageBox.Show("sửa thất bại"); } }
private void btnLuu_Click(object sender, EventArgs e) { try { DTO_TheLoai tl = new DTO_TheLoai(txtTentl.Text); bUS_TheLoai.InsertTheLoai(tl); MessageBox.Show("Thêm thành công"); LoadData(); } catch (Exception) { MessageBox.Show("Thêm thất bại"); } }
public bool DeleteTheLoai(DTO_TheLoai a) { try { TheLoai delete = db.TheLoais.Where(p => p.MaLoai.ToString().Equals(a.MaLoai)).SingleOrDefault(); db.TheLoais.DeleteOnSubmit(delete); db.SubmitChanges(); return(true); } catch { return(false); } }
public bool UpdateTheLoai(DTO_TheLoai a) { try { TheLoai update = db.TheLoais.Where(p => p.MaLoai.ToString().Equals(a.MaLoai)).SingleOrDefault(); update.Tenloai = a.TenLoai; db.SubmitChanges(); return(true); } catch { return(false); } }
public bool InsertNTheLoai(DTO_TheLoai a) { try { TheLoai insert = new TheLoai(); insert.Tenloai = a.TenLoai; db.TheLoais.InsertOnSubmit(insert); db.SubmitChanges(); return(true); } catch { return(false); } }
private void btnXoa_Click(object sender, EventArgs e) { try { DialogResult r = MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (r == DialogResult.Yes) { DTO_TheLoai tl = new DTO_TheLoai(int.Parse(txtMatl.Text)); bUS_TheLoai.DeleteTheLoai(tl); MessageBox.Show("Xóa thành công."); LoadData(); } } catch (Exception) { MessageBox.Show("Xóa thất bại"); } }
public bool DeleteTheLoai(DTO_TheLoai a) { return(dalTL.DeleteTheLoai(a)); }
public bool UpdateTheLoai(DTO_TheLoai a) { return(dalTL.UpdateTheLoai(a)); }
public bool InsertTheLoai(DTO_TheLoai a) { return(dalTL.InsertNTheLoai(a)); }