예제 #1
0
        private static List <information> GetInformation()
        {
            var context = new MyDbContext3();

            var info = context.informations.ToList();

            return(info);
        }
예제 #2
0
 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();
     }
 }
예제 #3
0
        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();
                }
            }
        }
예제 #4
0
        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();
                }
            }
        }