Beispiel #1
0
        public frmUsuariosAdd(Usuarios item)
        {
            InitializeComponent();
            Inicializar("Pagina: Usuários");
            this.item = item;

            if (item != null)
            {
                txtCodigo.Text        = item.UsuariosId.ToString();
                txtNomeCompleto.Text  = item.UsuarioNomeCompleto.ToString();
                txtApelido.Text       = item.Apelido.ToString();
                txtSenha.Text         = item.Senha.ToString();
                txtRepetir_Senha.Text = item.Senha.ToString();
                txtPIN.Text           = item.Pin.ToString();
                txtEmail.Text         = item.Email.ToString();
                checkEdit1.Checked    = item.Estado;
                dateEdit1.DateTime    = item.DataNascimento.Date;

                txtGrupos.EditValue = item.GrupoId;
                txtLogin.Text       = item.Login;

                if (item.Perfil != null)
                {
                    ImagemPictureEdit.Image = (Image)ImagemTratamento.byteArrayToImage(item.Perfil);
                }
            }
        }
Beispiel #2
0
        private async void Guardar_Registro()
        {
            try
            {
                if (Validar1(1))
                {
                    Cursor = Cursors.WaitCursor;

                    if (!(GetExistingData() > 0))
                    {
                        var curs = new Usuarios
                        {
                            //CursosTypoNome = txtNome.Text == null ? "" : "",
                            UsuarioNomeCompleto = txtNomeCompleto.Text,
                            Apelido             = txtApelido.Text,
                            Login          = txtLogin.Text,
                            Senha          = Encriptar.GetMD5Hash(txtSenha.Text),
                            DataNascimento = Convert.ToDateTime(dateEdit1.EditValue),
                            Email          = txtEmail.Text.Trim(),
                            Pin            = Encriptar.GetMD5Hash(txtPIN.Text),
                            Estado         = (bool)checkEdit1.EditValue,
                            GrupoId        = Convert.ToInt32(txtGrupos.EditValue),
                            Perfil         = (byte[])ImagemTratamento.ImageToByteArray(ImagemPictureEdit.Image)
                        };
                        if ((await UsuariosControllers.GetInstacia().Insert(curs)).IsSucess)
                        {
                            XtraMessageBox.Show("Serviço Inserido com Sucesso!...", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            ListGeral();
                            limpar_Campos();
                        }
                        else
                        {
                            XtraMessageBox.Show("Este Valor já existe tente novamente", "Má conclusão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Lamentamos mais já existe este login no Sistema\n Não pode existir PIN ou login com o mesmo acesso", "Má conclusão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (System.Exception exception)
            {
                MessageBox.Show("Erro " + exception, "Erro de SQL", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Beispiel #3
0
        public void Detalhes()
        {
            Cursor = Cursors.WaitCursor;
            try
            {
                if (gridView1.SelectedRowsCount > 0)
                {
                    if (gridView1.FocusedRowHandle >= 0)
                    {
                        listBoxControl1.Items.Clear();

                        var item       = usuariosBindingSource.Current as Usuarios;
                        var ImagemProd = item.Perfil;

                        if (item != null)
                        {
                            if (ImagemProd != null)
                            {
                                pictureEdit1.Image = (Image)ImagemTratamento.byteArrayToImage(ImagemProd);
                                ImagemProd         = null;
                            }
                            else
                            {
                                pictureEdit1.Image = null;
                            }

                            listBoxControl1.Items.AddRange(new object[] { "Código :    " + item.UsuariosId.ToString(),
                                                                          "Usuário:    " + item.UsuarioNomeCompleto,
                                                                          "Apelido:    " + item.Apelido,
                                                                          "E-Mail :    " + item.Email,
                                                                          "Estado :    " + string.Format("{0}", item.Estado == true ? "Activado" : "Desativado",
                                                                                                         "Aniversário:" + item.DataNascimento.ToShortDateString()), });
                        }

                        try
                        {
                            LerLogs();
                        }
                        catch (Exception exe)
                        {
                            MessageBox.Show(exe.Message);
                        }
                    }
                }
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
Beispiel #4
0
        private void Edit(int I, string user)
        {
            try
            {
                prog.Mostrar(this, "Aguarde!...", "Aguarde");

                var item = UsuariosInstaciaList.Where(x => x.UsuariosId == I ||
                                                      x.UsuarioNomeCompleto.ToLower() == user.ToLower()).FirstOrDefault();

                if (item != null)
                {
                    txtCodigo.Text        = item.UsuariosId.ToString();
                    txtNomeCompleto.Text  = item.UsuarioNomeCompleto;
                    txtApelido.Text       = item.Apelido;
                    txtLogin.Text         = item.Login;
                    txtSenha.Text         = item.Senha;
                    txtRepetir_Senha.Text = item.Senha;
                    dateEdit1.EditValue   = item.DataNascimento;
                    txtEmail.Text         = item.Email;
                    txtPIN.Text           = item.Pin;
                    checkEdit1.EditValue  = item.Estado;
                    txtGrupos.EditValue   = item.GrupoId;

                    UserPassword = item.Senha;
                    UserPIN      = item.Pin;

                    var ImagemProd = item.Perfil;
                    if (ImagemProd != null)
                    {
                        ImagemPictureEdit.Image = (Image)ImagemTratamento.byteArrayToImage(item.Perfil);
                        ImagemProd = null;
                    }
                    else
                    {
                        ImagemPictureEdit.Image = null;
                    }
                }
                txtNomeCompleto.Focus();
            }
            catch (System.Exception exe)
            {
                MessageBox.Show("Erro ao passar Dados" + exe.Message, "Erro de Dados", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                prog.Mostrar_Close(this);
                txtNomeCompleto.Focus();
            }
        }
Beispiel #5
0
        private async void Atualizar_RegistroAsync()
        {
            try
            {
                if (Validar1(2))
                {
                    Cursor = Cursors.WaitCursor;

                    if (!(GetExistingData() > 1))
                    {
                        if (MessageBox.Show("Estas preste a alterar o valor do (" + txtNomeCompleto.Text + ")! pretendes continuar?", "Alteração de dados", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                        {
                            string Pass1;
                            string Pass2;

                            if (isNew)
                            {
                                Pass1 = Encriptar.GetMD5Hash(txtSenha.Text);
                                Pass2 = Encriptar.GetMD5Hash(txtPIN.Text);
                            }
                            else
                            {
                                Pass1 = txtSenha.Text;
                                Pass2 = txtPIN.Text;
                            }

                            var cursos = new Usuarios
                            {
                                UsuariosId          = Convert.ToInt32(txtCodigo.Text),
                                UsuarioNomeCompleto = txtNomeCompleto.Text,
                                Apelido             = txtApelido.Text,
                                Login          = txtLogin.Text,
                                Senha          = Pass1,
                                DataNascimento = Convert.ToDateTime(dateEdit1.EditValue),
                                Email          = txtEmail.Text,
                                Pin            = Pass2,
                                Estado         = (bool)checkEdit1.EditValue,
                                GrupoId        = Convert.ToInt32(txtGrupos.EditValue),
                                Perfil         = (byte[])ImagemTratamento.ImageToByteArray(ImagemPictureEdit.Image)
                            };
                            if ((await UsuariosControllers.GetInstacia().Update(cursos)).IsSucess)
                            {
                                XtraMessageBox.Show("Serviço Atualizado com Sucesso!...", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                ListGeral();
                                limpar_Campos();
                            }
                            else
                            {
                                XtraMessageBox.Show("Este Valor já existe tente novamente", "Má conclusão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        XtraMessageBox.Show("Lamentamos mais já existe este login no Sistema\n Não pode existir PIN ou login com o mesmo acesso", "Má conclusão", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (System.Exception exe)
            {
                XtraMessageBox.Show(exe.Message, "Arro de Actualização", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }