Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        private void loadlist()
        {
            using (QLEntities db = new QLEntities())
            {
                var result = from s in db.Khoa select s;
                lvshowTT.Items.Clear();
                foreach (var data in result)                                    // doc nd trong result
                {
                    ListViewItem listView = new ListViewItem(data.makhoa + ""); // lay thong tin theo lua chon vd(tensv)
                    listView.SubItems.Add(data.tenkhoa);                        //add dchi cho tung Sv

                    lvshowTT.Items.Add(listView);                               //show TT ra;
                }
            }
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
 void loadkhoa()
 {
     using (QLEntities db = new QLEntities())
     {
         var result = from s in db.Table_TTSV
                      where s.makhoa == idkhoa
                      select s;
         lvKhoa.Items.Clear();
         foreach (var data in result)
         {
             ListViewItem listView = new ListViewItem(data.tensv);
             listView.SubItems.Add(data.diachi);
             listView.SubItems.Add(data.masv + "");
             lvKhoa.Items.Add(listView);
         }
     }
 }