コード例 #1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         int id     = (int)dataGridView1.SelectedRows[0].Cells[0].Value;
         var result = db.SinhViens.Find(id);
         db.SinhViens.Remove(result);
         db.SaveChanges();
         load();
     }
 }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var result = db.SinhViens.Find(ID);

            result.Hoten           = txtName.Text;
            result.MSSV            = txtMSSV.Text;
            result.Khoa            = cbbKhoa.Text;
            db.Entry(result).State = EntityState.Modified;
            db.SaveChanges();
            this.Close();
        }
コード例 #3
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count == 1)
     {
         string id = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
         var    rs = db.MuonSaches.Find(id);
         db.MuonSaches.Remove(rs);
         db.SaveChanges();
         loadsach();
     }
 }
コード例 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var result = db.MuonSaches.Find(ID);

            result.TenSach         = txtTen.Text;
            result.SoLuong         = int.Parse(txtSL.Text);
            result.LoaiSach        = cbbLoai.Text;
            result.TacGia          = txtTG.Text;
            db.Entry(result).State = EntityState.Modified;
            db.SaveChanges();
            this.Close();
        }
コード例 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var rs = new SinhVien
            {
                Hoten = txtName.Text,
                MSSV  = txtMSSV.Text,
                Khoa  = cbbKhoa.Text,
            };

            db.SinhViens.Add(rs);
            db.SaveChanges();
            this.Close();
        }
コード例 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var rs = new MuonSach
            {
                MaSach   = txtMa.Text,
                TenSach  = txtTen.Text,
                SoLuong  = int.Parse(txtSL.Text),
                LoaiSach = cbbLoai.Text,
                TacGia   = txtTG.Text
            };

            db.MuonSaches.Add(rs);
            db.SaveChanges();
            this.Close();
        }