示例#1
0
        private void btAtualizar_Click(object sender, EventArgs e)
        {
            string registro = dtGrid.CurrentRow.Cells[0].Value.ToString();

            using (capdeEntities context = new capdeEntities())
            {
                Pessoa pessoa = context.Pessoas.Where(x => x.Registro == registro).FirstOrDefault();

                if (ckCapacitado.Checked)
                {
                    pessoa.Capacitacao.DataInicio   = Convert.ToDateTime(dateTInicio.Text);
                    pessoa.Capacitacao.DataFim      = Convert.ToDateTime(dateTFim.Text);
                    pessoa.Capacitacao.IsCapacitado = true;

                    if (radioEAD.Checked && cmbCapacitacao.SelectedValue != null)
                    {
                        pessoa.Capacitacao.IsEAD   = true;
                        pessoa.Capacitacao.TurmaId = (int)cmbCapacitacao.SelectedValue;
                    }
                    else if (radioPresencial.Checked && cmbCapacitacao.SelectedValue != null)
                    {
                        pessoa.Capacitacao.RajId = (int)cmbCapacitacao.SelectedValue;
                        pessoa.Capacitacao.IsEAD = false;
                    }
                    else
                    {
                        pessoa.Capacitacao.IsEAD   = null;
                        pessoa.Capacitacao.TurmaId = null;
                        pessoa.Capacitacao.RajId   = null;
                    }
                }
                else
                {
                    pessoa.Capacitacao.IsCapacitado = false;
                }

                pessoa.Nome     = txtNome.Text;
                pessoa.Registro = txtRegistro.Text;
                pessoa.EMail    = txtEmail.Text;
                pessoa.CargoId  = (int)cmbCargo.SelectedValue;
                pessoa.SetorId  = (int)cmbSetor.SelectedValue;
                pessoa.Obs      = txtOBS.Text;

                common.SaveChanges_Database(context, true);
            }

            AtualizaPreencheInicial();
        }
示例#2
0
        private void btCadastrar_Click(object sender, EventArgs e)
        {
            using (capdeEntities context = new capdeEntities())
            {
                Capacitacao capacitacao = new Capacitacao();

                if (ckCapacitado.Checked)
                {
                    capacitacao.DataInicio   = Convert.ToDateTime(dateTInicio.Text);
                    capacitacao.DataFim      = Convert.ToDateTime(dateTFim.Text);
                    capacitacao.IsCapacitado = true;

                    if (radioEAD.Checked)
                    {
                        capacitacao.IsEAD   = true;
                        capacitacao.TurmaId = (int)cmbCapacitacao.SelectedValue;
                    }
                    else if (radioPresencial.Checked)
                    {
                        capacitacao.RajId = (int)cmbCapacitacao.SelectedValue;
                        capacitacao.IsEAD = false;
                    }
                }
                else
                {
                    capacitacao.IsCapacitado = false;
                }

                Pessoa pessoa = new Pessoa
                {
                    Nome         = txtNome.Text,
                    Registro     = txtRegistro.Text,
                    EMail        = txtEmail.Text,
                    CargoId      = (int)cmbCargo.SelectedValue,
                    Setor        = context.Setors.Where(x => x.SetorId == (int)cmbSetor.SelectedValue).FirstOrDefault(),
                    Capacitacao  = capacitacao,
                    Obs          = txtOBS.Text,
                    IsExcluido   = false,
                    IsAposentado = false,
                };

                try
                {
                    context.Capacitacaos.Add(capacitacao);
                    context.Pessoas.Add(pessoa);

                    common.SaveChanges_Database(context, true);
                }
                catch (Exception ex) { commonLog.SendLogError(thisAssemblyVersion.FileVersion, "Cadastro Pessoa",
                                                              ex.Message + "\r\n" + ex.StackTrace, logedUser); }
            }

            LimpaCampos();
            insertedData = true;
            common.PreencheCombos_Pessoa(cmbRAJ, cmbCJ, cmbCidade, cmbCargo, cmbSetor, cmbCapacitacao);
        }
