Exemple #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     // Mở kết nối
     // Thêm dữ liệu
     if (Add)
     {
         try
         {
             // Thực hiện lệnh
             BLKhoa blKhoa = new BLKhoa();
             blKhoa.ThemKhoa(this.txtMaKhoa.Text, this.txtTenKhoa.Text);
             // Load lại dữ liệu trên DataGridView
             LoadData();
             // Thông báo
             MessageBox.Show("Đã thêm xong!");
         }
         catch
         {
             MessageBox.Show("Không thêm được. Lỗi rồi!");
         }
     }
     else
     {
         // Thực hiện lệnh
         BLKhoa blTp = new BLKhoa();
         blTp.CapNhatKhoa(this.txtMaKhoa.Text, this.txtTenKhoa.Text, ref err);
         // Load lại dữ liệu trên DataGridView
         LoadData();
         // Thông báo
         MessageBox.Show("Đã sửa xong!");
     }
     // Đóng kết nối
 }