Exemple #1
0
        private int CadastroCJ(string cj, int raj)
        {
            using (capdeEntities context = new capdeEntities())
            {
                CJ newCJ = new CJ
                {
                    RajId      = raj,
                    CjNome     = cj.ToUpper(),
                    IsExcluido = false,
                };

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

                context.CJs.Add(newCJ);
                context.Cidades.Add(cidade);
                context.SaveChanges();

                return(newCJ.CjId);
            }
        }
Exemple #2
0
        private int CadastroRaj(string raj)
        {
            using (capdeEntities context = new capdeEntities())
            {
                RAJ newRaj = new RAJ
                {
                    NomeRaj    = raj.ToUpper(),
                    IsExcluido = false,
                };

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

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

                context.RAJs.Add(newRaj);
                context.CJs.Add(cj);
                context.Cidades.Add(cidade);
                context.SaveChanges();

                return(newRaj.RajId);
            }
        }
Exemple #3
0
        public void SaveChanges_Database(capdeEntities context, bool changed)
        {
            DatabaseConfig config = context.DatabaseConfigs.Where(x => x.DatabaseConfigId == 1).First();

            config.HasChanged = changed;

            context.SaveChanges();
        }
Exemple #4
0
        private int CadastroCargo(string cargo)
        {
            using (capdeEntities context = new capdeEntities())
            {
                Cargo newCargo = new Cargo
                {
                    NomeCargo  = cargo.ToUpper(),
                    IsExcluido = false,
                };

                context.Cargoes.Add(newCargo);
                context.SaveChanges();

                return(newCargo.CargoId);
            }
        }
Exemple #5
0
        private int CadastroSetor(string setor, int cidade)
        {
            using (capdeEntities context = new capdeEntities())
            {
                Setor newSetor = new Setor
                {
                    CidadeId   = cidade,
                    NomeSetor  = setor.ToUpper(),
                    IsExcluido = false,
                };

                context.Setors.Add(newSetor);
                context.SaveChanges();

                return(newSetor.SetorId);
            }
        }
Exemple #6
0
        private int CadastroCidade(string cidade, int cj)
        {
            using (capdeEntities context = new capdeEntities())
            {
                Cidade newCidade = new Cidade
                {
                    CjId       = cj,
                    NomeCidade = cidade.ToUpper(),
                    IsExcluido = false,
                };

                context.Cidades.Add(newCidade);
                context.SaveChanges();

                return(newCidade.CidadeId);
            }
        }
Exemple #7
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            string[] registros = File.ReadAllLines(textBox1.Text);

            using (capdeEntities context = new capdeEntities())
            {
                for (int i = 0; i < registros.Length; i++)
                {
                    string idRegistro = normalizeString(registros[i]);
                    Pessoa pessoa     = context.Pessoas.Where(x => x.Registro == idRegistro).FirstOrDefault();

                    if (pessoa != null)
                    {
                        pessoa.Capacitacao.IsCapacitado = true;
                        pessoa.Capacitacao.DataInicio   = dtPicker1.Value;
                        pessoa.Capacitacao.DataFim      = dtPicker2.Value;

                        if (radioEAD.Checked && radioEAD.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker) delegate
                            {
                                pessoa.Capacitacao.IsEAD   = true;
                                pessoa.Capacitacao.TurmaId = (int)comboBox1.SelectedValue;
                            });
                        }
                        else if (radioPresencial.Checked && comboBox1.InvokeRequired)
                        {
                            this.Invoke((MethodInvoker) delegate
                            {
                                pessoa.Capacitacao.RajId = (int)comboBox1.SelectedValue;
                            });
                        }

                        context.SaveChanges();
                    }

                    (sender as BackgroundWorker).ReportProgress(i);
                }

                common.SaveChanges_Database(context, true);
            }
        }
Exemple #8
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            using (capdeEntities context = new capdeEntities())
            {
                for (int i = 0; i < matricula.Length; i++)
                {
                    string fileMatricula = matricula[i];
                    Pessoa pessoa        = new Pessoa();

                    if (radioButton3.Checked)
                    {
                        pessoa = context.Pessoas.Where(x => x.EMail == fileMatricula.ToUpper()).FirstOrDefault();
                    }
                    else if (radioButton4.Checked)
                    {
                        pessoa = context.Pessoas.Where(x => x.Registro == fileMatricula.ToUpper()).FirstOrDefault();
                    }
                    else if (radioButton5.Checked)
                    {
                        pessoa = context.Pessoas.Where(x => x.Nome == fileMatricula.ToUpper()).FirstOrDefault();
                    }

                    if (pessoa != null)
                    {
                        pessoa.Capacitacao.IsCapacitado = true;
                        pessoa.Capacitacao.RajId        = pessoa.Setor.Cidade.CJ.RajId;

                        context.SaveChanges();
                    }
                    else
                    {
                        logMatricula.Add(matricula[i]);
                    }

                    (sender as BackgroundWorker).ReportProgress(i);
                }
            }
        }
Exemple #9
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            CadastroRaj(StringBase.TODOS.ToString());

            AdjustVariables();

            if (progressBar1.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate { progressBar1.Maximum = matricula.Length; });
            }

            using (capdeEntities context = new capdeEntities())
            {
                for (int i = 0; i < raj.Length; i++)
                {
                    string a_raj    = raj[i].ToString();
                    string a_cj     = cj[i].ToString();
                    string a_cidade = cidade[i].ToString();
                    string a_setor  = setor[i].ToString();
                    string a_cargo  = cargo[i].ToString();

                    int rajId    = context.RAJs.Where(x => x.NomeRaj == a_raj).Select(x => x.RajId).FirstOrDefault();
                    int cjId     = context.CJs.Where(x => x.CjNome == a_cj).Select(x => x.CjId).FirstOrDefault();
                    int cidadeId = context.Cidades.Where(x => x.NomeCidade == a_cidade).Select(x => x.CidadeId).FirstOrDefault();
                    int setorId  = context.Setors.Where(x => x.NomeSetor == a_setor).Select(x => x.SetorId).FirstOrDefault();

                    int cargoId = context.Cargoes.Where(x => x.NomeCargo == a_cargo).Select(x => x.CargoId).FirstOrDefault();

                    if (rajId == 0)
                    {
                        rajId = CadastroRaj(a_raj);
                    }
                    if (cjId == 0)
                    {
                        cjId = CadastroCJ(a_cj, rajId);
                    }
                    if (cidadeId == 0)
                    {
                        cidadeId = CadastroCidade(a_cidade, cjId);
                    }
                    if (setorId == 0)
                    {
                        setorId = CadastroSetor(a_setor, cidadeId);
                    }
                    if (cargoId == 0)
                    {
                        cargoId = CadastroCargo(a_cargo);
                    }

                    Capacitacao capacitacao = new Capacitacao {
                        IsCapacitado = false,
                    };

                    context.Capacitacaos.Add(capacitacao);

                    Pessoa pessoa = new Pessoa
                    {
                        Nome          = nome[i].ToUpper(),
                        Registro      = matricula[i],
                        EMail         = email[i],
                        SetorId       = setorId,
                        Obs           = obs[i],
                        CargoId       = cargoId,
                        CapacitacaoId = capacitacao.CapacitacaoId,
                        IsAposentado  = false,
                        IsExcluido    = false,
                    };

                    context.Pessoas.Add(pessoa);
                    context.SaveChanges();

                    (sender as BackgroundWorker).ReportProgress(i);
                }
            }
        }