private void chkListBoxSinhVien_SelectedIndexChanged(object sender, EventArgs e) { idSinhVien = chkListBoxSinhVien.SelectedItem.ToString(); foreach (SinhViens sinhvien in listSinhVien) { if (sinhvien.IDSinhVien.Equals(chkListBoxSinhVien.SelectedItem.ToString())) { txtHoTen.Text = sinhvien.HoTen; ckbGioiTinh.Checked = (sinhvien.GioiTinh == 1); dtpNgaySinh.Value = sinhvien.NgaySinh; khoa = sinhvien.IDKhoa; if (sinhvien.IDKhoa.Equals("1")) { DiemKhoaCNTT tin = SinhVienServices.getDiemTin(idSinhVien); tcHocTap.SelectedTab = tpCNTT; tpCNTT.Enabled = true; tpVan.Enabled = false; tpVan.Visible = false; tpVatLy.Enabled = false; tpVatLy.Visible = false; txtC.Text = tin.DiemC.ToString(); txtJava.Text = tin.DiemJava.ToString(); lblDTB.Text = ((tin.DiemC + tin.DiemJava) / 2).ToString(); } else if (sinhvien.IDKhoa.Equals("2")) { DiemKhoaVatLy ly = SinhVienServices.getDiemLy(idSinhVien); tcHocTap.SelectedTab = tpVatLy; tpVatLy.Enabled = true; tpCNTT.Enabled = false; tpCNTT.Visible = false; tpVan.Enabled = false; tpVan.Visible = false; txtCoHoc.Text = ly.DiemCoHoc.ToString(); txtQuangHoc.Text = ly.DiemQuangHoc.ToString(); lblDTB.Text = ((ly.DiemCoHoc + ly.DiemQuangHoc) / 2).ToString(); } else { DiemKhoaVan van = SinhVienServices.getDiemVan(idSinhVien); tcHocTap.SelectedTab = tpVan; tpVan.Enabled = true; tpCNTT.Enabled = false; tpCNTT.Visible = false; tpVatLy.Enabled = false; tpVatLy.Visible = false; txtVanHocCD.Text = van.DiemVHCD.ToString(); txtVanHocHD.Text = van.DiemVHHD.ToString(); lblDTB.Text = ((van.DiemVHCD + van.DiemVHHD) / 2).ToString(); } } } }
private void btnXoa_ItemClick(object sender, ItemClickEventArgs e) { List<String> ListIdSVXoa = new List<string>(); var rs = MessageBox.Show("Bạn có chắc là muốn xóa sinh viên này không?", "Thông báo" , MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (rs == DialogResult.OK) { for (int i = chkListBoxSinhVien.Items.Count - 1; i >= 0; i--) { if (chkListBoxSinhVien.GetItemChecked(i)) { ListIdSVXoa.Add(chkListBoxSinhVien.Items[i].ToString()); } } foreach (SinhViens sinhvien in listSinhVien) { foreach (String t in ListIdSVXoa) { if (sinhvien.IDSinhVien.Equals(t)) { if (sinhvien.IDKhoa.Equals("1")) { SinhVienServices.XoaDiemSVCNTT(sinhvien.IDSinhVien); } else if (sinhvien.IDKhoa.Equals("2")) { SinhVienServices.XoaDiemSVLy(sinhvien.IDSinhVien); } else { SinhVienServices.XoaDiemSVVan(sinhvien.IDSinhVien); } SinhVienServices.XoaSinhVien(sinhvien.IDSinhVien); } } } HienThiSinhVien(); MessageBox.Show("Bạn đã xóa thành công"); } else { MessageBox.Show("Bạn đã không xóa"); } }
private void HienThiSinhVien() { chkListBoxSinhVien.Items.Clear(); listSinhVien = SinhVienServices.GetListSinhVien(); if (listSinhVien == null) { throw new Exception("Không tồn tại sinh viên"); } else { foreach (SinhViens sinhvien in listSinhVien) { chkListBoxSinhVien.Items.Add(sinhvien); } } }
private void btnThem_Click(object sender, EventArgs e) { int gioitinh = 0; if (chkGioiTinh.Checked) { gioitinh = 1; } if (string.IsNullOrEmpty(txtHoTen.Text) || string.IsNullOrEmpty(txtMaSV.Text) || string.IsNullOrEmpty(txtQuangHoc.Text) || string.IsNullOrEmpty(txtCoHoc.Text)) { SinhVienServices.ThemSinhVien(txtMaSV.Text, txtHoTen.Text, gioitinh, dtpNgaySinh.Value, "2"); SinhVienServices.ThemDiemSVLy(float.Parse(txtCoHoc.Text), float.Parse(txtQuangHoc.Text), txtMaSV.Text); } MessageBox.Show("Đã cập nhật dữ liệu thành công"); DialogResult = DialogResult.OK; }
private void btnCapNhat_ItemClick(object sender, ItemClickEventArgs e) { var rs = MessageBox.Show("Bạn có chắc là muốn cập nhật sinh viên này không?", "Thông báo" , MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (rs == DialogResult.OK) { int gt = 0; if (ckbGioiTinh.Checked) { gt = 1; } SinhVienServices.CapNhatThongTinSV(idSinhVien, txtHoTen.Text, gt, dtpNgaySinh.Value); if (khoa.Equals("1")) { SinhVienServices.CapNhatDiemSVCNTT(float.Parse(txtC.Text), float.Parse(txtJava.Text), idSinhVien); lblDTB.Text = ((float.Parse(txtC.Text) + float.Parse(txtJava.Text)) / 2).ToString(); } else if (khoa.Equals("2")) { SinhVienServices.CapNhatDiemSVLy(float.Parse(txtCoHoc.Text), float.Parse(txtQuangHoc.Text), idSinhVien); lblDTB.Text = ((float.Parse(txtCoHoc.Text) + float.Parse(txtQuangHoc.Text)) / 2).ToString(); } else { SinhVienServices.CapNhatDiemSVVan(float.Parse(txtVanHocCD.Text), float.Parse(txtVanHocHD.Text), idSinhVien); lblDTB.Text = ((float.Parse(txtVanHocCD.Text) + float.Parse(txtVanHocHD.Text)) / 2).ToString(); } HienThiSinhVien(); MessageBox.Show("Bạn đã cập nhật thành công"); } else { MessageBox.Show("Bạn đã không cập nhật"); } }
private void btnThem_Click(object sender, EventArgs e) { int gioitinh = 0; if (chkGioiTinh.Checked) { gioitinh = 1; } if (string.IsNullOrEmpty(txtHoTen.Text) || string.IsNullOrEmpty(txtMaSV.Text) || string.IsNullOrEmpty(txtC.Text) || string.IsNullOrEmpty(txtJava.Text)) { MessageBox.Show("Vui lòng không để trống !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtMaSV.Focus(); return; } else { SinhVienServices.ThemSinhVien(txtMaSV.Text, txtHoTen.Text, gioitinh, dtpNgaySinh.Value, "1"); SinhVienServices.ThemDiemSVCNTT(float.Parse(txtC.Text), float.Parse(txtJava.Text), txtMaSV.Text); } MessageBox.Show("Đã cập nhật dữ liệu thành công"); DialogResult = DialogResult.OK; }