private void btnCadastrar_Click(object sender, EventArgs e) { if (btnCadastrar.Text == "Editar") { pnlLogin.Enabled = true; btnCadastrar.Text = "Salvar"; } else { //Salva o usuario editado if (!string.IsNullOrWhiteSpace(Codigo)) { modelLogin.Codigo = Codigo; modelLogin.ID = txtID.Text; if (txtSenha.Text == txtConfirmarSenha.Text) { modelLogin.Senha = txtSenha.Text; } else { MessageBox.Show("Senhas diferentes", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (rbAdministrador.Checked == true) { modelLogin.Nivel = rbAdministrador.Text; } if (rbSecretaria.Checked == true) { modelLogin.Nivel = rbSecretaria.Text; } if (rbClinico.Checked == true) { modelLogin.Nivel = rbClinico.Text; } if (controllerLogin.Editar(modelLogin)) { MessageBox.Show("O ID: " + txtID.Text + " foi editado com sucesso!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Information); pnlLogin.Enabled = false; btnCadastrar.Text = "Editar"; } } //Cadastra um novo usuario else { modelLogin.ID = txtID.Text; if (txtSenha.Text == txtConfirmarSenha.Text) { modelLogin.Senha = txtSenha.Text; } else { MessageBox.Show("Senhas diferentes", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (rbAdministrador.Checked == true) { modelLogin.Nivel = rbAdministrador.Text; } if (rbSecretaria.Checked == true) { modelLogin.Nivel = rbSecretaria.Text; } if (rbClinico.Checked == true) { modelLogin.Nivel = rbClinico.Text; } if (controllerLogin.VerificarLogin(modelLogin) == null && !string.IsNullOrWhiteSpace(txtSenha.Text)) { controllerLogin.Cadastrar(modelLogin); MessageBox.Show("O ID: " + txtID.Text + " foi cadastrado com sucesso!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Erro, verifique os dados e tente novamente!", "Alerta!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }