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();
                }
            }
        }
Example #2
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);
            }
        }