Exemplo n.º 1
0
        public void btnOk_Click(object sender, EventArgs e)
        {
            //põe asterisco nos campos em branco
            lblAstID.Text = Utilidades.PreencherCampos(txtID.Text);
            lblAstNome.Text = Utilidades.PreencherCampos(txtNome.Text);
            lblAstIdentidade.Text = Utilidades.PreencherCampos(txtIdentidade.Text);
            lblAstDataNasc.Text = Utilidades.PreencherCampos(txtDataNasc.Text);
            lblAstCpf.Text = Utilidades.PreencherCampos(txtCpf.Text);
            lblAstTipoOperador.Text = Utilidades.PreencherCamposVF(rbtnGerente.Checked, rbtnOpCadastro.Checked, rbtnOpCredito.Checked, rbtnOpEntradaRU.Checked);
            lblAstRua.Text = Utilidades.PreencherCampos(txtRua.Text);
            lblAstNum.Text = Utilidades.PreencherCampos(txtN.Text);
            lblAstBairro.Text = Utilidades.PreencherCampos(txtBairro.Text);
            lblAstCidade.Text = Utilidades.PreencherCampos(txtCidade.Text);
            lblAstUf.Text = Utilidades.PreencherCampos(cbxUF.Text);
            lblAstCep.Text = Utilidades.PreencherCampos(txtCep.Text);
            lblAstFone.Text = Utilidades.PreencherCampos(txtFone.Text);
            lblAstEmail.Text = Utilidades.PreencherCampos(txtEmail.Text);

            //manda de data de nascimento, fone
            Utilidades.DataNasc = this.txtDataNasc.Text;
            Utilidades.cep = this.txtCep.Text;
            Utilidades.fone = this.txtFone.Text;

            //NOVO CADASTRO
            if (Utilidades.ControleDeTela == "novoOp")
            {
                lblAstSenha.Text = Utilidades.PreencherCampos(txtSenha.Text);
                lblAstConfirmeSenha.Text = Utilidades.PreencherCampos(txtConfirmeSenha.Text);

                string cpfSpace = this.txtCpf.Text.ToString().Replace(" ", ".");
                string cpfHifen = cpfSpace.Replace("-", ".");
                Utilidades.Cpf = cpfHifen.Replace(".", "");

                //função para validar todos os campos
                Utilidades.ValidaCampos();
                if (Utilidades.ControleDeValidaCampos == "N")
                {
                    Utilidades.ControleDeValidaCampos = "";
                    Utilidades.ErrDataNasc = "";
                    Utilidades.ErrCep = "";
                    Utilidades.ErrFone = "";
                }

                //CONTROLE DE CAMPOS VAZIOS
                else if (lblAstBairro.Text == "*" || lblAstCep.Text == "*" || lblAstCidade.Text == "*" || lblAstConfirmeSenha.Text == "*" || lblAstCpf.Text == "*" || lblAstTipoOperador.Text == "*" || lblAstDataNasc.Text == "*" || lblAstFone.Text == "*" || lblAstEmail.Text == "*" || lblAstID.Text == "*" || lblAstIdentidade.Text == "*" || lblAstNome.Text == "*" || lblAstNum.Text == "*" || lblAstRua.Text == "*" || lblAstSenha.Text == "*" || lblAstUf.Text == "*")
                {
                    MessageBox.Show("Preencha os campos em asterisco!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                //CONTROLE DA SENHA
                else if (txtSenha.Text != txtConfirmeSenha.Text)
                {
                    MessageBox.Show("Senhas Diferentes!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                else
                {
                    using (CheffTogaEntities context = new CheffTogaEntities())
                    {
                        Usuario user = new Usuario();
                        user.Status = cbxStatus.Text;
                        user.RG = this.txtIdentidade.Text;
                        user.Nome = this.txtNome.Text;
                        user.Logradouro = this.txtRua.Text;
                        user.CPF = Utilidades.Cpf;
                        user.Id_TipoUsuario = Utilidades.SelecionaUsuario(rbtnGerente.Checked,rbtnOpCadastro.Checked,rbtnOpCredito.Checked,rbtnOpEntradaRU.Checked);
                        user.Bolsista = this.rbtnSim.Checked;
                        user.DataNascimento = this.txtDataNasc.Text;
                        var linq = (from i in context.Usuario select i.Id_Usuario).Max();
                        user.Id_Usuario = linq + 1;
                        user.Id_Periodo = 0;
                        user.Id_Curso = 0;
                        user.Id_Card = Utilidades.GerarIdCard(linq + 1);
                        user.Numero = this.txtN.Text;
                        user.Bairro = this.txtBairro.Text;
                        user.Cidade = this.txtCidade.Text;
                        user.CEP = this.txtCep.Text;
                        user.Fone = this.txtFone.Text;
                        user.E_mail = this.txtEmail.Text;
                        user.Senha = this.txtSenha.Text;
                        user.UF = this.cbxUF.SelectedItem.ToString();
                        user.Saldo = 0;
                        user.Bandeja_Em_Espera = false;
                        user.Data_Refeicao = DateTime.Now.ToShortDateString();
                        user.Almoco = false;
                        user.Jantar = false;
                        user.Foto = Utilidades.pasta_fotos(Utilidades.GerarIdCard(linq + 1));
                        context.AddObject("Usuario", user);
                        context.SaveChanges();

                        Utilidades.Movimentacoes(user.Id_Card, Utilidades.Cpf, txtNome.Text, "Novo Cadastro de Operador", "Todos", "-", 0); //registrador de movimentacões
                        MessageBox.Show("Cadastro realizado com sucesso!", "Validação", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        Close();
                    }
                }
            }

            //ALTERAR CADASTRO
            else
            {
                string cpfSpace = this.txtCpf.Text.ToString().Replace(" ", ".");
                string cpfHifen = cpfSpace.Replace("-", ".");
                Utilidades.CpfNovo = cpfHifen.Replace(".", "");

                //função para validar todos os campos
                Utilidades.ValidaCampos();
                if (Utilidades.ControleDeValidaCampos == "N")
                {
                    Utilidades.ControleDeValidaCampos = "";
                    Utilidades.ErrDataNasc = "";
                    Utilidades.ErrCep = "";
                    Utilidades.ErrFone = "";
                }

                //CONTROLE DE CAMPOS VAZIOS
                else if (lblAstBairro.Text == "*" || lblAstCep.Text == "*" || lblAstCidade.Text == "*" || lblAstConfirmeSenha.Text == "*" || lblAstCpf.Text == "*" || lblAstTipoOperador.Text == "*" || lblAstDataNasc.Text == "*" || lblAstFone.Text == "*" || lblAstEmail.Text == "*" || lblAstID.Text == "*" || lblAstIdentidade.Text == "*" || lblAstNome.Text == "*" || lblAstNum.Text == "*" || lblAstRua.Text == "*" || lblAstSenha.Text == "*" || lblAstUf.Text == "*")
                {
                    MessageBox.Show("Preencha os campos em asterisco!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                //CONTROLE DA SENHA
                else if (txtSenha.Text != txtConfirmeSenha.Text)
                {
                    MessageBox.Show("Senhas Diferentes!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                else
                {
                    Utilidades.status = cbxStatus.Text;
                    Utilidades.nome = txtNome.Text;
                    Utilidades.identidade = txtIdentidade.Text;
                    Utilidades.rua = txtRua.Text;
                    Utilidades.numero = txtN.Text;
                    Utilidades.bairro = txtBairro.Text;
                    Utilidades.cidade = txtCidade.Text;
                    Utilidades.uf = cbxUF.SelectedItem.ToString();
                    Utilidades.cep = txtCep.Text;
                    Utilidades.fone = txtFone.Text;
                    Utilidades.email = txtEmail.Text;
                    Utilidades.bolsista = rbtnSim.Checked;
                    Utilidades.TipoUser = Utilidades.SelecionaUsuario(rbtnGerente.Checked, rbtnOpCadastro.Checked, rbtnOpCredito.Checked, rbtnOpEntradaRU.Checked);
                    Utilidades.IDCurso = 0;
                    Utilidades.IDPeriodo = 0;
                    Utilidades.DataNasc = txtDataNasc.Text;

                    //Verificar campos alterados, alterar dados, informar movimentações
                    Utilidades.AltCampos();
                    Utilidades.AlterarDados();
                    Utilidades.Movimentacoes(Utilidades.IdCard, Utilidades.Cpf, txtNome.Text, "Alterar Cadastro de Operador", Utilidades.modificacao, "-", 0); //registrador de movimentacões
                    Close();
                }
            }
        }
Exemplo n.º 2
0
        public static Boolean VerRefeicao()
        {
            Usuario user = new Usuario();

            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var DataRef = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Data_Refeicao).ToList();
                DateTime data_refeicao = DateTime.Parse(DataRef[0].ToString());

                var VerAlmoco = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Almoco).ToList();
                bool ver_almoco = bool.Parse(VerAlmoco[0].ToString());

                var VerJantar = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Jantar).ToList();
                bool ver_jantar = bool.Parse(VerJantar[0].ToString());

                if (ControleRefeicao == "almoco")
                {
                    if ((data_refeicao.Date < DateTime.Now.Date) || (ver_almoco == false) || (data_refeicao == null))
                    {
                        retorno = false;
                    }
                    else
                    {
                        MessageBox.Show("Cartão já utilizado para Almoço!", "Não Autorizado!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        retorno = true;
                    }
                }

                else if (ControleRefeicao == "jantar")
                {
                    if ((data_refeicao.Date < DateTime.Now.Date) || (ver_jantar == false) || (data_refeicao == null))
                    {
                        retorno = false;
                    }
                    else
                    {
                        MessageBox.Show("Cartão já utilizado para o Jantar!", "Não Autorizado!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        retorno = true;
                    }
                }
            }

            return retorno;
        }
Exemplo n.º 3
0
        public static Boolean VerStatus()
        {
            Usuario user = new Usuario();

            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var verstatus = (from i in context.Usuario
                               where i.CPF == Cpf
                               select i.Status).ToList();
                string status = verstatus[0];

                if (status == "Desbloqueado") return true;
                else return false;
            }
        }
Exemplo n.º 4
0
        public static String Saldo()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                Usuario card = new Usuario();

                var meusaldo = (from i in context.Usuario
                            where i.CPF == Utilidades.Cpf
                            select i.Saldo).ToList();

                var SALDO = meusaldo[0];

                return SALDO.ToString();
            }
        }