private void Salvar() { try { var checarUsuario = new Agenda.Core.Service.Service(); if (checarUsuario.ChecarUsuario(txtLogin.Text)) { MessageBox.Show("Login já cadastrado. Utilize outro nome de login.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (VerificaCampo()) { var _objUsuario = new Entity.Usuario() { nome = txtNome.Text.ToUpper(), sobrenome = txtSobrenome.Text.ToUpper(), login = txtLogin.Text.ToUpper(), senha = txtSenha.Text, email = txtEmail.Text, foto = _ByteFoto, nivelAcesso = (int)((System.Collections.Generic.KeyValuePair <int, string>)(cmbPerfil.SelectedValue)).Key, status = (int)((System.Collections.Generic.KeyValuePair <int, string>)(cmbStatus.SelectedValue)).Key, sexo = cmbSexo.Text, idUsuarioLogado = _Usuario.idUsuarioLogado, loginLogado = _Usuario.login }; var retornoCadastro = new Agenda.Core.Service.Service().CadastrarUsuario(_objUsuario); if (retornoCadastro) { MessageBox.Show("Cadatrado com sucesso.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Dados não cadatrado, favor verifique.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnLogin_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(txtLogin.Text) && !string.IsNullOrEmpty(txtSenha.Text)) { MessageBox.Show("Informe o Login", "Informe", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (!string.IsNullOrEmpty(txtSenha.Text) && string.IsNullOrEmpty(txtSenha.Text)) { MessageBox.Show("Informe a Senha", "Informe", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (string.IsNullOrEmpty(txtLogin.Text) && string.IsNullOrEmpty(txtSenha.Text)) { MessageBox.Show("Informe Login e Senha", "Informe", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { var retorno = new Agenda.Core.Service.Service().LoginUsuario(txtLogin.Text, txtSenha.Text); if (retorno.idusuario != null) { if (retorno.idusuario > 0) { var frm = new FrmPrincipal(); frm.Iniciar(retorno); frm.ShowDialog(); } } else { MessageBox.Show("Login ou Senha Incorreto!", "Informe", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { new Exception("Erro - " + ex.Message.ToString() + " - Contate o Suporte."); } }