private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData() == true)
                {
                    Certificates aCertificates = new Certificates();
                    aCertificates.ID = ID_Old;
                    aCertificates.Certificate = txtCertificate.Text;
                    aCertificates.Organization = txtOrganization.Text;
                    aCertificates.Type = Convert.ToInt32(lueCertificateTypes.EditValue);
                    aCertificatesBO.Update(aCertificates);
                    if (this.afrmLst_Certificates_Old != null)
                    {
                        this.afrmLst_Certificates_Old.ReloadData();
                    }

                    MessageBox.Show("Sửa thành công !", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmUpd_Certificates.btnEdit_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData() == true)
                {
                    Certificates aCertificates = new Certificates();
                    aCertificates.Certificate = txtCertificate.Text;
                    aCertificates.Organization = txtOrganization.Text;
                    aCertificates.Type = Convert.ToInt32(lueCertificateTypes.EditValue);
                    int ID = aCertificatesBO.Insert(aCertificates);

                    if (this.afrmLst_Certificates_Old != null)
                    {
                        afrmLst_Certificates_Old.ReloadData();
                    }
                    else if (this.afrmTsk_SystemUser_Infromation != null)
                    {
                        this.afrmTsk_SystemUser_Infromation.ReloadCertificate();
                        this.afrmTsk_SystemUser_Infromation.CallBackCertificate(ID);
                    }
                    else if (this.afrmTsk_UpdateSystemUser_Infromation != null)
                    {
                        this.afrmTsk_UpdateSystemUser_Infromation.LoadCertificate();
                        this.afrmTsk_UpdateSystemUser_Infromation.SetFocusCertificate(ID);

                    }

                    MessageBox.Show("Thêm mới thành công !", "Success ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_Certificates.btnAddNew_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
 //Author : LinhTing
 //Function : Update Certificates
 public int Update(Certificates aCertificates)
 {
     try
     {
         aDatabaseDA.Certificates.AddOrUpdate(aCertificates);
         aDatabaseDA.SaveChanges();
         return aCertificates.ID;
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("CertificatesBO.Update :"+ ex.Message.ToString()));
     }
 }
 //Author : LinhTing
 //Function : Select Certificates = ID
 public List<Certificates> Select_ByIDSystemUser(int IDSystemUser)
 {
     List<SystemUsers_Certificates> aListSystemUsers_Certificates = aSystemUsers_CertificatesBO.Select_All().Where(p => p.IDSystemUser == IDSystemUser).ToList();
     List<int> aListID = aListSystemUsers_Certificates.Select(p => p.IDCertificate).ToList();
     List<Certificates> aListCertificates = new List<Certificates>();
     Certificates aCertificate;
     for (int i = 0; i < aListID.Count; i++)
     {
         aCertificate = new Certificates();
         aCertificate = Select_ByID(aListID[i]);
         aListCertificates.Add(aCertificate);
     }
     return aListCertificates;
 }