Ejemplo n.º 1
0
        private void btnDeletar_Click(object sender, EventArgs e)
        {
            if (cliente == null)
            {
                string   msg   = "Selecione um registro para removê-lo.";
                frmAlert alert = new frmAlert();
                alert.LoadScreen(msg);
                alert.ShowDialog();
            }
            else
            {
                string msgm = "Quer mesmo apagar o registro " + cliente.id + "?" +
                              "\nObs: ao apagar este cliente, todos os outros registros nele vinculados serão perdidos.";

                frmQuestion tela = new frmQuestion();
                tela.LoadScreen(msgm);
                tela.ShowDialog();

                bool click = tela.BotaoYes;

                if (click == true)
                {
                    ClienteBusiness buss = new ClienteBusiness();
                    buss.Remover(cliente.id);

                    CarregarGrid();
                }
            }
        }
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            try
            {
                if (funcionario == null)
                {
                    string msg = "Selecione um registro para Altera-lo.";

                    frmAlert tela = new frmAlert();
                    tela.LoadScreen(msg);
                    tela.ShowDialog();
                }
                else
                {
                    frmAlterarFuncionarios screen = new frmAlterarFuncionarios();
                    screen.LoadScreen(funcionario);
                    screen.ShowDialog();

                    CarregarGrid();
                }
            }
            catch (Exception ex)
            {
                string msg = "Ocorreu um erro: " + ex.Message;

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
Ejemplo n.º 3
0
        private void btnDeletar_Click_1(object sender, EventArgs e)
        {
            if (fornecedor == null)
            {
                string msg = "Selecione um fornecedor para deleta-lo.";

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            else
            {
                string mensagem = "Quer mesmo apagar o Fornecedor " + fornecedor.Id + " do sistema?" +
                                  "\n obs: ao apagar um fornecedor, todos os outros registros nele vinculados serão apagados.";

                frmQuestion tela = new frmQuestion();
                tela.LoadScreen(mensagem);
                tela.ShowDialog();

                bool click = tela.BotaoYes;

                if (click == true)
                {
                    FornecedoresBusiness buss = new FornecedoresBusiness();
                    buss.Remover(fornecedor.Id);

                    CarregarGrid();
                }
            }
        }
Ejemplo n.º 4
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            LoginBusiness business = new LoginBusiness();
            string        user     = txtUser.Text;
            string        pass     = txtPass.Text;

            LoginDTO usuario = business.Logar(user, pass);


            if (usuario != null)
            {
                UserSession.UsuarioLogado = usuario;

                Menu tela = new Menu();
                tela.Show();
                this.Close();
            }
            else
            {
                string msg = "Nome de usuário ou senha incorretos.";

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
Ejemplo n.º 5
0
        private void btnEntrar_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                LoginBusiness business = new LoginBusiness();
                string        user     = txtUser.Text;
                string        pass     = txtPass.Text;

                LoginDTO usuario = business.Logar(user, pass);


                if (usuario != null)
                {
                    UserSession.UsuarioLogado = usuario;

                    frmMenuPrincipal tela = new frmMenuPrincipal();
                    tela.Show();
                    this.Close();
                }
                else
                {
                    frmAlert tela = new frmAlert();
                    tela.LoadScreen("Nome de usuário ou senha incorretos.");
                    tela.ShowDialog();
                }
            }
        }
Ejemplo n.º 6
0
        private void btnComprar_Click(object sender, EventArgs e)
        {
            try
            {
                ComprasDTO dto = new ComprasDTO();
                dto.UsuarioId  = UserSession.UsuarioLogado.Id;
                dto.Data       = mkbDataCompra.Text;
                dto.FormaPagto = Convert.ToString(cboTipoPag.SelectedItem);

                ComprasBusiness buss = new ComprasBusiness();
                buss.Salvar(dto, carrinhoAdd.ToList());

                string msg = "Compra salva com sucesso!";

                frmMessage tela = new frmMessage();
                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();
            }
        }
Ejemplo n.º 7
0
        private void btnDeletar_Click(object sender, EventArgs e)
        {
            if (animal == null)
            {
                string msg = "Selecione um registro para removê-lo";

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            else
            {
                string      msg  = "Quer mesmo remover o registro " + animal.Id + "?";
                frmQuestion tela = new frmQuestion();
                tela.LoadScreen(msg);
                tela.ShowDialog();

                bool click = tela.BotaoYes;

                if (click == true)
                {
                    AnimalBusiness buss = new AnimalBusiness();
                    buss.Remover(animal.Id);

                    CarregarGrid();
                }
            }
        }
        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 button1_Click(object sender, EventArgs e)
        {
            try
            {
                EstadoDTO estado = cboEstado.SelectedItem as EstadoDTO;

                FornecedoresDTO dto = new FornecedoresDTO();

                dto.Nome = txtNome.Text;
                dto.Email = txtEmail.Text;
                dto.CNPJ = txtCnpj.Text;
                dto.Cidade = txtCidade.Text;
                dto.CEP = mkbCep.Text;
                dto.Telefone = txtTelefone.Text;
                dto.IdEstado = estado.Id;
                dto.Rua = txtRua.Text;
                dto.Numero = txtNumero.Text;

                FornecedoresBusiness business = new FornecedoresBusiness();
                business.Salvar(dto);

                string msg = "Fornecedor cadastrado com sucesso!";

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

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            catch (MySqlException mex)
            {
                if (mex.Number == 1062)
                {
                    string msg = "Esse fornecedor já está cadastrado. " +
                        "Verifique se o CNPJ está corretamente preenchido ou se ele já está cadastrado no sistema.";

                    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();
            }
        }
Ejemplo n.º 10
0
        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();
            }
        }
Ejemplo n.º 11
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            try
            {
                EstadoDTO dto = cboUF.SelectedItem as EstadoDTO;

                ClienteDTO dta = new ClienteDTO();
                dta.id = this.cliente.id;

                dta.Nome           = txtNome.Text;
                dta.Email          = txtEmail.Text;
                dta.DataNascimento = mkbNascimento.Text;
                dta.Rg             = mkbRG.Text;
                dta.Cpf            = mkbCPF.Text;
                dta.Telefone       = mkbTelefone.Text;
                dta.Cidade         = txtCidade.Text;
                dta.DataCadastro   = mkbCadastro.Text;
                dta.Cep            = txtCEP.Text;
                dta.Rua            = txtRua.Text;
                dta.Numero         = txtNumero.Text;
                dta.EstadoId       = Convert.ToInt32(dto.Id);
                dta.Complemento    = txtComplemento.Text;

                ClienteBusiness business = new ClienteBusiness();
                business.Alterar(dta);

                string msg = "Cliente Cadastrado com sucesso";

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

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
Ejemplo n.º 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                EstadoDTO estado = cboEstado.SelectedItem as EstadoDTO;

                FornecedoresDTO dto = new FornecedoresDTO();
                dto.Id = this.fornecedor.Id;

                dto.Nome     = txtNome.Text;
                dto.Email    = txtEmail.Text;
                dto.CNPJ     = txtCnpj.Text;
                dto.Cidade   = txtCidade.Text;
                dto.CEP      = mkbCep.Text;
                dto.Telefone = txtTelefone.Text;
                dto.IdEstado = estado.Id;
                dto.Rua      = txtRua.Text;
                dto.Numero   = txtNumero.Text;

                FornecedoresBusiness business = new FornecedoresBusiness();
                business.Alterar(dto);

                string msg = "Fornecedor alterado com sucesso!";

                frmMessage tela = new frmMessage();
                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();
            }
        }
Ejemplo n.º 13
0
        private void btnAlterar_Click_1(object sender, EventArgs e)
        {
            if (cliente == null)
            {
                string   msg   = "Selecione um registro para alterá-lo.";
                frmAlert alert = new frmAlert();
                alert.LoadScreen(msg);
                alert.ShowDialog();
            }
            else
            {
                frmAlterarCliente tela = new frmAlterarCliente();
                tela.LoadScreen(cliente);
                tela.ShowDialog();

                CarregarGrid();
            }
        }
Ejemplo n.º 14
0
        private void btnAnexar_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog janela = new OpenFileDialog();
                janela.ShowDialog();

                txtAnexo.Text = janela.FileName;

                Email.AdicionarAnexo(janela.FileName);
            }
            catch (Exception)
            {
                frmAlert tela = new frmAlert();
                tela.LoadScreen("Não foi possível adicionar este anexo.");
                tela.ShowDialog();
            }
        }
