예제 #1
0
        private void guardarBtn_Click(object sender, EventArgs e)
        {
            if (pwdChangeText.Text != "Nueva contraseña" && pwdChangeText.Text != "" && pwdChangeCheckTxt.Text != "Validar Nueva Contraseña" && pwdChangeCheckTxt.Text != "")
            {
                if (pwdChangeCheckTxt.Text != pwdChangeText.Text)
                {
                    MessageBox.Show("Contraseñas no coinciden.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    pwdChangeCheckTxt.Text                  = "Validar Nueva Contraseña";
                    pwdChangeCheckTxt.ForeColor             = SystemColors.ControlDark;
                    pwdChangeCheckTxt.UseSystemPasswordChar = false;
                    pwdChangeText.Text                  = "Nueva contraseña";
                    pwdChangeText.ForeColor             = SystemColors.ControlDark;
                    pwdChangeText.UseSystemPasswordChar = false;
                    return;
                }

                if (pwdChangeText.Text == user.pwd)
                {
                    MessageBox.Show("Nueva contraseña no puede ser igual a la anterior.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    pwdChangeCheckTxt.Text                  = "Validar Nueva Contraseña";
                    pwdChangeCheckTxt.ForeColor             = SystemColors.ControlDark;
                    pwdChangeCheckTxt.UseSystemPasswordChar = false;
                    pwdChangeText.Text                  = "Nueva contraseña";
                    pwdChangeText.ForeColor             = SystemColors.ControlDark;
                    pwdChangeText.UseSystemPasswordChar = false;
                    return;
                }

                bool res = proxy.ChangeUser(user.ID, nameRegisterTxt.Text, lastNameRegisterTxt.Text, pwdChangeText.Text, imageLocation);

                if (res)
                {
                    this.Hide();
                    Form next = new Profile();
                    next.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error al realizar cambios.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                bool res = proxy.ChangeUser(user.ID, nameRegisterTxt.Text, lastNameRegisterTxt.Text, user.pwd, imageLocation);

                if (res)
                {
                    this.Hide();
                    Form next = new Profile();
                    next.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error al realizar cambios.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }