private void btnSave_Click(object sender, EventArgs e) { SinhVienDAO dao = new SinhVienDAO(); SinhVien info = InitSinhVien(); if (isAdd_) { if (dao.Add(info)) { MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); result_ = true; this.Close(); } else { MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (dao.Edit(info)) { MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); result_ = true; this.Close(); } else { MessageBox.Show("Sửa thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void Edit(SinhVien sv) { try { context.Edit(sv); } catch (Exception ex) { Console.WriteLine(ex); } }
private void btnSave_Click(object sender, EventArgs e) { SinhVienDAO dao = new SinhVienDAO(); SinhVien sinhVien = CreateSinhVien(); if (isAdd_) { if (dao.Add(sinhVien)) { MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); result_ = true; } else { MessageBox.Show("Thêm thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (dao.Edit(sinhVien)) { MessageBox.Show("Cập nhật thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); result_ = true; } else { MessageBox.Show("Cập nhật thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (result_) { this.Close(); } }