private void btnxoa_Click(object sender, EventArgs e) { LOP inf = new LOP(); inf.lop1 = dgvlop.SelectedRows[0].Cells[0].Value.ToString(); data.xoaLop(inf); MessageBox.Show("Đã xóa!"); dgvlop.DataSource = data.loadLop(); }
public void xoaLop(LOP inf) { var temp = data.LOPs.Find(inf.lop1); if (temp != null) { data.LOPs.Remove(temp); data.SaveChanges(); } }
public void suaLop(LOP bef, LOP aft) { SqlCommand sql = new SqlCommand(); sql.CommandText = "update LOP set lop = @l where lop = @l1"; sql.CommandType = CommandType.Text; sql.Parameters.AddWithValue("@l", aft.lop1); sql.Parameters.AddWithValue("@l1", bef.lop1); sql.Connection = DataProvider.con; sql.ExecuteNonQuery(); }
private void btnthem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtlop.Text)) return; LOP inf = new LOP(); inf.lop1 = txtlop.Text; data.themLop(inf); txtlop.Clear(); MessageBox.Show("Đã thêm!"); dgvlop.DataSource = data.loadLop(); }
public void xoaLop(LOP inf) { data.xoaLop(inf); }
public void themLop(LOP inf) { data.themLop(inf); }
public void suaLop(LOP bef, LOP aft) { data.suaLop(bef, aft); }
public void themLop(LOP inf) { data.LOPs.Add(inf); data.SaveChanges(); }