private void btnXoa_Click(object sender, EventArgs e) { var history = bdsQuaTrinhHocTap.Current as HistoryLearning; if (history != null) { var resultDialog = MessageBox.Show( "Bạn có thực sự muốn xóa?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (resultDialog == DialogResult.OK) { //Viết code xóa dữ liệu ở đây --> Bài tập về nhà ngày 12/10/2019 HistoryLearningService.Remove(Utils.HistoryPathFile, history); bdsQuaTrinhHocTap.RemoveCurrent(); } } }
private void btnDongY_Click(object sender, EventArgs e) { if (history != null) { //Chỉnh sửa history.YearFrom = (int)numTuNam.Value; history.YearEnd = (int)numDenNam.Value; history.SchoolName = txtHocTai.Text; HistoryLearningService.Update(Utils.HistoryPathFile, history); } else { //Thêm mới history = new HistoryLearning(); history.ID = Guid.NewGuid().ToString(); history.YearFrom = (int)numTuNam.Value; history.YearEnd = (int)numDenNam.Value; history.SchoolName = txtHocTai.Text; HistoryLearningService.Add(Utils.HistoryPathFile, history); } }
public frmThongTinSinhVien(string idStudent) { InitializeComponent(); picAnhDaiDien.AllowDrop = true; anhDaiDienPathDirectory = Application.StartupPath + @"\AnhDaiDien"; anhDaiDienPathFile = anhDaiDienPathDirectory + @"\avatar.png"; if (File.Exists(anhDaiDienPathFile)) { FileStream fileStream = new FileStream(anhDaiDienPathFile, FileMode.Open, FileAccess.Read); picAnhDaiDien.Image = Image.FromStream(fileStream); fileStream.Close(); } //var student = StudentService.GetStudent(idStudent); var student = StudentService.GetStudent(Utils.StudentPathFile, idStudent); if (student == null) { throw new Exception("Lỗi rồi. Sinh viên này không tồn tại"); } else { student.ListHistoryLearning = //HistoryLearningService.GetListHistoryLearning(idStudent); HistoryLearningService.GetListHistoryLearning(Utils.HistoryPathFile, idStudent); txtMaSinhVien.Text = student.ID; txtHoTen.Text = student.FullName; dtpNgaySinh.Value = student.DateOfBirth; txtNoiSinh.Text = student.PlaceOfBirth; chkGioiTinh.Checked = student.Gender == Model.GENDER.Male; dtgQuaTrinhHocTap.AutoGenerateColumns = false; bdsQuaTrinhHocTap.DataSource = student.ListHistoryLearning; dtgQuaTrinhHocTap.DataSource = bdsQuaTrinhHocTap; lblTongSoMuc.Text = string.Format("{0} mục", student.ListHistoryLearning.Count()); } }