private void btSua_Click_1(object sender, EventArgs e) { byte[] img = null; FileStream streem = new FileStream(imageLocation, FileMode.Open, FileAccess.Read); BinaryReader brs = new BinaryReader(streem); img = brs.ReadBytes((int)streem.Length); int masv; string ho, ten, sdt, diachi, gioitinh, email, manganh; masv = int.Parse(txtMaSV.Text.Trim()); ho = txtHo.Text.Trim(); ten = txtTen.Text.Trim(); sdt = txtSDT.Text.Trim(); diachi = txtDiaChi.Text.Trim(); gioitinh = txtGioiTinh.Text.Trim(); email = txtEmail.Text.Trim(); manganh = txtMaNganh.Text.Trim(); SinhVien SV = new SinhVien(masv, ho, ten, sdt, diachi, gioitinh, email, manganh, img); try { int i = new SinhVien1BUS().SuaSV(SV); if (i == -2) { throw new Exception(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } dgvStudent.DataSource = getStudent(); }
public List <SinhVien> getStudent() { try { string sql = "select * from SinhVien"; SinhVien1BUS sv = new SinhVien1BUS(); return(sv.getStudent1(sql)); } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } }
private void btXoa_Click_1(object sender, EventArgs e) { int masv; masv = int.Parse(txtMaSV.Text.Trim()); try { int i = new SinhVien1BUS().XoaSV(masv); if (i == -2) { throw new Exception(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } dgvStudent.DataSource = getStudent(); }
private void loadAStudent(int MSSV) { try { string sql = @"SELECT * FROM SinhVien WHERE MaSV = " + MSSV; SinhVien sv = new SinhVien1BUS().getAStudent(sql); lbhoten.Text = sv.Ho + " " + sv.Ten; lbsdt.Text = sv.SDT; lbdc.Text = sv.DiaChi; lbemail.Text = sv.Email; lbgt.Text = sv.GioiTinh; lbmanganh.Text = sv.MaNganh; } catch (Exception) { MessageBox.Show("Nhap sai ma so sinh vien"); txttim.Clear(); }; }