Ejemplo n.º 15
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (item == null)
            {
                string   msg  = "Selecione um item para alterá-lo.";
                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            else
            {
                frmAlterarItem tela = new frmAlterarItem();
                tela.LoadScreen(item);
                tela.ShowDialog();

                CarregarGrid();
            }
        }
Ejemplo n.º 16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                FornecedoresDTO fornecedor = cboFornecedor.SelectedItem as FornecedoresDTO;

                ItemDTO dto = new ItemDTO();
                dto.Nome         = txtNome.Text;
                dto.FornecedorId = fornecedor.Id;
                dto.Descricao    = txtDescricao.Text;
                dto.Preco        = Convert.ToDecimal(nudPreco.Value);

                ItemBusiness buss = new ItemBusiness();
                int          pk   = buss.Salvar(dto);

                EstoqueDTO estoque = new EstoqueDTO();
                estoque.Produto       = txtNome.Text;
                estoque.ItemProdutoId = pk;
                estoque.QtdEstocado   = 0;

                EstoqueBusiness business = new EstoqueBusiness();
                business.Salvar(estoque);

                string msg = "Item salvo com sucesso!";

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

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
Ejemplo n.º 17
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                ProdutoDTO dto = new ProdutoDTO();
                dto.Nome      = txtNome.Text;
                dto.Marca     = txtMarca.Text;
                dto.Descricao = txtDesc.Text;
                dto.Preco     = nudPreco.Value;

                ProdutoBusiness business = new ProdutoBusiness();
                int             pk       = business.Salvar(dto);

                EstoqueDTO estoque = new EstoqueDTO();
                estoque.Produto       = txtNome.Text;
                estoque.ItemProdutoId = pk;
                estoque.QtdEstocado   = 0;

                EstoqueBusiness buss = new EstoqueBusiness();
                buss.Salvar(estoque);

                string msg = "Produto Cadastrado com sucesso!";

                frmMessage tela = new frmMessage();
                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();
            }
        }
Ejemplo n.º 18
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (produto == null)
            {
                string msg = "selecione um registro para alterá-lo";

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            else
            {
                frmAlterarProduto form = new frmAlterarProduto();
                form.LoadScreen(produto);
                form.ShowDialog();

                CarregarGrid();
            }
        }
Ejemplo n.º 19
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (animal == null)
            {
                string msg = "Selecione um registro para alterá-lo";

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            else
            {
                frmAlterarAnimal screen = new frmAlterarAnimal();
                screen.LoadScreen(animal);
                screen.ShowDialog();

                CarregarGrid();
            }
        }
Ejemplo n.º 20
0
        private void btnAlterar_Click(object sender, EventArgs e)
        {
            if (fornecedor == null)
            {
                string msg = "Selecione um fornecedor para altera-lo.";

                frmAlert tela = new frmAlert();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
            else
            {
                frmAlterarFornecedor tela = new frmAlterarFornecedor();
                tela.LoadScreen(fornecedor);
                tela.ShowDialog();

                CarregarGrid();
            }
        }
Ejemplo n.º 21
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                ClienteDTO IdCliente = cboDono.SelectedItem as ClienteDTO;

                AnimalDTO dto = new AnimalDTO();
                dto.Id = this.animal.Id;

                dto.NomeAnimal = txtNomeAnimal.Text;
                dto.Sexo       = cboSexo.Text;
                dto.Raca       = txtRaca.Text;
                dto.Pelagem    = txtTipoPelo.Text;
                dto.CorPelo    = txtCorPelo.Text;
                dto.Obs        = txtObs.Text;
                dto.IdCliente  = IdCliente.id;
                dto.DataNasc   = mkbDataNasc.Text;
                dto.Imagem     = PlugIn.ImagemPlugIn.ConverterParaString(pbxImagem.Image);

                AnimalBusiness business = new AnimalBusiness();
                business.Alterar(dto);

                string msg = "Animal Alterado com sucesso!";

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

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
Ejemplo n.º 22
0
        private void btnEnviar_Click(object sender, EventArgs e)
        {
            try
            {
                string email = txtPara.Text;
                email = email.Trim();

                Validacoes.ValidarEmail validEmail = new Validacoes.ValidarEmail();

                bool mail = validEmail.VerificarEmail(email);

                if (mail == false)
                {
                    throw new Exception();
                }

                string msg    = txtMsg.Text;
                int    qtdMsg = msg.Count();

                if (qtdMsg == 0)
                {
                    throw new Exception();
                }

                Email.Para     = txtPara.Text;
                Email.Assunto  = txtAssunto.Text;
                Email.Mensagem = txtMsg.Text;

                Email.Enviar();

                frmMessage tela = new frmMessage();
                tela.LoadScreen("E-mail enviado!");
                tela.ShowDialog();
            }
            catch (Exception)
            {
                frmAlert tela = new frmAlert();
                tela.LoadScreen("Não foi possível enviar o email. \nVerifique se o destinatário está correto.");
                tela.ShowDialog();
            }
        }
Ejemplo n.º 23
0
        private void btnDeletar_Click(object sender, EventArgs e)
        {
            try
            {
                if (funcionario == null)
                {
                    string msg = "Selecione um registro para remove-lo.";

                    frmAlert tela = new frmAlert();
                    tela.LoadScreen(msg);
                    tela.ShowDialog();
                }
                else
                {
                    string msg = "Quer mesmo deletar o funcionário " + funcionario.Id + " do sistema?";

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

                    bool botaoYes = tela.BotaoYes;

                    if (botaoYes == true)
                    {
                        FuncionarioBusiness buss = new FuncionarioBusiness();
                        int Id = funcionario.Id;
                        buss.Remover(Id);

                        CarregarGrid();
                    }
                }
            }
            catch (Exception ex)
            {
                string msg = "Ocorreu um erro: " + ex.Message;

                frmException tela = new frmException();
                tela.LoadScreen(msg);
                tela.ShowDialog();
            }
        }
        private void txtCep_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                try
                {
                    var ws       = new WSCorreios.AtendeClienteClient();
                    var resposta = ws.consultaCEP(mkbCep.Text);

                    txtEndereco.Text = resposta.end;
                    txtCidade.Text   = resposta.cidade;
                    cboEstado.Text   = resposta.uf;
                }
                catch (Exception)
                {
                    frmAlert tela = new frmAlert();
                    tela.LoadScreen("O CEP não foi encontrado");
                    tela.ShowDialog();
                }
            }
        }