示例#3
0
        private void CadastroRAJ()
        {
            using (capdeEntities context = new capdeEntities())
            {
                RAJ rajVerif = context.RAJs.Where(x => x.NomeRaj == textBox1.Text).FirstOrDefault();
                if (isEditing)
                {
                    RAJ raj = context.RAJs.Where(x => x.RajId == idEditing).FirstOrDefault();
                    raj.NomeRaj    = textBox1.Text;
                    raj.IsExcluido = false;
                }
                else if (rajVerif == null)
                {
                    RAJ raj = new RAJ
                    {
                        NomeRaj    = textBox1.Text,
                        RajIdent   = context.RAJs.Count() + 1,
                        IsExcluido = false,
                    };

                    CJ cj = new CJ
                    {
                        RajId      = raj.RajId,
                        CjIdent    = context.CJs.Count() + 1,
                        CjNome     = StringBase.TODOS.ToString(),
                        IsExcluido = false,
                    };

                    Cidade cidade = new Cidade
                    {
                        CjId       = cj.CjId,
                        NomeCidade = StringBase.TODOS.ToString(),
                        IsExcluido = false,
                    };

                    context.RAJs.Add(raj);
                    context.CJs.Add(cj);
                    context.Cidades.Add(cidade);
                }

                if (isEditing || rajVerif == null)
                {
                    common.SaveChanges_Database(context, true);
                    OutEditing();
                }
                else
                {
                    MessageBox_AlreadyCadastrado(textBox1, TypeForm.RAJ.ToString());
                }
            };
        }
示例#4
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            using (capdeEntities context = new capdeEntities())
            {
                foreach (DataGridViewRow row in dataGridView1.Rows)
                {
                    string registro  = row.Cells[0].Value.ToString();
                    string nome      = row.Cells[1].Value.ToString();
                    string email     = row.Cells[2].Value.ToString();
                    string obs       = row.Cells[8].Value.ToString();
                    string nomeCargo = row.Cells[3].Value.ToString();
                    string nomeSetor = row.Cells[7].Value.ToString();

                    Pessoa verifyPessoa = context.Pessoas.Where(x => x.Registro == registro).FirstOrDefault();

                    if (verifyPessoa == null)
                    {
                        Capacitacao capacitacao = new Capacitacao();
                        capacitacao.IsCapacitado = false;

                        Pessoa pessoa = new Pessoa
                        {
                            Registro     = registro,
                            Nome         = nome.ToUpper(),
                            EMail        = email,
                            Obs          = obs,
                            SetorId      = context.Setors.Where(x => x.NomeSetor == nomeSetor).Select(x => x.SetorId).First(),
                            IsAposentado = false,
                            IsExcluido   = false,
                            Capacitacao  = capacitacao,
                            CargoId      = context.Cargoes.Where(x => x.NomeCargo == nomeCargo).Select(x => x.CargoId).First(),
                        };

                        context.Capacitacaos.Add(capacitacao);
                        context.Pessoas.Add(pessoa);
                        common.SaveChanges_Database(context, true);
                    }
                }
            }

            this.Close();
        }
示例#5
0
        private void dgvUser_DoubleClick(object sender, EventArgs e)
        {
            if (dgvUser.CurrentRow != null)
            {
                using (capdeEntities context = new capdeEntities())
                {
                    int     idUser = (int)dgvUser.CurrentRow.Cells[0].Value;
                    Usuario user   = context.Usuarios.Where(x => x.UsuarioId == idUser).FirstOrDefault();

                    if (user.IsAdmin)
                    {
                        user.IsAdmin = false;
                    }
                    else
                    {
                        user.IsAdmin = true;
                    }

                    common.SaveChanges_Database(context, true);
                    AllUser();
                }
            }
        }