private static List <information> GetInformation() { var context = new MyDbContext3(); var info = context.informations.ToList(); return(info); }
public static void Add(TextBox text1, TextBox text2, TextBox text3) { using (var context = new MyDbContext3()) { var info = new information() { Name = text1.Text, This = text2.Text, Code = text3.Text }; context.informations.Add(info); context.SaveChanges(); } }
private static void Remove(TextBox box) { int _box = Convert.ToInt32(box.Text); using (MyDbContext3 myDb = new MyDbContext3()) { var item = myDb.informations.Find(_box); if (item != null) { myDb.informations.Remove(item); myDb.SaveChanges(); } } }
private static void Edit(TextBox box, TextBox boxN, TextBox boxT, TextBox boxC) { int _box = Convert.ToInt32(box.Text); using (MyDbContext3 myDb = new MyDbContext3()) { var item = myDb.informations.Find(_box); if (item != null) { item.Name = boxN.Text; item.This = boxT.Text; item.Code = boxC.Text; myDb.SaveChanges(); } } }