Пример #1
0
        void edit()
        {
            int     id = Int32.Parse(datagridview2.SelectedCells[0].OwningRow.Cells["id"].Value.ToString());
            hocsinh hs = db.hocsinhs.Find(id);

            hs.lop      = cblophs.Text;
            hs.ngaysinh = dateTimePicker1.Value;
            db.SaveChanges();
        }
Пример #2
0
 void delete()
 {
     try {
         int     idhs = Int32.Parse(txtid.Text);
         hocsinh hs   = db.hocsinhs.Where(p => p.id == idhs).SingleOrDefault();
         db.hocsinhs.Remove(hs);
         db.SaveChanges();
     } catch { }
 }
Пример #3
0
        void addhs()
        {
            DateTime date       = dateTimePicker1.Value;
            string   lophoc     = cblophs.Text;
            string   tenhocsinh = txthocsinh.Text;

            hocsinh hs = new hocsinh()
            {
                tenhs = tenhocsinh, lop = lophoc, ngaysinh = date
            };

            db.hocsinhs.Add(hs);
            db.SaveChanges();
        }