private void btnAutorizar_Click(object sender, EventArgs e)
        {
            string hora = DateTime.Now.ToShortTimeString();
            string hora1 = hora[0].ToString() + hora[1].ToString();
            int h = int.Parse(hora1);
            string data = DateTime.Now.ToShortDateString();

            if ((h>=17) && (h<=19))
            {
                Utilidades.ValorASerCobrado = float.Parse("2,6");
                if (Utilidades.Debitar() == true)
                {
                    using (CheffTogaEntities context = new CheffTogaEntities())
                    {
                        string strSQL = "UPDATE Usuario SET Jantar = '" + true + "' , Data_Refeicao= '" + data + "' WHERE CPF= '" + Utilidades.Cpf + "'";

                        context.ExecuteStoreCommand(strSQL);

                        Utilidades.Bandeja_Espera();

                        MessageBox.Show("Autorizado!", "Entrada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }

                else MessageBox.Show("Não Autorizado! Crédito Insuficiente!", "Entrada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                Close();
            }
            else if ((h >= 11) && (h <= 14))
            {
                Utilidades.ValorASerCobrado = float.Parse("3");
                if (Utilidades.Debitar() == true)
                {
                    using (CheffTogaEntities context = new CheffTogaEntities())
                    {
                        string strSQL = "UPDATE Usuario SET Almoco = '" + true + "' , Data_Refeicao= '" + data + "' WHERE CPF= '" + Utilidades.Cpf + "'";

                        context.ExecuteStoreCommand(strSQL);

                        Utilidades.Bandeja_Espera();

                        MessageBox.Show("Autorizado!", "Entrada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }
                }

                else MessageBox.Show("Não Autorizado! Crédito Insuficiente!", "Entrada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                Close();
            }

            else
            {
                MessageBox.Show("Não Autorizado! Fora do horário de refeição!", "Entrada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
            }

             // tornar o campo "em_espera" do DB com valor "TRUE" ==>> autorização da bandeja (depois de passar na bandeja o valor volta pra "FALSE")
        }
Beispiel #2
0
        public static void AlterarDados()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var linq = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Id_Usuario).ToList();

                id = linq[0];

                string strSQL = "UPDATE Usuario SET Nome ='" + nome.Replace("'", "''") + "', Status= '" + status + "', Id_TipoUsuario= '" + TipoUser +
                                "', RG='" + identidade + "', Logradouro='" + rua + "', Numero='" + numero + "', Bairro='" + bairro + "', Cidade='" + cidade +
                                "',CPF='" + CpfNovo + "', UF='" + uf + "', CEP='" + cep + "', Fone='" + fone + "', E_mail='" + email + "', Bolsista='" + bolsista +
                                "', DataNascimento='" + DataNasc + "', Id_Curso=" + IDCurso + ", Id_Periodo= " + IDPeriodo + " WHERE Id_Usuario=" + id;

                context.ExecuteStoreCommand(strSQL);

                Cpf = CpfNovo;

                MessageBox.Show("Cadastro alterado com sucesso!", "Validação", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
        private void btnDebitar_Click(object sender, EventArgs e)
        {
            lblAstObs.Text = Utilidades.PreencherCampos(txtObs.Text);

            if (lblAstObs.Text == "*") MessageBox.Show("Informe o motivo da retirada de crédito!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            else
            {
                using (CheffTogaEntities context = new CheffTogaEntities())
                {
                    var SaldoDB = (from i in context.Usuario
                                   where i.CPF == Utilidades.Cpf
                                   select i.Saldo).ToList();

                    float saldo = float.Parse(SaldoDB[0].ToString());

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

                    int id = listaid[0];

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

                    string nome = listanome[0];

                    if ((saldo - float.Parse(txtValorASerCreditado.Text)) < 0)
                    {
                        MessageBox.Show("NÃO AUTORIZADO! O valor a ser debitado é maior que o Saldo existente.", "Autorização!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                    else if (MessageBox.Show("Deseja realmente debitar R$ " + txtValorASerCreditado.Text + " ao aluno " + txtNome.Text + "?", "Confirmação!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        string ValorSpace = this.txtValorASerCreditado.Text.Replace(" ", "");
                        Utilidades.debito = float.Parse(ValorSpace);

                        Utilidades.DebitarEstorno();

                        Utilidades.Movimentacoes(id, Utilidades.Cpf, nome, "Crédito Retirado", "-", txtObs.Text, Utilidades.debito); //registrador de movimentacões

                        MessageBox.Show("O novo saldo do aluno " + txtNome.Text + " é R$ " + Utilidades.saldo + "!", "Operação realizada com sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        this.Close();

                    }
                }
            }
        }
Beispiel #4
0
        public void btnEntrar_Click(object sender, EventArgs e)
        {
            string cpfSpace = this.mtbLogin.Text.Replace(" ", ".");
            string cpfHifen = cpfSpace.Replace("-", ".");
            Utilidades.CpfOperador = cpfHifen.Replace(".", "");

            if (Utilidades.validaCPF(Utilidades.CpfOperador))
            {
                using (CheffTogaEntities context = new CheffTogaEntities())
                {

                    var linq = (from i in context.Usuario
                                where i.CPF == Utilidades.CpfOperador && i.Senha == this.txtSenha.Text
                                select i.Id_TipoUsuario).ToList();

                    if (linq.ToList().Count() == 1)
                    {
                        Utilidades.Cpf = Utilidades.CpfOperador; //para poder verificar status ao logar
                        if (Utilidades.VerStatus() == true)
                        {
                            //Guardar nome do operador; mostrá-lo nas telas
                            var lista = (from i in context.Usuario
                                         where i.CPF == Utilidades.CpfOperador && i.Senha == this.txtSenha.Text
                                         select i.Nome).ToList();
                            Utilidades.NomeOperador = lista[0];
                            Utilidades.NomeLogin = Utilidades.NomeOperador;

                            //guardar id do Operador
                            var listaid = (from i in context.Usuario
                                           where i.CPF == Utilidades.CpfOperador && i.Senha == this.txtSenha.Text
                                           select i.Id_Card).ToList();
                            Utilidades.IDOperador = listaid[0];

                            Utilidades.Movimentacoes(0, "-", "-", "Login", "-", "-", 0); //registrador de movimentacões

                            if ((linq.ToList().Count() == 1) && (linq[0] == 1))
                            {
                                //abrir pagina dos alunos
                                lblErroLogar.Text = "Não há acesso para Alunos neste Sistema!";
                            }

                            else if ((linq.ToList().Count() == 1) && (linq[0] == 2))
                            {
                                fCadastroGerenciar form = new fCadastroGerenciar();
                                form.Show();
                                this.Hide();
                            }

                            else if ((linq.ToList().Count() == 1) && (linq[0] == 3))
                            {
                                fCreditoGerenciar form = new fCreditoGerenciar();
                                form.Show();
                                this.Hide();
                            }

                            else if ((linq.ToList().Count() == 1) && (linq[0] == 4))
                            {
                                fEntradaRuGerenciar form = new fEntradaRuGerenciar();
                                form.Show();
                                this.Hide();
                            }

                            else if ((linq.ToList().Count() == 1) && (linq[0] == 5))
                            {
                                fGerenteGerenciar form = new fGerenteGerenciar();
                                form.Show();
                                this.Hide();
                            }

                            else if ((linq.ToList().Count() == 1) && (linq[0] == 6))
                            {
                                //abrir pagina dos Developers
                            }
                        }
                        else MessageBox.Show("Usuário Bloqueado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }

                    else
                    {
                        lblErroLogar.Text = "Usuário ou Senha incorretos!";
                    }
                }

            }

            else
            {
                lblErroLogar.Text = "Usuário ou Senha incorretos!";
            }
        }
Beispiel #5
0
 public static String FuncDataNasc()
 {
     using (CheffTogaEntities context = new CheffTogaEntities())
     {
         var item = (from i in context.Usuario
                     where i.CPF == Cpf
                     select i.DataNascimento).ToList();
         string DataNascSpace = item[0].Replace(" ","");
         DataNasc = DataNascSpace.Replace("/", "");
         return DataNasc;
     }
 }
Beispiel #6
0
        public static void ExcluirCadastro()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {

                var linq = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Id_Usuario).ToList();
                id = linq[0];

                var linqIdCard = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Id_Card).ToList();
                IdCard = linqIdCard[0];

                var linqnome = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Nome).ToList();
                string name = linqnome[0];

                var linqTipo = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Id_TipoUsuario).ToList();
                int TipoUser = linqTipo[0];

                if (TipoUser == 1) Utilidades.Movimentacoes(IdCard, Utilidades.Cpf, name, "Exclusão de Cadastro de Aluno", "Todos", "-", 0); //registrador de movimentacões
                else Utilidades.Movimentacoes(IdCard, Utilidades.Cpf, name, "Exclusão de Cadastro de Operador", "Todos", "-", 0); //registrador de movimentacões

                if (IdCard != IDOperador)
                {
                    string strSQLCartao = "DELETE FROM Usuario WHERE Id_Usuario=" + id + "";
                    context.ExecuteStoreCommand(strSQLCartao);
                    MessageBox.Show("Cadastro excluído com sucesso!", "Validação", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else MessageBox.Show("Operação não Autorizada! Usuário Conectado ao Sistema.", "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #7
0
        public static Boolean DuploCPF(String cpfEnviado)
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var list = (from i in context.Usuario
                            where i.CPF == cpfEnviado
                            select cpfEnviado).ToList();

                if ((list.ToList().Count() > 0) && (Cpf != CpfNovo))
                {
                    return true;
                }

                else return false;
            }
        }
Beispiel #8
0
        public static Boolean Debitar()
        {
            if (Bolsista() == false)
            {
                using (CheffTogaEntities context = new CheffTogaEntities())
                {

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

                    saldo = float.Parse(SaldoAtual[0].ToString());

                    var listid = (from i in context.Usuario
                                      where i.CPF == Cpf
                                      select i.Id_Card).ToList();

                    IdCard = listid[0];

                    var listnome = (from i in context.Usuario
                                  where i.CPF == Cpf
                                  select i.Nome).ToList();

                    string nomebolsa = listnome[0];

                    string StrResultado = Math.Round((saldo - ValorASerCobrado), 2).ToString();

                    float resultado = float.Parse(StrResultado);

                    if (ValorASerCobrado <= saldo)
                    {
                        string desconto = resultado.ToString().Replace(",", ".");

                        string strSQL = "UPDATE Usuario SET Saldo =" + desconto + " WHERE CPF='" + Cpf + "'";

                        context.ExecuteStoreCommand(strSQL);

                        var NovoSaldo = (from j in context.Usuario
                                         where j.CPF == Cpf
                                         select j.Saldo).ToList();

                        saldo = float.Parse(NovoSaldo[0].ToString());

                        Movimentacoes(IdCard, Utilidades.Cpf, nomebolsa, "Entrada de Aluno com Desconto", "-", "-", ValorASerCobrado); //registrador de movimentacões

                        return true;
                    }

                    else return false;
                }
            }
            else
            {
                using (CheffTogaEntities context = new CheffTogaEntities())
                {
                    var listnome = (from i in context.Usuario
                                    where i.CPF == Cpf
                                    select i.Nome).ToList();

                    string nomebolsa = listnome[0];

                    if (ControleDeTela == "autorizarporcpf")
                    {
                        ALUNOouOPERADOR = "ALUNO";
                    }
                    else ALUNOouOPERADOR = "OPERADOR";

                    Movimentacoes(IdCard, Utilidades.Cpf, nomebolsa, "Entrada de " + ALUNOouOPERADOR + " BOLSISTA" , "-", "-", 0); //registrador de movimentacões

                    MessageBox.Show("Entrada sem desconto! " + ALUNOouOPERADOR + " BOLSISTA!", "Entrada", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return true;
                }
            }
        }
Beispiel #9
0
        public static void PegarBandeja()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var listData = (from i in context.Usuario
                                where i.CPF == Cpf
                                select i.Data_Refeicao).ToList();
                DateTime dataRef = DateTime.Parse(listData[0]);

                var listBandeja = (from i in context.Usuario
                                where i.CPF == Cpf
                                select i.Bandeja_Em_Espera).ToList();
                bool bandejaEspera = bool.Parse(listBandeja[0].ToString());

                if ((dataRef.Date == DateTime.Now.Date) && (bandejaEspera == true))
                {
                    string strSQL = "UPDATE Usuario SET Bandeja_Em_Espera ='" + false + "' WHERE CPF='" + Cpf + "'";
                    context.ExecuteStoreCommand(strSQL);
                    MessageBox.Show("Autorizado!", "Bandeja", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }

                else MessageBox.Show("Não Autorizado! Ou já foi pego bandeja ou pagamento não efetuado", "Bandeja", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
0
 public static void Bandeja_Espera()
 {
     using (CheffTogaEntities context = new CheffTogaEntities())
     {
         string strSQL = "UPDATE Usuario SET Bandeja_Em_Espera ='" + true + "' WHERE CPF='" + Cpf + "'";
         context.ExecuteStoreCommand(strSQL);
     }
 }
Beispiel #11
0
        public static void Movimentacoes(int IdAluno, string CpfAluno, string NomeAluno, string TipoMovimentacao, string Campos, string Observacao, float valor)
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                Movimentacao mov = new Movimentacao();
                var linq = (from i in context.Movimentacao select i.Id_Movimentacao).Max();
                mov.Id_Movimentacao = linq + 1;
                mov.Id_Operador = IDOperador;
                mov.Cpf_Operador = CpfOperador;
                mov.Nome_Operador = NomeOperador;
                mov.Id_Aluno = IdAluno;
                mov.Cpf_Aluno = CpfAluno;
                mov.Nome_Aluno = NomeAluno;
                mov.Data_Movimentacao = DateTime.Now.ToShortDateString();
                mov.Hora_Movimentacao = DateTime.Now.ToShortTimeString();
                mov.Tipo_Movimentacao = TipoMovimentacao;
                mov.Campos = Campos;
                mov.Observacao = Observacao;
                context.AddObject("Movimentacao", mov);
                context.SaveChanges();

                string strValor = valor.ToString().Replace(",", ".");
                int locMov = linq + 1;

                string SQL = "UPDATE Movimentacao SET Valor=" + strValor + " WHERE Id_Movimentacao=" + locMov;

                context.ExecuteStoreCommand(SQL);
            }
        }
Beispiel #12
0
        public static void ModStatusOp(string estado, string obs)
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                string SQL = "UPDATE Usuario SET Status='" + estado + "' WHERE ((Id_TipoUsuario>1) and (Id_TipoUsuario<5))";
                context.ExecuteStoreCommand(SQL);
                Movimentacoes(0, "-", "-", "Status de todos os Operadores " + estado + "s", "-", obs, 0); //registrador de movimentacões
            }

            MessageBox.Show("Operação realizada com sucesso! Todos os Operadores foram " + estado + "s!", "Validação", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void btnCreditar_Click(object sender, EventArgs e)
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var SaldoDB = (from i in context.Usuario
                            where i.CPF == Utilidades.Cpf
                            select i.Saldo).ToList();

                float saldo = float.Parse(SaldoDB[0].ToString());

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

                int id = listaid[0];

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

                string nome = listanome[0];

                if ((saldo + float.Parse(txtValorASerCreditado.Text)) > 999)
                {
                    MessageBox.Show("NÃO AUTORIZADO! O saldo não pode exceder R$ 999,00", "Autorização!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                else if (MessageBox.Show("Deseja realmente creditar R$ " + txtValorASerCreditado.Text + " ao aluno " + txtNome.Text + "?", "Confirmação!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    string ValorSpace = this.txtValorASerCreditado.Text.Replace(" ", "");
                    Utilidades.credito = float.Parse(ValorSpace);

                    Utilidades.Creditar();

                    Utilidades.Movimentacoes(id, Utilidades.Cpf, nome, "Crédito Inserido", "-", "-", Utilidades.credito); //registrador de movimentacões

                    MessageBox.Show("O novo saldo do aluno " + txtNome.Text + " é R$ " + Utilidades.saldo + "!", "Operação realizada com sucesso!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.Close();

                }
            }
        }
Beispiel #14
0
        public static String Cep()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var item = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.CEP).ToList();
                string CepPonto = item[0].Replace(".", "");
                string CepDigito = CepPonto.Replace("-", "");
                cep = CepDigito.Replace(" ", "");

                return cep;
            }
        }
Beispiel #15
0
        public static String Periodo()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var IdPeriodo = (from i in context.Usuario
                               where i.CPF == Cpf
                               select i.Id_Periodo).ToList();
                IDPeriodo = int.Parse(IdPeriodo[0].ToString());

                var Periodo = (from i in context.Periodo
                             where i.Id_Periodo == IDPeriodo
                             select i.Descricao_Periodo).ToList();
                string periodo = Periodo[0];

                strIdPeriodo = IDPeriodo.ToString(); //modificação de campos

                return periodo;
            }
        }
Beispiel #16
0
        public static String Curso()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var IdCurso = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Id_Curso).ToList();
                IDCurso = int.Parse(IdCurso[0].ToString());

                var Curso = (from i in context.Curso
                             where i.IdCurso == IDCurso
                             select i.DescricaoCurso).ToList();
                string curso = Curso[0];

                strIdCurso = IDCurso.ToString(); //modificação de campos

                return curso;
            }
        }
Beispiel #17
0
 public static Boolean Bolsista()
 {
     using (CheffTogaEntities context = new CheffTogaEntities())
     {
         var item = (from i in context.Usuario
                     where i.CPF == Cpf
                     select i.Bolsista).ToList();
         return bool.Parse(item[0].ToString());
     }
 }
Beispiel #18
0
        public static void DebitarEstorno()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {

                var linq = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Id_Usuario).ToList();

                id = linq[0];

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

                saldo = float.Parse(SaldoAtual[0].ToString());

                string StrResultado = Math.Round((saldo - debito), 2).ToString();

                float resultado = float.Parse(StrResultado);

                string strDebito = resultado.ToString().Replace(",", ".");

                string strSQL = "UPDATE Usuario SET Saldo =" + strDebito + " WHERE Id_Usuario=" + id;

                context.ExecuteStoreCommand(strSQL);

                var NovoSaldo = (from j in context.Usuario
                                 where j.CPF == Cpf
                                 select j.Saldo).ToList();

                saldo = float.Parse(NovoSaldo[0].ToString());

            }
        }
Beispiel #19
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();
            }
        }
Beispiel #20
0
        public static Boolean ErrOperador(string cpf)
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var linq = (from i in context.Usuario
                            where i.CPF == cpf
                            select i.Id_TipoUsuario).ToList();

                if ((linq.ToList().Count() == 1) && (linq[0] == 1))
                {
                    return true;
                }
                else return false;

            }
        }
Beispiel #21
0
        public static Int32 TipoOperador()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {

                var item = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Id_TipoUsuario).ToList();
                Int32 tipo = int.Parse(item[0].ToString());

                return tipo;
            }
        }
Beispiel #22
0
 public static String Foto()
 {
     using (CheffTogaEntities context = new CheffTogaEntities())
     {
         var item = (from i in context.Usuario
                     where i.CPF == Cpf
                     select i.Foto).ToList();
         return item[0];
     }
 }
Beispiel #23
0
        public static void CarregaCombobox(ComboBox cbxCurso, ComboBox cbxPeriodo)
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                //Filtro de Cursos apartir do DB:
                cbxCurso.DataSource = from i in context.Curso select i;
                cbxCurso.ValueMember = "IdCurso";
                cbxCurso.DisplayMember = "DescricaoCurso";

                //Filtro de Periodo apartir do DB:
                cbxPeriodo.DataSource = from i in context.Periodo select i;
                cbxPeriodo.ValueMember = "Id_Periodo";
                cbxPeriodo.DisplayMember = "Descricao_Periodo";

            }
        }
Beispiel #24
0
        public static String FuncFone()
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var item = (from i in context.Usuario
                            where i.CPF == Cpf
                            select i.Fone).ToList();
                string foneParAberto = item[0].Replace("(","");
                string foneParFechado = foneParAberto.Replace(")", "");
                string foneDigito = foneParFechado.Replace("-", "");
                fone = foneDigito.Replace(" ", "");

                return fone;
            }
        }
Beispiel #25
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;
        }
Beispiel #26
0
        public static void GerarRelatorioOp(Document doc, PdfPTable tabela, PdfPCell celula, String item)
        {
            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var idmov = (from i in context.Movimentacao
                             where (i.Cpf_Operador == item)
                             select i.Id_Movimentacao).ToList();

                var idop = (from i in context.Movimentacao
                            where (i.Cpf_Operador == item)
                            select i.Id_Operador).ToList();

                var cpfop = (from i in context.Movimentacao
                             where (i.Cpf_Operador == item)
                             select i.Cpf_Operador).ToList();

                var nomeop = (from i in context.Movimentacao
                              where (i.Cpf_Operador == item)
                              select i.Nome_Operador).ToList();

                var idal = (from i in context.Movimentacao
                            where (i.Cpf_Operador == item)
                            select i.Id_Aluno).ToList();

                var cpfal = (from i in context.Movimentacao
                             where (i.Cpf_Operador == item)
                             select i.Cpf_Aluno).ToList();

                var nomeal = (from i in context.Movimentacao
                              where (i.Cpf_Operador == item)
                              select i.Nome_Aluno).ToList();

                var datamov = (from i in context.Movimentacao
                               where (i.Cpf_Operador == item)
                               select i.Data_Movimentacao).ToList();

                var horamov = (from i in context.Movimentacao
                               where (i.Cpf_Operador == item)
                               select i.Hora_Movimentacao).ToList();

                var tipomov = (from i in context.Movimentacao
                               where (i.Cpf_Operador == item)
                               select i.Tipo_Movimentacao).ToList();

                var campos = (from i in context.Movimentacao
                              where (i.Cpf_Operador == item)
                              select i.Campos).ToList();

                var obs = (from i in context.Movimentacao
                           where (i.Cpf_Operador == item)
                           select i.Observacao).ToList();

                var valor = (from i in context.Movimentacao
                             where (i.Cpf_Operador == item)
                             select i.Valor).ToList();

                Int32 j = 0;
                Int32 total = idmov.Count();
                while (j < total)
                {
                    string stridmov = idmov[j].ToString();
                    string stridop = idop[j].ToString();
                    string strcpfop = cpfop[j].ToString();
                    string strnomeop = nomeop[j].ToString();
                    string stridal = idal[j].ToString();
                    string strcpfal = cpfal[j].ToString();
                    string strnomeal = nomeal[j].ToString();
                    string strdatamov = datamov[j].ToString();
                    string strhoramov = horamov[j].ToString();
                    string strtipomov = tipomov[j].ToString();
                    string strcampos = campos[j].ToString();
                    string strobs = obs[j].ToString();
                    string strvalor = valor[j].ToString();

                    MontaInicioRelatorio(tabela, celula, stridmov);
                    MontaInicioRelatorio(tabela, celula, stridop);
                    MontaInicioRelatorio(tabela, celula, strcpfop);
                    MontaInicioRelatorio(tabela, celula, strnomeop);
                    MontaInicioRelatorio(tabela, celula, stridal);
                    MontaInicioRelatorio(tabela, celula, strcpfal);
                    MontaInicioRelatorio(tabela, celula, strnomeal);
                    MontaInicioRelatorio(tabela, celula, strdatamov);
                    MontaInicioRelatorio(tabela, celula, strhoramov);
                    MontaInicioRelatorio(tabela, celula, strtipomov);
                    MontaInicioRelatorio(tabela, celula, strcampos);
                    MontaInicioRelatorio(tabela, celula, strobs);
                    MontaInicioRelatorio(tabela, celula, strvalor);

                    j += 1;
                }
            }
        }
Beispiel #27
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;
            }
        }
        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();
                }
            }
        }
Beispiel #29
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            string cpfSpace = this.txtCPF.Text.Replace(" ", ".");
            string cpfHifen = cpfSpace.Replace("-", ".");
            Utilidades.Cpf = cpfHifen.Replace(".", "");

            using (CheffTogaEntities context = new CheffTogaEntities())
            {
                var ExistenciaCadastro = (from i in context.Usuario
                                          where i.CPF == Utilidades.Cpf
                                          select Utilidades.Cpf).ToList();

                if (Utilidades.validaCPF(Utilidades.Cpf))
                {

                    if (ExistenciaCadastro.ToList().Count() == 1)
                    {

                        //Operador de Cadastro
                        if (Utilidades.ControleDeTela == "alterar")
                        {
                            if (Utilidades.ErrAluno(Utilidades.Cpf) == false)
                            {
                                fCadastroNovo _fCad;
                                _fCad = new fCadastroNovo();
                                _fCad.Show();
                                Close();
                            }
                            else MessageBox.Show("Este cadastro pertence à um funcionário. Acesse-o através da opção Cadastro -> Operador", "Área Gerencial", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        else if (Utilidades.ControleDeTela == "visualizar")
                        {
                            if (Utilidades.ErrAluno(Utilidades.Cpf) == false)
                            {
                                fCadastroVisualizar _fCad;
                                _fCad = new fCadastroVisualizar();
                                _fCad.Show();
                                Close();
                            }
                            else MessageBox.Show("Este cadastro pertence à um funcionário. Acesse-o através da opção Cadastro -> Operador", "Área Gerencial", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        else if (Utilidades.ControleDeTela == "excluir")
                        {
                            if (Utilidades.ErrAluno(Utilidades.Cpf) == false)
                            {
                                fCadastroVisualizar _fVCad;
                                _fVCad = new fCadastroVisualizar();
                                _fVCad.Show();
                                Close();
                                if (MessageBox.Show("Deseja Realmente Excluir este Cadastro?", "Atenção!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    Utilidades.ExcluirCadastro();

                                    _fVCad.Close();
                                }
                            }
                            else MessageBox.Show("Este cadastro pertence à um funcionário. Acesse-o através da opção Cadastro -> Operador", "Área Gerencial", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                    //Operador de Credito
                        else if (Utilidades.ControleDeTela == "visualizarsaldo")
                        {
                            var listaTipoUser = (from i in context.Usuario
                                                 where i.CPF == Utilidades.Cpf
                                                 select i.Id_TipoUsuario).ToList();
                            int TipoUser = listaTipoUser[0];

                            if (TipoUser != 1)
                            {
                                Utilidades.ControleDeTela = "visualizarsaldoOp";
                            }

                            fCreditoVisualizar _fVCad;
                            _fVCad = new fCreditoVisualizar();
                            _fVCad.Show();
                            Close();
                        }

                        else if (Utilidades.ControleDeTela == "creditar")
                        {
                            var listaTipoUser = (from i in context.Usuario
                                                 where i.CPF == Utilidades.Cpf
                                                 select i.Id_TipoUsuario).ToList();
                            int TipoUser = listaTipoUser[0];

                            if (TipoUser != 1)
                            {
                                Utilidades.ControleDeTela = "creditarOp";
                            }

                            fCreditoCreditar _fVCad;
                            _fVCad = new fCreditoCreditar();
                            _fVCad.Show();
                            Close();
                        }

                        else if (Utilidades.ControleDeTela == "retirarcredito")
                        {
                            var listaTipoUser = (from i in context.Usuario
                                                 where i.CPF == Utilidades.Cpf
                                                 select i.Id_TipoUsuario).ToList();
                            int TipoUser = listaTipoUser[0];

                            if (TipoUser != 1)
                            {
                                Utilidades.ControleDeTela = "retirarcreditoOp";
                            }

                            fCreditoCreditar _fVCad;
                            _fVCad = new fCreditoCreditar();
                            _fVCad.Show();
                            Close();
                        }

                    //Operador de Autorização
                        else if (Utilidades.ControleDeTela == "autorizarporcpf")
                        {
                            if (Utilidades.VerStatus() == true)
                            {
                                var listaTipoUser = (from i in context.Usuario
                                                     where i.CPF == Utilidades.Cpf
                                                     select i.Id_TipoUsuario).ToList();
                                int TipoUser = listaTipoUser[0];

                                if (TipoUser != 1)
                                {
                                    Utilidades.ControleDeTela = "autorizarporcpfOp";
                                }

                                Close();
                                fEntradaRuAutorizar _fVCad;
                                _fVCad = new fEntradaRuAutorizar();
                                _fVCad.Show();
                            }
                            else MessageBox.Show("Usuário Bloqueado!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                        }

                        //Operador de Bandeja
                        else if (Utilidades.ControleDeTela == "pegarbandeja")
                        {
                            Utilidades.PegarBandeja();
                            Close();
                        }

                        //Gerente Cadastro de Operadores ALTERAR
                        else if (Utilidades.ControleDeTela == "alterarOp")
                        {
                            if (Utilidades.ErrOperador(Utilidades.Cpf) == false)
                            {
                                fCadastroNovoOp _fCad;
                                _fCad = new fCadastroNovoOp();
                                _fCad.Show();
                                Close();
                            }
                            else MessageBox.Show("Este cadastro pertence à um aluno. Acesse-o através da opção Cadastro -> Aluno", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        //Gerente Cadastro de Operadores VISUALIZAR
                        else if (Utilidades.ControleDeTela == "visualizarOp")
                        {
                            if (Utilidades.ErrOperador(Utilidades.Cpf) == false)
                            {
                                fCadastroVisualizarOp _fCad;
                                _fCad = new fCadastroVisualizarOp();
                                _fCad.Show();
                                Close();
                            }
                            else MessageBox.Show("Este cadastro pertence à um aluno. Acesse-o através da opção Cadastro -> Aluno", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                        else if (Utilidades.ControleDeTela == "excluirOp")
                        {
                            if (Utilidades.ErrOperador(Utilidades.Cpf) == false)
                            {
                                fCadastroVisualizarOp _fVCad;
                                _fVCad = new fCadastroVisualizarOp();
                                _fVCad.Show();
                                Close();
                                if (MessageBox.Show("Deseja Realmente Excluir este Cadastro?", "Atenção!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    Utilidades.ExcluirCadastro();

                                    _fVCad.Close();
                                }
                            }
                            else MessageBox.Show("Este cadastro pertence à um aluno. Acesse-o através da opção Cadastro -> Aluno", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }

                    }

                    else
                    {
                        MessageBox.Show("CPF não Cadastrado", "Buca de CPF", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }

                else
                {
                    MessageBox.Show("CPF Inválido!", "Validação de CPF", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }