Ejemplo n.º 1
0
        // Hàm này sẽ lưu lại những thông tin được sửa, thêm vào
        private void btnSave_Click(object sender, EventArgs e)
        {
            GiangVienDAO dao = new GiangVienDAO();
            // tạo biến tham chiếu
            GiangVien info = InitGiangVien();

            if (isAdd_)
            {
                if (dao.Add(info))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    // đánh dấu là đã thực hiện thành công việc thêm dữ liệu để chuẩn bị Load lại danh sách
                    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);
                }
            }
        }
Ejemplo n.º 2
0
 public void Edit(GiangVien giangVien)
 {
     if (giangVien == null)
     {
         return;
     }
     try
     {
         contextGV.Edit(giangVien);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }