private void btnxoa_Click(object sender, EventArgs e) { NGONNGU inf = new NGONNGU(); inf.ngonngu1 = dgvngonngu.SelectedRows[0].Cells[0].Value.ToString(); data.xoaNgonNgu(inf); dgvngonngu.DataSource = data.loadNgonNgu(); MessageBox.Show("Đã xóa!"); }
public void xoaNgonNgu(NGONNGU inf) { var temp = data.NGONNGUs.Find(inf.ngonngu1); if (temp != null) { data.NGONNGUs.Remove(temp); data.SaveChanges(); } }
public void suaNgonNgu(NGONNGU bef, NGONNGU aft) { SqlCommand sql = new SqlCommand(); sql.CommandText = "update NGONNGU set ngonngu = @nn where ngonngu = @nn1"; sql.CommandType = CommandType.Text; sql.Parameters.AddWithValue("@nn", aft.ngonngu1); sql.Parameters.AddWithValue("@nn1", bef.ngonngu1); sql.Connection = DataProvider.con; sql.ExecuteNonQuery(); }
private void btnthem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtngonngu.Text)) return; NGONNGU inf = new NGONNGU(); inf.ngonngu1 = txtngonngu.Text; data.themNgonNgu(inf); txtngonngu.Clear(); MessageBox.Show("Đã thêm!"); dgvngonngu.DataSource = data.loadNgonNgu(); }
public void themNgonNgu(NGONNGU inf) { data.NGONNGUs.Add(inf); data.SaveChanges(); }
public void xoaNgonNgu(NGONNGU inf) { data.xoaNgonNgu(inf); }
public void themNgonNgu(NGONNGU inf) { data.themNgonNgu(inf); }
public void suaNgonNgu(NGONNGU bef, NGONNGU aft) { data.suaNgonNgu(bef, aft); }