Пример #1
0
        private void salvarAlteracao(object sender, EventArgs e)
        {
            if (imgErroNome.Visible == false && imgErroData.Visible == false && imgErroTelefone.Visible == false &&
                imgErroEmail.Visible == false && imgErroSenha.Visible == false && imgErroCEP.Visible == false &&
                imgErroPais.Visible == false && imgErroEstado.Visible == false && imgErroCidade.Visible == false &&
                imgErroBairro.Visible == false && imgErroEndereco.Visible == false) //todos os campos foram preenchidos corretamente
            {
                if (txtConfirmacao.Text == txtSenha.Text)
                {
                    usuario alterar = new usuario();
                    alterar = logada;
                    string novoValorNome     = txtNome.Text;
                    string novoValorData     = txtData.Text;
                    string novoValorTelefone = txtTelefone.Text;
                    string novoValorCelular  = txtCelular.Text;
                    string novoValorEmail    = txtEmail.Text;
                    string novoValorSenha    = txtSenha.Text;
                    string novoValorCEP      = txtCEP.Text;
                    string novoValorBairro   = txtBairro.Text;
                    string novoValorEndereco = txtEndereco.Text;

                    string passwords = encryption(novoValorSenha);

                    paises tes = new paises();
                    tes = bd.paises.Where(u => u.nome.Equals(comboBox1.Text)).FirstOrDefault();

                    estados tec = new estados();
                    tec = bd.estados.Where(d => d.nome.Equals(comboBox2.Text)).FirstOrDefault();

                    cidade tep = new cidade();
                    tep = bd.cidade.Where(g => g.nome.Equals(comboBox3.Text)).FirstOrDefault();


                    Image          img = roundShapePB2.Image;
                    byte[]         arr;
                    ImageConverter converter = new ImageConverter();
                    arr = (byte[])converter.ConvertTo(img, typeof(byte[]));


                    bool validAdm = false;
                    if (checkBox1.Checked == true)
                    {
                        validAdm = true;
                    }
                    else
                    {
                        validAdm = false;
                    }


                    //usuario novin = new usuario();
                    bd.usuario.ToList().ForEach(f =>
                    {
                        if (f.id == alterar.id)
                        {
                            f.nome             = novoValorNome;
                            f.foto             = arr;
                            f.dataDeNascimento = novoValorData;
                            f.telefone         = novoValorTelefone;
                            f.celular          = novoValorCelular;
                            f.email            = novoValorEmail;
                            f.senha            = passwords;
                            f.cep = novoValorCEP;

                            f.id_pais   = tes.id;
                            f.id_estado = tec.id;
                            f.id_cidade = tep.id;

                            f.bairro        = novoValorBairro;
                            f.endereco      = novoValorEndereco;
                            f.administrador = validAdm;

                            bd.SaveChanges();
                        }
                    });
                    //bd.usuario.Add(novin);
                    bd.SaveChanges();

                    label1.Visible = true;
                    label1.Text    = "Perfil salvo com sucesso!";
                }
                else
                {
                    label1.Visible = true;
                    label1.Text    = "Confira o campo Confirmação de Senha";
                }
            }
            else
            {
                label1.Visible = true;
                label1.Text    = "Preencha os campos obrigatórios!";
            }
        }
Пример #2
0
        public Form3()
        {
            InitializeComponent();

            label1.Visible = false;
            logada         = Form1.logado;
            usSenha.senha  = Form1.logado2.senha;
            carregarFoto();
            preencheInfo();
            preencheCombos();

            comboBox1.SelectedIndexChanged += mudaPais;
            comboBox2.SelectedIndexChanged += mudaEstado;

            panel1.BackColor = Color.FromArgb(1, 115, 56);
            panel2.BackColor = Color.FromArgb(17, 92, 53);
            panel3.BackColor = Color.White;
            panel3.Visible   = false;

            linkLabel5.Location = new System.Drawing.Point(0, 56);

            linkLabel2.Click  += expandirCadastros;
            linkLabel3.Visible = false;
            linkLabel4.Visible = false;

            linkLabel5.Click  += expandirRelatorios;
            linkLabel6.Visible = false;
            linkLabel7.Visible = false;

            if (logada.administrador == true)
            {
                checkBox1.Enabled = true;
            }
            else
            {
                checkBox1.Enabled = false;
            }

            this.roundShapePB1.ContextMenuStrip = this.contextMenuStrip1;
            roundShapePB1.MouseHover           += mostrarNome;

            btnSalvar.Click += salvarAlteracao;
            button1.Click   += addFoto;

            monthCalendar1.Visible = false;
            pictureBox4.Click     += aparecerCalendario;

            txtSenha.UseSystemPasswordChar       = true;
            txtConfirmacao.UseSystemPasswordChar = true;
            pictureBox5.Click += aparecerSenha;

            txtConfirmacao.Visible = true;
            label26.Visible        = true;
            label27.Visible        = true;
            txtSenha.LostFocus    += saiu;


            txtData.TextChanged     += txtData_TextChanged;
            txtTelefone.TextChanged += txtTelefone_TextChanged;
            txtCEP.TextChanged      += txtCEP_TextChanged;
            comboBox1.TextChanged   += comboBox1_TextChanged;
            comboBox2.TextChanged   += comboBox2_TextChanged;
            comboBox3.TextChanged   += comboBox3_TextChanged;
        }