コード例 #1
0
 private void btnThemmoi_Click(object sender, EventArgs e)
 {
     if (txtMaSV.Text.Trim() == "")
     {
         MessageBox.Show("Chưa nhập mã sinh viên", "Thông báo");
     }
     else
     {
         if (context.tblSINH_VIEN.Find(txtMaSV.Text.Trim()) != null)
         {
             MessageBox.Show("Mã sinh viên đã tồn tại ", "Thông báo");
         }
         else
         {
             SINHVIENF    f = new SINHVIENF();
             tblSINH_VIEN g = new tblSINH_VIEN();
             g.MaSv     = txtMaSV.Text;
             g.HoTen    = txtHoTen.Text;
             g.NgaySinh = dateNgaysinh.Value.ToString();
             g.DiaChi   = txtDiaChi.Text;
             g.GioiTinh = cboGioiTinh.Text;
             g.MaLop    = cboMalop.Text;
             f.Insert(g);
             dgrDSSV.DataSource = context.tblSINH_VIEN.ToList();
             txtMaSV.Clear();
             txtHoTen.Clear();
             txtDiaChi.Clear();
             dateNgaysinh.Text = "";
             cboGioiTinh.Text  = "";
             cboMalop.Text     = "";
         }
     }
 }
コード例 #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            string id = txtMaSV.Text.Trim();

            if (MessageBox.Show(string.Format("Xóa sinh viên có mã '{0}'?", id), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                tblSINH_VIEN g = new tblSINH_VIEN();
                g.MaSv = txtMaSV.Text;

                SINHVIENF f = new SINHVIENF();
                f.Delete(g);
                context            = new HSGVDbContext();
                dgrDSSV.DataSource = context.tblSINH_VIEN.ToList();
            }
        }
コード例 #3
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            string id = txtMaSV.Text.Trim();

            if (MessageBox.Show(string.Format("Sửa sinh viên có mã '{0}'?", id), "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                tblSINH_VIEN g = new tblSINH_VIEN();
                g.MaSv     = txtMaSV.Text;
                g.HoTen    = txtHoTen.Text;
                g.NgaySinh = dateNgaysinh.Text;
                g.DiaChi   = txtDiaChi.Text;
                g.GioiTinh = cboGioiTinh.Text;
                g.MaLop    = cboMalop.Text;
                SINHVIENF f = new SINHVIENF();
                f.Update(g);
                context            = new HSGVDbContext();
                dgrDSSV.DataSource = context.tblSINH_VIEN.ToList();
            }
        }