Ejemplo n.º 1
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     if (!isAccountInfoEditable)
     {
         txtEmail.ReadOnly     = false;
         txtName.ReadOnly      = false;
         btnEdit.Text          = "Confirm Changes!";
         isAccountInfoEditable = true;
     }
     else
     {
         txtEmail.ReadOnly = true;
         txtName.ReadOnly  = true;
         DataBaseAccess dataBaseAccess = new DataBaseAccess();
         dataBaseAccess.StartConnection();
         if (txtEmail.Text.Contains('@') && formMain.UsersAccounts.RetrieveUserData(txtEmail.Text) == null)
         {
             dataBaseAccess.ChangeUserEmail(_currentUser.userName, txtEmail.Text);
         }
         if (txtName.Text.Count() >= 1 && txtName.Text.Count() < 12)
         {
             dataBaseAccess.ChangeUserFullName((int)_currentUser.GetUserID(), txtName.Text);
         }
         formMain.UsersAccounts.SetCurrentUser(dataBaseAccess.GetUser((int)_currentUser.GetUserID()));
         dataBaseAccess.CloseConnection();
         btnEdit.Text          = "Edit User Information";
         isAccountInfoEditable = false;
     }
 }