private void buttonSave_Click(object sender, EventArgs e) { long result; if (textBoxDni.Text.Trim().Equals("")) { MessageBox.Show(Strings.errorDni, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBoxPhone.Text.Trim().Equals("")) { MessageBox.Show(Strings.errorPhone, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!long.TryParse(textBoxPhone.Text.Trim(), out result)) { MessageBox.Show(Strings.errorPhoneNum, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBoxName.Text.Trim().Equals("")) { MessageBox.Show(Strings.errorName, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBoxLastName.Text.Trim().Equals("")) { MessageBox.Show(Strings.errorLastName, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBoxEmail.Text.Trim().Equals("")) { MessageBox.Show(Strings.errorEmail, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (textBoxPassword.Text.Trim().Equals("")) { MessageBox.Show(Strings.errorPassword, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!textBoxPassword2.Text.Trim().Equals(textBoxPassword.Text.Trim())) { MessageBox.Show(Strings.errorPassword2, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!regex.IsMatch(textBoxPassword2.Text.Trim()) && !regex.IsMatch(textBoxPassword.Text.Trim()) && socio == null) { MessageBox.Show(Strings.security, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!regex.IsMatch(textBoxPassword2.Text.Trim()) && !regex.IsMatch(textBoxPassword.Text.Trim()) && !textBoxPassword.Text.Trim().Equals(socio.password)) { MessageBox.Show(Strings.security, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { //bindingSourceComunidades.DataSource = comunidades; socios socioNuevo = new socios(); socioNuevo.dni = textBoxDni.Text.Trim(); socioNuevo.telefono = textBoxPhone.Text.Trim(); socioNuevo.nombre = textBoxName.Text.Trim(); socioNuevo.apellidos = textBoxLastName.Text.Trim(); socioNuevo.mail = textBoxEmail.Text.Trim(); socioNuevo.activo = checkBoxActive.Checked; socioNuevo.administrador = checkBoxAdministrator.Checked; socioNuevo.estatal = checkBoxState.Checked; if (modificar) { String clave = textBoxPassword.Text.Trim(); if (!clave.Equals(socio.password)) { OC.Core.Crypto.Hash hash = new OC.Core.Crypto.Hash(); clave = hash.Sha512(textBoxPassword.Text.Trim()); } socioNuevo.password = clave; } else { OC.Core.Crypto.Hash hash = new OC.Core.Crypto.Hash(); String clave = hash.Sha512(textBoxPassword.Text.Trim()); socioNuevo.password = clave; } socioNuevo.comunidades = ComunidadORM.SelectComunidad((int)comboBoxComunity.SelectedValue); if (comboBoxComunity.SelectedItem != null) { socioNuevo.id_comunidad = (int)comboBoxComunity.SelectedValue; } if (!modificar) { if (SocioORM.InsertSocio(socioNuevo)) { MessageBox.Show(Strings.partnerCreated, Strings.created, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } else { socioNuevo.id = socio.id; if (SocioORM.UpdateSocio(socioNuevo)) { MessageBox.Show(Strings.modifiedPartnert, Strings.modified, MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } } }