public bool Gravar(Produtividade produtividade)
 {
     crud = new CRUD();
     SQL  = "INSERT INTO Produtividade (Id_Competencia, Id_Empresa, Id_Empregado, Dias_Apurados, Fer_Dom_Apurados, Media_Avaliacao, Produtividade_Valor, Produtividade_Reflexo, Data_Calculo) " +
            "VALUES (@Id_Competencia, @Id_Empresa, @Id_Empregado, @Dias_Apurados, @Fer_Dom_Apurados, @Media_Avaliacao, @Produtividade_Valor, @Produtividade_Reflexo, @Data_Calculo)";
     try
     {
         crud.LimparParametros();
         crud.AdicionarParametros("Id_Competencia", produtividade.Competencia.Id);
         crud.AdicionarParametros("Id_Empresa", produtividade.Empresa.Id);
         crud.AdicionarParametros("Id_Empregado", produtividade.Empregado.Id);
         crud.AdicionarParametros("Dias_Apurados", produtividade.DiasUteis);
         crud.AdicionarParametros("Fer_Dom_Apurados", produtividade.DomingosFeriados);
         crud.AdicionarParametros("Media_Avaliacao", produtividade.Media);
         crud.AdicionarParametros("Produtividade_Valor", produtividade.Produtividade_Valor);
         crud.AdicionarParametros("Produtividade_Reflexo", produtividade.Produtividade_Reflexo);
         crud.AdicionarParametros("Data_Calculo", produtividade.Data_Calculo);
         crud.Executar(CommandType.Text, SQL);
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        protected void btnExportarExcel_Click(object sender, EventArgs e)
        {
            this.lblAviso.Text = string.Empty;
            //verifica as datas
            if (cboDtFim.Value == null || cboDtInicio.Value == null)
            {
                this.lblAviso.Text = "Favor selecionar as datas";
                return;
            }

            if (cboDtInicio.Date > cboDtFim.Date)
            {
                this.lblAviso.Text = "A data início não pode ser superior a data fim";
                return;
            }


            var dsExport = Produtividade.GetExport(this.cboDtInicio.Date, this.cboDtFim.Date).ToList();

            this.dGridExport.DataSource = dsExport;

            this.dGridExport.DataBind();
            this.dGridExportExporter.FileName = string.Format("ExportProdutividade_{0:yyyy_MM_dd}_{1:yyyy_MM_dd}.xlsx", this.cboDtInicio.Date, this.cboDtFim.Date);

            this.dGridExportExporter.WriteXlsxToResponse(true);
        }
        //Exclusao geral do calculo
        private bool ExcluirGeral()
        {
            atividadeAvaliacaoControle = new AtividadeAvaliacaoControle();
            produtividade         = new Produtividade();
            produtividadeControle = new ProdutividadeControle();
            empregadoControle     = new EmpregadoControle();
            int x = 0;

            Invoke((Action)(() =>
            {
                LblInfoCalculoExclusao.Visible = true;
            }));
            try
            {
                DataTable tblEmpregado = empregadoControle.EmpregadoTabelaCalculo(idEmpresa);
                foreach (DataRow item in tblEmpregado.Rows)
                {
                    idEmpregado = int.Parse(item["Id"].ToString());
                    produtividade.Competencia    = new Competencia();
                    produtividade.Competencia.Id = idCompetencia;
                    produtividade.Empresa        = new Empresa();
                    produtividade.Empresa.Id     = idEmpresa;

                    totalAvaliacaoPorEmpregado = atividadeAvaliacaoControle.TotalAvaliacaoEmpregado(idEmpresa, idEmpregado, idCompetencia);

                    if (totalAvaliacaoPorEmpregado != 0)
                    {
                        x++;
                        BwProcesso.ReportProgress(x);
                        produtividadeControle.Excluir(produtividade);
                    }
                    else
                    {
                        continue;
                    }
                }
                Invoke((Action)(() =>
                {
                    LblInfoCalculoExclusao.Visible = false;
                }));
                MessageBox.Show("Exclusão finalizada!!!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ListaCalculo(idCompetencia, idEmpresa);
                CompararCalculoEmpregado();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
 public bool Excluir(Produtividade produtividade)
 {
     crud = new CRUD();
     SQL  = "DELETE FROM Produtividade " +
            "WHERE Id_Competencia = @Id_Competencia AND Id_Empresa = @Id_Empresa";
     try
     {
         crud.LimparParametros();
         crud.AdicionarParametros("Id_Competencia", produtividade.Competencia.Id);
         crud.AdicionarParametros("Id_Empresa", produtividade.Empresa.Id);
         crud.Executar(CommandType.Text, SQL);
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
 public bool AlterarEmpresaProdutividade(Produtividade produtividade)
 {
     crud = new CRUD();
     SQL  = "UPDATE Produtividade SET  Id_Empresa = @Id_Empresa " +
            "WHERE Id_Empregado = @Id_Empregado ";
     try
     {
         crud.LimparParametros();
         crud.AdicionarParametros("Id_Empresa", produtividade.Empresa.Id);
         crud.AdicionarParametros("Id_Empregado", produtividade.Empregado.Id);
         crud.Executar(CommandType.Text, SQL);
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        protected void btnGerar_Click(object sender, EventArgs e)
        {
            this.pnlMain.Visible = false;

            this.lblAviso.Text = string.Empty;
            //verifica as datas
            if (cboDtFim.Value == null || cboDtInicio.Value == null)
            {
                this.lblAviso.Text = "Favor selecionar as datas";
                return;
            }

            if (cboDtInicio.Date > cboDtFim.Date)
            {
                this.lblAviso.Text = "A data início não pode ser superior a data fim";
                return;
            }

            if (cboDtFim.Date.Subtract(cboDtInicio.Date).TotalDays > 365)
            {
                this.lblAviso.Text = "Intervalo muito grande, não é possível realizar a consulta";
                return;
            }


            //Produtividade
            List <Produtividade> dtProd = Produtividade.GetEvolucaoMensalPorFuncionario(cboDtInicio.Date, cboDtFim.Date);

            this.chartTop.DataSource  = dtProd;
            chartTop.SeriesDataMember = "Periodo";
            chartTop.SeriesTemplate.ArgumentDataMember = "Funcionario";
            chartTop.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "qtdRecs" });
            chartTop.DataBind();
            foreach (DevExpress.XtraCharts.Series serie in chartTop.Series)
            {
                serie.LabelsVisibility             = DevExpress.Utils.DefaultBoolean.True;
                serie.Label.LineVisible            = true;
                serie.LegendPointOptions.PointView = DevExpress.XtraCharts.PointView.Values;
            }

            XYDiagram diagram = (XYDiagram)chartTop.Diagram;

            diagram.EnableAxisXScrolling = true;



            //Evolução Geral
            List <Produtividade> dtEvolucao = Produtividade.GetEvolucaoMensal(cboDtInicio.Date, cboDtFim.Date);

            this.chartRight.DataSource       = dtEvolucao;
            this.chartRight.SeriesDataMember = "Funcionario";
            this.chartRight.SeriesTemplate.ArgumentDataMember = "Periodo";
            this.chartRight.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "qtdRecs" });
            this.chartRight.DataBind();

            foreach (DevExpress.XtraCharts.Series serie in chartRight.Series)
            {
                serie.LabelsVisibility             = DevExpress.Utils.DefaultBoolean.True;
                serie.Label.LineVisible            = true;
                serie.LegendPointOptions.PointView = DevExpress.XtraCharts.PointView.Values;
            }



            //Evolução Diaria
            List <Produtividade> dtEvolucaoDiaria = Produtividade.GetEvolucaoDiaria(cboDtInicio.Date, cboDtFim.Date);



            for (DateTime d = this.cboDtInicio.Date; d < cboDtFim.Date; d = d.AddDays(1))
            {
                if (dtEvolucaoDiaria.Find(f => f.Periodo == d.ToString("yyyy-MM-dd")) == null)
                {
                    dtEvolucaoDiaria.Add(new Produtividade
                    {
                        Funcionario      = "Evolucao",
                        Periodo          = d.ToString("yyyy-MM-dd hh:mm:ss"),
                        PeriodoFormatado = d.ToString("dd/MMM"),
                        id_usuario       = "Evolucao",
                        qtdRecs          = 0
                    });
                }
            }



            this.chrEvolDiaria.DataSource  = dtEvolucaoDiaria.OrderBy(f => f.Periodo).ToList();
            chrEvolDiaria.SeriesDataMember = "Funcionario";
            chrEvolDiaria.SeriesTemplate.ArgumentDataMember = "PeriodoFormatado";
            chrEvolDiaria.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "qtdRecs" });
            chrEvolDiaria.DataBind();
            foreach (DevExpress.XtraCharts.Series serie in chrEvolDiaria.Series)
            {
                serie.LabelsVisibility             = DevExpress.Utils.DefaultBoolean.True;
                serie.Label.LineVisible            = true;
                serie.LegendPointOptions.PointView = DevExpress.XtraCharts.PointView.Values;
            }



            //Painel BSC
            List <ItemRanking> objRanking = ItemRanking.GeraRanking(cboDtInicio.Date, cboDtFim.Date);

            rptBscItens.DataSource = objRanking;
            rptBscItens.DataBind();

            this.pnlMain.Visible = true;
        }
Exemplo n.º 7
0
        private bool Manipular(TipoManipulacao tipoManipulacao)
        {
            empregado                  = new Empregado();
            empregadoControle          = new EmpregadoControle();
            atividadeAvaliacao         = new AtividadeAvaliacao();
            atividadeAvaliacaoControle = new AtividadeAvaliacaoControle();
            produtividade              = new Produtividade();
            produtividadeControle      = new ProdutividadeControle();
            competenciaControle        = new CompetenciaControle();
            try
            {
                try
                {
                    dtCompetencia = competenciaControle.CompetenciaAtiva();
                    idCompetencia = competenciaControle.Id(dtCompetencia.Date);
                }
                catch
                {
                    MessageBox.Show("Cadastrar competência!!!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                //Trava a manutencao para que o usuario exclua o calcul da produtividade antes de alterar qualquer dados.
                int numCalculo    = produtividadeControle.NumCalculados(idCompetencia, idEmpresa);
                int numEmpregados = DgvEmpregado.Rows.Count;
                if (numCalculo == numEmpregados && numEmpregados != 0)
                {
                    MessageBox.Show("Empresa com produtividade calculada para competência: " + dtCompetencia.ToString("MM/yyyy") +
                                    "\nEfetue o cancelamento do calculo para fazer alterações no cadastro.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reset();
                    return(false);
                }

                empregado.Id   = idEmpregado;
                empregado.Nome = TxtNome.Text.Trim();
                if (CbxAtivo.Checked)
                {
                    empregado.Ativo = true;
                }
                else
                {
                    empregado.Ativo = false;
                }
                empregado.Empresa         = new Empresa();
                empregado.Empresa.Id      = idEmpresa;
                empregado.Departamento    = new Departamento();
                empregado.Departamento.Id = idDepartamento;

                atividadeAvaliacao.Empresa      = new Empresa();
                atividadeAvaliacao.Empresa.Id   = idEmpresa;
                atividadeAvaliacao.Empregado    = new Empregado();
                atividadeAvaliacao.Empregado.Id = idEmpregado;

                produtividade.Empresa      = new Empresa();
                produtividade.Empresa.Id   = idEmpresa;
                produtividade.Empregado    = new Empregado();
                produtividade.Empregado.Id = idEmpregado;

                if (tipoManipulacao == TipoManipulacao.Gravar)
                {
                    empregadoControle.Gravar(empregado);
                }
                else if (tipoManipulacao == TipoManipulacao.Alterar)
                {
                    empregadoControle.Alterar(empregado);
                    atividadeAvaliacaoControle.AlterarAtividadeEmpregado(atividadeAvaliacao);
                    produtividadeControle.AlterarEmpresaProdutividade(produtividade);
                }
                else if (tipoManipulacao == TipoManipulacao.Excluir)
                {
                    empregadoControle.Excluir(empregado);
                }

                ListaEmpregado();
                Reset();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }
Exemplo n.º 8
0
        protected void btnGerar_Click(object sender, EventArgs e)
        {
            this.lblAviso.Text = string.Empty;
            //verifica as datas
            if (this.cboDtInicio.Value == null)
            {
                this.lblAviso.Text = "Favor selecionar as datas";
                return;
            }

            var prodBase = Produtividade.GetHoraria(this.cboDtInicio.Date);

            var prod = (from p in prodBase
                        group p by new
            {
                Usuario = p.id_usuario
            } into pp
                        select new
            {
                Usuario = pp.Key.Usuario,
                QtdRecs = prodBase.Where(f => f.id_usuario == pp.Key.Usuario).Sum(g => g.qtdRecs),
                Prod = (prodBase.Where(f => f.id_usuario == pp.Key.Usuario).Sum(g => g.qtdRecs) / 8.00).ToString("0.##"),
                QtdHoras = 8,
                C1 = pp.Where(f => f.Periodo == "1").Sum(g => g.qtdRecs),
                C2 = pp.Where(f => f.Periodo == "2").Sum(g => g.qtdRecs),
                C3 = pp.Where(f => f.Periodo == "3").Sum(g => g.qtdRecs),
                C4 = pp.Where(f => f.Periodo == "4").Sum(g => g.qtdRecs),
                C5 = pp.Where(f => f.Periodo == "5").Sum(g => g.qtdRecs),
                C6 = pp.Where(f => f.Periodo == "6").Sum(g => g.qtdRecs),
                C7 = pp.Where(f => f.Periodo == "7").Sum(g => g.qtdRecs),
                C8 = pp.Where(f => f.Periodo == "8").Sum(g => g.qtdRecs),
                C9 = pp.Where(f => f.Periodo == "9").Sum(g => g.qtdRecs),
                C10 = pp.Where(f => f.Periodo == "10").Sum(g => g.qtdRecs),
                C11 = pp.Where(f => f.Periodo == "11").Sum(g => g.qtdRecs),
                C12 = pp.Where(f => f.Periodo == "12").Sum(g => g.qtdRecs),
                C13 = pp.Where(f => f.Periodo == "13").Sum(g => g.qtdRecs),
                C14 = pp.Where(f => f.Periodo == "14").Sum(g => g.qtdRecs),
                C15 = pp.Where(f => f.Periodo == "15").Sum(g => g.qtdRecs),
                C16 = pp.Where(f => f.Periodo == "16").Sum(g => g.qtdRecs),
                C17 = pp.Where(f => f.Periodo == "17").Sum(g => g.qtdRecs),
                C18 = pp.Where(f => f.Periodo == "18").Sum(g => g.qtdRecs),
                C19 = pp.Where(f => f.Periodo == "19").Sum(g => g.qtdRecs),
                C20 = pp.Where(f => f.Periodo == "20").Sum(g => g.qtdRecs),
                C21 = pp.Where(f => f.Periodo == "21").Sum(g => g.qtdRecs),
                C22 = pp.Where(f => f.Periodo == "22").Sum(g => g.qtdRecs),
                C23 = pp.Where(f => f.Periodo == "23").Sum(g => g.qtdRecs),
                C24 = pp.Where(f => f.Periodo == "0").Sum(g => g.qtdRecs)
            }).ToList();

            //Adiciona o Total
            prod.Add(new
            {
                Usuario  = "Total",
                QtdRecs  = prodBase.Sum(f => f.qtdRecs),
                Prod     = (prodBase.Sum(f => f.qtdRecs) / (prod.Count * 8.00)).ToString("0.##"),
                QtdHoras = prod.Count * 8,
                C1       = prodBase.Where(f => f.Periodo == "1").Sum(g => g.qtdRecs),
                C2       = prodBase.Where(f => f.Periodo == "2").Sum(g => g.qtdRecs),
                C3       = prodBase.Where(f => f.Periodo == "3").Sum(g => g.qtdRecs),
                C4       = prodBase.Where(f => f.Periodo == "4").Sum(g => g.qtdRecs),
                C5       = prodBase.Where(f => f.Periodo == "5").Sum(g => g.qtdRecs),
                C6       = prodBase.Where(f => f.Periodo == "6").Sum(g => g.qtdRecs),
                C7       = prodBase.Where(f => f.Periodo == "7").Sum(g => g.qtdRecs),
                C8       = prodBase.Where(f => f.Periodo == "8").Sum(g => g.qtdRecs),
                C9       = prodBase.Where(f => f.Periodo == "9").Sum(g => g.qtdRecs),
                C10      = prodBase.Where(f => f.Periodo == "10").Sum(g => g.qtdRecs),
                C11      = prodBase.Where(f => f.Periodo == "11").Sum(g => g.qtdRecs),
                C12      = prodBase.Where(f => f.Periodo == "12").Sum(g => g.qtdRecs),
                C13      = prodBase.Where(f => f.Periodo == "13").Sum(g => g.qtdRecs),
                C14      = prodBase.Where(f => f.Periodo == "14").Sum(g => g.qtdRecs),
                C15      = prodBase.Where(f => f.Periodo == "15").Sum(g => g.qtdRecs),
                C16      = prodBase.Where(f => f.Periodo == "16").Sum(g => g.qtdRecs),
                C17      = prodBase.Where(f => f.Periodo == "17").Sum(g => g.qtdRecs),
                C18      = prodBase.Where(f => f.Periodo == "18").Sum(g => g.qtdRecs),
                C19      = prodBase.Where(f => f.Periodo == "19").Sum(g => g.qtdRecs),
                C20      = prodBase.Where(f => f.Periodo == "20").Sum(g => g.qtdRecs),
                C21      = prodBase.Where(f => f.Periodo == "21").Sum(g => g.qtdRecs),
                C22      = prodBase.Where(f => f.Periodo == "22").Sum(g => g.qtdRecs),
                C23      = prodBase.Where(f => f.Periodo == "23").Sum(g => g.qtdRecs),
                C24      = prodBase.Where(f => f.Periodo == "0").Sum(g => g.qtdRecs)
            });



            this.dGridMain.DataSource = prod;
            this.dGridMain.DataBind();
        }
        protected void btnGerar_Click(object sender, EventArgs e)
        {
            this.pnlMain.Visible = false;


            this.lblAviso.Text = string.Empty;
            //verifica as datas
            if (cboDtFim.Value == null || cboDtInicio.Value == null)
            {
                this.lblAviso.Text = "Favor selecionar as datas";
                return;
            }

            if (cboDtInicio.Date > cboDtFim.Date)
            {
                this.lblAviso.Text = "A data início não pode ser superior a data fim";
                return;
            }

            if (cboDtFim.Date.Subtract(cboDtInicio.Date).TotalDays > 365)
            {
                this.lblAviso.Text = "Intervalo muito grande, não é possível realizar a consulta";
                return;
            }


            #region Causas
            //Causas
            List <Produtividade> dtCausas = Produtividade.GetCausas(cboDtInicio.Date, cboDtFim.Date);
            this.chartCausas.Series.Clear();
            this.chartCausas.DataSource  = dtCausas;
            chartCausas.SeriesDataMember = "Causa";
            chartCausas.SeriesTemplate.ArgumentDataMember = "PeriodoFormatado";
            chartCausas.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "qtdRecs" });
            chartCausas.DataBind();
            chartCausas.ToolTipEnabled = DevExpress.Utils.DefaultBoolean.False;
            chartCausas.CrosshairOptions.ShowCrosshairLabels = false;
            foreach (DevExpress.XtraCharts.Series serie in chartCausas.Series)
            {
                serie.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            }
            #endregion


            #region Tratamentos

            //Tratamentos
            List <Produtividade> dtTratamento = Produtividade.GetTratamentos(cboDtInicio.Date, cboDtFim.Date);
            this.chartTratamento.Series.Clear();
            this.chartTratamento.DataSource  = dtTratamento;
            chartTratamento.SeriesDataMember = "Tratamento";
            chartTratamento.SeriesTemplate.ArgumentDataMember = "PeriodoFormatado";
            chartTratamento.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "qtdRecs" });
            chartTratamento.DataBind();
            chartTratamento.ToolTipEnabled = DevExpress.Utils.DefaultBoolean.False;
            chartTratamento.CrosshairOptions.ShowCrosshairLabels = false;
            foreach (DevExpress.XtraCharts.Series serie in chartTratamento.Series)
            {
                serie.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;
            }

            #endregion



            this.pnlMain.Visible = true;
        }
        //Calculo Geral
        private bool CalcularGeral()
        {
            calculoProdutividade       = new CalculoProdutividade();
            atividadeAvaliacaoControle = new AtividadeAvaliacaoControle();
            produtividade         = new Produtividade();
            produtividadeControle = new ProdutividadeControle();
            empregadoControle     = new EmpregadoControle();
            int x = 0;

            Invoke((Action)(() =>
            {
                LblInfoCalculoExclusao.Visible = true;
            }));
            try
            {
                DataTable tblEmpregado = empregadoControle.EmpregadoTabelaCalculo(idEmpresa);
                foreach (DataRow item in tblEmpregado.Rows)
                {
                    idEmpregado = int.Parse(item["Id"].ToString());
                    produtividade.Data_Calculo   = DateTime.Now.Date;
                    produtividade.Competencia    = new Competencia();
                    produtividade.Competencia.Id = idCompetencia;
                    produtividade.Empresa        = new Empresa();
                    produtividade.Empresa.Id     = idEmpresa;
                    produtividade.Empregado      = new Empregado();
                    produtividade.Empregado.Id   = idEmpregado;

                    totalAvaliacaoPorEmpregado = atividadeAvaliacaoControle.TotalAvaliacaoEmpregado(idEmpresa, idEmpregado, idCompetencia);

                    dbMedia     = 0;
                    totalDomFer = numDomingos + numFeriados;
                    //Calcular a media
                    if (totalAvaliacaoPorEmpregado != 0)
                    {
                        x++;
                        BwProcesso.ReportProgress(x);
                        dbMedia = atividadeAvaliacaoControle.Media(idEmpresa, idEmpregado, idCompetencia);
                    }
                    else
                    {
                        continue;
                    }

                    valor   = calculoProdutividade.Valor(valorBase, dbMedia);
                    reflexo = calculoProdutividade.Reflexo(valor, numDiasUteis, totalDomFer);

                    produtividade.Media = Math.Round(dbMedia, 2);
                    produtividade.Produtividade_Valor   = Math.Round(valor, 2);
                    produtividade.Produtividade_Reflexo = Math.Round(reflexo, 2);
                    produtividade.DiasUteis             = numDiasUteis;
                    produtividade.DomingosFeriados      = totalDomFer;

                    produtividadeControle.Gravar(produtividade);
                }
                Invoke((Action)(() =>
                {
                    LblInfoCalculoExclusao.Visible = false;
                }));
                MessageBox.Show("Calculo geral finalizado!!!", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ListaCalculo(idCompetencia, idEmpresa);
                CompararCalculoEmpregado();
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(false);
            }
        }