Esempio n. 1
0
        void GerarCredenciais()
        {
            try
            {
                string          nome = cboFuncionario.Text;
                FuncionarioView dto  = cboFuncionario.SelectedItem as FuncionarioView;

                mkbCPF.Text     = dto.Cpf;
                txtSalario.Text = dto.Salario.ToString();
                txtDepto.Text   = dto.Depto.ToString();

                if (dto.Imagem == string.Empty)
                {
                    pbxImgFuncionario.Image = null;
                }
                else
                {
                    pbxImgFuncionario.Image = ImagemPlugIn.ConverterParaImagem(dto.Imagem);
                }
            }
            catch (Exception ex)
            {
                string msg = "Ocorreu um erro: " + ex.Message;

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
        public void LoadScreen(FuncionarioView dto)
        {
            try
            {
                this.dto              = dto;
                txtCidade.Text        = dto.Cidade;
                txtEmail.Text         = dto.Email;
                txtNome.Text          = dto.Nome;
                nudSalario.Value      = dto.Salario;
                mkbCEP.Text           = dto.Cep;
                txtEndereco.Text      = dto.Rua;
                txtNum.Text           = dto.Numero.ToString();
                mkbCPF.Text           = dto.Cpf;
                mkbRG.Text            = dto.Rg;
                mkbTelefone.Text      = dto.Telefone;
                cboDepto.SelectedItem = dto.Depto;
                cboUF.Text            = dto.Estado;
                txtComplemento.Text   = dto.Complemento;

                pbxFoto.Image = ImagemPlugIn.ConverterParaImagem(dto.Imagem);
            }
            catch (Exception ex)
            {
                string msg = "Ocorreu um erro: " + ex.Message;

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
Esempio n. 3
0
        void GerarCredenciais()
        {
            try
            {
                string          nome = cboFuncionario.Text;
                ViewFuncionario dto  = cboFuncionario.SelectedItem as ViewFuncionario;

                mkbCPF.Text     = dto.Cpf;
                txtSalario.Text = dto.Salario.ToString();
                txtDepto.Text   = dto.Depto.ToString();

                if (dto.Imagem == string.Empty)
                {
                    pbxImgFuncionario.Image = null;
                }
                else
                {
                    pbxImgFuncionario.Image = ImagemPlugIn.ConverterParaImagem(dto.Imagem);
                }
            }
            catch (Exception)
            {
                frmException tela = new frmException();
                tela.LoadScreen("Ocorreu um erro.\nConsulte o administrador do sistema.");
                tela.ShowDialog();
            }
        }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                DeptoDTO  depto  = cboDepto.SelectedItem as DeptoDTO;
                EstadoDTO estado = cboUF.SelectedItem as EstadoDTO;

                FuncionarioDTO dto = new FuncionarioDTO();
                dto.Nome        = txtNome.Text;
                dto.Rg          = mkbRG.Text;
                dto.Salario     = nudSalario.Value;
                dto.Cpf         = mkbCPF.Text;
                dto.Telefone    = mkbTelefone.Text;
                dto.Email       = txtEmail.Text;
                dto.IdDepto     = depto.Id;
                dto.Cidade      = txtCidade.Text;
                dto.IdEstado    = estado.Id;
                dto.Cep         = mkbCEP.Text;
                dto.Rua         = txtEndereco.Text;
                dto.Complemento = txtComplemento.Text;
                dto.Numero      = txtNum.Text;

                dto.Imagem = ImagemPlugIn.ConverterParaString(pbxFoto.Image);

                FuncionarioBusiness buss = new FuncionarioBusiness();
                buss.Salvar(dto);

                frmMessage tela = new frmMessage();
                tela.LoadScreen("Funcionário cadastrado com sucesso!");
                tela.ShowDialog();
            }
            catch (MySqlException mex)
            {
                if (mex.Number == 1062)
                {
                    string msg = "Funcionario já está cadastrado. Verifique se o CPF está corretamente preenchido ou se ele já esta no sistema.";

                    frmAlert tela = new frmAlert();
                    tela.LoadScreen(msg);
                    tela.ShowDialog();
                }
            }
            catch (ValidacaoException vex)
            {
                string msg = vex.Message;

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            catch (Exception ex)
            {
                string msg = "Ocorreu um erro: " + ex.Message;

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                DeptoDTO  depto  = cboDepto.SelectedItem as DeptoDTO;
                EstadoDTO estado = cboUF.SelectedItem as EstadoDTO;

                int funcio = this.dto.Id;

                FuncionarioDTO dto = new FuncionarioDTO();
                dto.Id = funcio;

                dto.Nome        = txtNome.Text;
                dto.Rg          = mkbRG.Text;
                dto.Salario     = nudSalario.Value;
                dto.Cpf         = mkbCPF.Text;
                dto.Telefone    = mkbTelefone.Text;
                dto.Email       = txtEmail.Text;
                dto.IdDepto     = depto.Id;
                dto.Cidade      = txtCidade.Text;
                dto.IdEstado    = estado.Id;
                dto.Cep         = mkbCEP.Text;
                dto.Rua         = txtEndereco.Text;
                dto.Numero      = txtNum.Text;
                dto.Imagem      = ImagemPlugIn.ConverterParaString(pbxFoto.Image);
                dto.Complemento = txtComplemento.Text;

                FuncionarioBusiness buss = new FuncionarioBusiness();
                buss.Alterar(dto);

                string msg = "Funcionário alterado com sucesso!";

                frmMessage tela = new frmMessage();
                tela.LoadScreen(msg);
                tela.ShowDialog();

                this.Close();
            }
            catch (ValidacaoException vex)
            {
                string msg = vex.Message;

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            catch (Exception ex)
            {
                string msg = "Ocorreu um erro: " + ex.Message;

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }