private void DoLaiDuLieu() { QLSVDB db = new QLSVDB(); string mssv = data[0].MSSV; data = db.DiemCuaSinhViens.Where(x => x.MSSV == mssv).ToList(); DoDuLieu(); }
private void buttonXoa_Click(object sender, EventArgs e) { DialogResult dr; dr = MessageBox.Show("Bạn có chắc chắn muốn xóa không?", "Thông báo", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { DiemCuaSinhVien diemCanXoa = data[dataGridViewDiemCuaSV.SelectedCells[0].RowIndex]; QLSVDB db = new QLSVDB(); DiemCuaSinhVien diemXoa = db.DiemCuaSinhViens.Where (x => x.MSSV == diemCanXoa.MSSV && x.MaHocPhan == diemCanXoa.MaHocPhan && x.TenHocPhan == diemCanXoa.TenHocPhan && x.HocKy == diemCanXoa.HocKy && x.NienKhoa == diemCanXoa.NienKhoa).SingleOrDefault(); db.DiemCuaSinhViens.Remove(diemXoa); db.SaveChanges(); DoLaiDuLieu(); } }
private void buttonLuu_Click(object sender, EventArgs e) { DiemCuaSinhVien diemMoi = new DiemCuaSinhVien() { MaHocPhan = textBoxMaHocPhan.Text, TenHocPhan = textBoxTenHocPhan.Text, TinChi = int.Parse(textBoxTinChi.Text), LoaiMonHoc = textBoxLoaiMonHoc.Text, HocKy = int.Parse(textBoxHocKy.Text), NienKhoa = textBoxNienKhoa.Text, MSSV = mssv }; if (textBoxDiemQT.Text != "") { diemMoi.DiemQT = float.Parse(textBoxDiemQT.Text); } if (textBoxDiemThi.Text != "") { diemMoi.DiemThi = float.Parse(textBoxDiemThi.Text); } if (textBoxDiemQT.Text != "" && textBoxDiemThi.Text != "") { float diem = (float.Parse(textBoxDiemQT.Text) + float.Parse(textBoxDiemThi.Text)) / 2; string diemChi; if (diem >= 8.5) { diemChi = "A"; } else if (diem >= 7.5) { diemChi = "B"; } else if (diem >= 6) { diemChi = "C"; } else if (diem >= 5) { diemChi = "D"; } else if (diem >= 3) { diemChi = "E"; } else { diemChi = "F"; } bool ketQua = diem >= 5; diemMoi.Diem = diem; diemMoi.DiemChi = diemChi; diemMoi.KetQua = ketQua; } QLSVDB db = new QLSVDB(); db.DiemCuaSinhViens.Add(diemMoi); db.SaveChanges(); this.Close(); }
private void buttonLuu_Click(object sender, EventArgs e) { QLSVDB db = new QLSVDB(); DiemCuaSinhVien diemCu = db.DiemCuaSinhViens.Where (thongTin => thongTin.MaHocPhan == this.diem.MaHocPhan && thongTin.TenHocPhan == this.diem.TenHocPhan && thongTin.HocKy == this.diem.HocKy && thongTin.NienKhoa == this.diem.NienKhoa && thongTin.MSSV == this.diem.MSSV).SingleOrDefault(); if (textBoxTinChi.Text != "") { diemCu.TinChi = int.Parse(textBoxTinChi.Text); } if (textBoxLoaiMonHoc.Text != "") { diemCu.LoaiMonHoc = textBoxLoaiMonHoc.Text; } if (textBoxDiemQT.Text != "") { diemCu.DiemQT = float.Parse(textBoxDiemQT.Text); } if (textBoxDiemThi.Text != "") { diemCu.DiemThi = float.Parse(textBoxDiemThi.Text); } if (textBoxDiemQT.Text != "" && textBoxDiemThi.Text != "") { float diem = (float.Parse(textBoxDiemQT.Text) + float.Parse(textBoxDiemThi.Text)) / 2; string diemChi; if (diem >= 8.5) { diemChi = "A"; } else if (diem >= 7.5) { diemChi = "B"; } else if (diem >= 6) { diemChi = "C"; } else if (diem >= 5) { diemChi = "D"; } else if (diem >= 3) { diemChi = "E"; } else { diemChi = "F"; } bool ketQua = diem >= 5; diemCu.Diem = diem; diemCu.DiemChi = diemChi; diemCu.KetQua = ketQua; } db.SaveChanges(); this.Close(); }