Example #1
0
        private void btnxoa_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem listView in lvKhoa.SelectedItems)
            {
                id = Int32.Parse(listView.SubItems[2].Text);//lay id sv
            }

            QLEntities db = new QLEntities();
            Table_TTSV sv = db.Table_TTSV.Where(p => p.masv == id).SingleOrDefault();

            db.Table_TTSV.Remove(sv);
            db.SaveChanges();
            loadlist();
        }
Example #2
0
        private void btnthem_Click(object sender, EventArgs e)
        {
            foreach (ListViewItem listView in lvshowTT.SelectedItems)
            {
                mk = Int32.Parse(listView.SubItems[0].Text);//lay id sv
            }
            QLEntities db = new QLEntities();
            Table_TTSV sv = new Table_TTSV();

            sv.tensv  = txtTen.Text;
            sv.diachi = txtDiaChi.Text;
            sv.makhoa = mk;
            db.Table_TTSV.Add(sv);
            db.SaveChanges();
            loadkhoa();
            loadlist();
        }