private void EditProfileButton_Click(object sender, EventArgs e) { try { if (EditProfileButton.Text.Equals(ProfileStringConstants.EDIT_PROFILE, StringComparison.OrdinalIgnoreCase)) { string saveText = ProfileStringConstants.SAVE_BUTTON.FirstCharToUpper(); EditProfileButton.Text = saveText; textBoxName.ReadOnly = false; textBoxAddress.ReadOnly = false; textBoxEmail.ReadOnly = false; textBoxPhone.ReadOnly = false; } else { string[] name = textBoxName.Text.Split(' '); if (name.Length == 3 && !string.IsNullOrWhiteSpace(name[0]) && !string.IsNullOrWhiteSpace(name[2])) { using (TransactionScope scope = new TransactionScope()) { _customer.Info.FirstName = name[0]; _customer.Info.MiddleName = name[1]; _customer.Info.LastName = name[2]; _customer.Info.Address = textBoxAddress.Text; _customer.Info.Email = textBoxEmail.Text; _customer.Info.ContactNo = textBoxPhone.Text; if (_customerManager.Update(_customer.Info)) { CustomerForm logInForm = Application.OpenForms.OfType <CustomerForm>().FirstOrDefault(); logInForm.LoadData(); scope.Complete(); } else { string message = "Can't update profile. Please try again."; string caption = "Error"; MessageBox.Show(message, caption, MessageBoxButtons.OK); } } } else { string message = "Entered Name should follow format \"firstname middlename lastname\""; string caption = "Error"; MessageBox.Show(message, caption, MessageBoxButtons.OK); } string editText = ProfileStringConstants.EDIT_PROFILE.FirstCharToUpper(); EditProfileButton.Text = editText; textBoxName.ReadOnly = true; textBoxAddress.ReadOnly = true; textBoxEmail.ReadOnly = true; textBoxPhone.ReadOnly = true; } LoadData(); } catch (Exception ex) { Logger.log.Error(ex.ToString()); } }