Ejemplo n.º 25
0
        private void txtPass_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    LoginBusiness business = new LoginBusiness();
                    string        user     = txtUser.Text;
                    string        pass     = txtPass.Text;

                    LoginDTO usuario = business.Logar(user, pass);


                    if (usuario != null)
                    {
                        UserSession.UsuarioLogado = usuario;

                        Menu tela = new Menu();
                        tela.Show();
                        this.Close();
                    }
                    else
                    {
                        string msg = "Nome de usuário ou senha incorretos.";

                        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();
                }
            }
        }
Ejemplo n.º 26
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                LoginDTO dto = new LoginDTO();
                dto.Usuario             = txtUsuario.Text;
                dto.Funcionario         = txtNome.Text;
                dto.Senha               = txtSenha.Text;
                dto.Email               = txtEmail.Text;
                dto.PermissaoAdm        = ckbAdm.Checked;
                dto.PermissaoCadastros  = ckbCadastros.Checked;
                dto.PermissaoCaixa      = ckbCaixa.Checked;
                dto.PermissaoEstoque    = ckbEstoque.Checked;
                dto.PermissaoFinanceiro = ckbFinanceiro.Checked;

                LoginBusiness business = new LoginBusiness();
                business.Salvar(dto);

                frmMessage tela = new frmMessage();
                tela.LoadScreen("Cadastro efetuado com sucesso.");
                tela.ShowDialog();
            }
            catch (MySqlException ex)
            {
                if (ex.Number == 1062)
                {
                    frmAlert tela = new frmAlert();
                    tela.LoadScreen("O nome de usuário já existe.");
                    tela.ShowDialog();
                }
            }
            catch (Exception)
            {
                frmException tela = new frmException();
                tela.LoadScreen("Ocorreu um erro.\nConsulte o administrador do sistema.");
                tela.ShowDialog();
            }
        }
        private void mkbCEP_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                try
                {
                    var ws       = new WSCorreios.AtendeClienteClient();
                    var resposta = ws.consultaCEP(mkbCEP.Text);

                    txtEndereco.Text = resposta.end;
                    txtCidade.Text   = resposta.cidade;
                    cboUF.Text       = resposta.uf;
                }
                catch (Exception)
                {
                    string msg = "Não foi possível encontrar o CEP";

                    frmAlert tela = new frmAlert();
                    tela.LoadScreen(msg);
                    tela.ShowDialog();
                }
            }
        }
Ejemplo n.º 28
0
        private void lblRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                LoginBusiness business = new LoginBusiness();
                string        user     = txtUser.Text;
                string        pass     = txtPass.Text;

                LoginDTO usuario = business.Logar(user, pass);


                if (usuario != null)
                {
                    UserSession.UsuarioLogado = usuario;

                    frmCadastrarLogin tela = new frmCadastrarLogin();
                    tela.Show();
                    this.Close();
                }
                else
                {
                    string msg = "É preciso ser um administrador do sistema para acessar o cadastro de usuários.";

                    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();
            }
        }
Ejemplo n.º 29
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                ProdutoDTO dto = new ProdutoDTO();
                dto.Id = this.produto.Id;

                dto.Nome      = txtNome.Text;
                dto.Marca     = txtMarca.Text;
                dto.Descricao = txtDesc.Text;
                dto.Preco     = nudPreco.Value;

                ProdutoBusiness business = new ProdutoBusiness();
                business.Alterar(dto);

                string msg = "Produto Alterado com sucesso!";

                frmMessage tela = new frmMessage();
                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();
            }
        }
Ejemplo n.º 30
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                AnimalDTO animal = cboAnimal.SelectedItem as AnimalDTO;

                ServicoDTO dto = new ServicoDTO();
                dto.IdAnimal = animal.Id;
                dto.Data     = mkbData.Text;
                dto.Servico  = txtDescricao.Text;
                dto.Valor    = nudValor.Value;

                ServicoBusiness buss = new ServicoBusiness();
                int             pk   = buss.Salvar(dto, itemAdd.ToList());

                string msg = "Serviço salvo concluido com sucesso!";

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

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