Пример #1
0
        public static void AlterarUsuario(UsuarioVO u)
        {
            string sql = String.Format("update UserDev set nomeUserDev = '{0}', nascimento = '{1}', senha = '{2}'," +
            "email = '{3}', caminhoDaFoto = '{4}' where idUserDev = {5}", u.GetNome(),
            u.GetNascimento(), u.GetSenha(), u.GetEmail(), u.GetCaminhoDoArquivo(), u.GetId());

            Metodos.ExecutaSql(sql);
        }
Пример #2
0
        public static void InserirUsuario(UsuarioVO u)
        {
            string sql = String.Format("set dateformat dmy; " +
            "insert into UserDev (idUserDev, tipoCadastro, nomeUserDev, nascimento, username, senha, email, caminhoDaFoto) values " +
            "({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}');", u.GetId(), u.GetTipoCadastro(),
            u.GetNome(), u.GetNascimento(), u.GetUsuario(), u.GetSenha(), u.GetEmail(), u.GetCaminhoDoArquivo());

            Metodos.ExecutaSql(sql);
        }
        private void btnAvancar_Click(object sender, EventArgs e)
        {
            if (tabWizard.SelectedIndex == 2)
            {
                if (!Validacoes())
                    return;
                else
                {
                    try
                    {
                        UsuarioVO u = new UsuarioVO();

                        u.SetId(Metodos.GeraId("select top 1 idUserDev from UserDev order by idUserDev desc"));

                        if (rbUsuario.Checked)
                            u.SetTipoCadastro('U');
                        else
                            u.SetTipoCadastro('D');

                        u.SetNome(txtNome.Text.Trim() + " " + txtSobrenome.Text.Trim());
                        u.SetNascimento(Convert.ToDateTime(txtNascimento.Text.Trim()));
                        u.SetUsuario(txtUsuario.Text.Trim());
                        u.SetSenha(txtSenha.Text.Trim());
                        u.SetEmail(txtEmail.Text.Trim());

                        string extensao = "";

                        if (txtFoto.Text.Trim() != "padrão")
                        {
                            extensao = Metodos.CopiarFotoUser(u.GetId(), txtFoto.Text);
                            extensao = extensao.Substring(extensao.LastIndexOf('.'));
                        }
                        else
                            extensao = "padrão";

                        u.SetCaminhoDoArquivo(extensao);

                        UsuarioDAO.InserirUsuario(u);
                        tabWizard.SelectedIndex = 3;
                    }
                    catch (Exception erro)
                    {
                        string err = erro.Message.ToString();
                        Metodos.Mensagem("Ocorreu um erro ao adicionar os dados:" + Environment.NewLine + err, Metodos.TipoMensagem.erro);
                        tabWizard.SelectedIndex = 4;
                    }
                }
            }

            if (tabWizard.SelectedIndex != 3 && tabWizard.SelectedIndex != 4)
                tabWizard.SelectedIndex += 1;

            VerificaQualPagina();
        }
Пример #4
0
        public static UsuarioVO MontaUsuarioVO(DataRow linha)
        {
            UsuarioVO u = new UsuarioVO();
            u.SetId(Convert.ToInt32(linha["idUserDev"]));
            u.SetTipoCadastro(Convert.ToChar(linha["tipoCadastro"]));
            u.SetNome(linha["nomeUserDev"].ToString());
            u.SetNascimento(Convert.ToDateTime(linha["nascimento"]));
            u.SetUsuario(linha["username"].ToString());
            u.SetSenha(linha["senha"].ToString());
            u.SetEmail(linha["email"].ToString());
            u.SetCaminhoDoArquivo(linha["caminhoDaFoto"].ToString());

            return u;
        }
        private void PreencherUsuarioSA(UsuarioVO u)
        {
            try
            {
                txtNome.Text = u.GetNome().Substring(0, u.GetNome().IndexOf(" "));
                txtSobrenome.Text = u.GetNome().Substring(u.GetNome().IndexOf(" ") + 1);
                txtNascimento.Text = u.GetNascimento().ToString("dd/MM/yyyy");
                txtUsuario.Text = u.GetUsuario();
                txtSenha.Text = u.GetSenha();
                txtEmail.Text = u.GetEmail();
                txtID.Text = u.GetId().ToString();

                if (u.GetTipoCadastro().ToString() == "U")
                    txtTipoCadastro.Text = "Usuário";
                else
                    txtTipoCadastro.Text = "Desenvolvedor";

                if (u.GetCaminhoDoArquivo() != "padrão")
                {
                    pbSAUser.ImageLocation = ondeEstamos + "userimgs\\" + u.GetId() + u.GetCaminhoDoArquivo();
                }
                else
                {
                    pbSAUser.Image = Properties.Resources.unknown_person;
                }
            }
            catch { }
        }