Example #1
0
 public void SalvarValor(CE_Pesquisa03 valor)
 {
     if (valor.idpesquisa03 == 0)
     {
         conn.Insert(valor);
     }
     else
     {
         conn.Update(valor);
     }
 }
Example #2
0
 private void CriarResposta(CE_Pesquisa03 opcao)
 {
     resposta = new CE_Pesquisa07();
     resposta.idpesquisa04  = modalResposta.Item.idpesquisa04;
     resposta.idpesquisa06  = modalResposta.Pesquisa06.idpesquisa06;
     resposta.idpesquisador = pesquisador.idpesquisador;
     resposta.idcliente     = pesquisador.idcliente;
     resposta.idpesquisa03  = opcao.idpesquisa03;
     resposta.pesquisa03    = opcao;
     resposta.txresposta    = opcao.descricao;
     resposta.chavepesquisa = itemViewModel.Item.Formulario.codigoformulario;
 }
Example #3
0
 public void AtualizarValor(CE_Pesquisa03 valor)
 {
     conn.Update(valor);
 }
Example #4
0
 public void InserirValor(CE_Pesquisa03 valor)
 {
     conn.Insert(valor);
 }
Example #5
0
        public async void TratarRespostaLista(CE_Pesquisa03 opcao)
        {
            //var selecionado = modalResposta.Item.Opcoes.Where(o => o.IsSelecionado).ToList().FirstOrDefault(b => b.idpesquisa03 == OpcaoSelecionada.idpesquisa03);

            if (modalResposta.Item.pesquisa02outros != null && opcao.campotipooutros == 1)             //&& selecionado == null)
            {
                if (itemViewModel.IsRespondido && modalResposta.Item.qtrespostas == 1)
                {
                    resposta            = dao.ObterRespostaPorPergunta(modalResposta.Item.idpesquisa04, itemViewModel.Item.Formulario.codigoformulario).FirstOrDefault();
                    resposta.pesquisa03 = opcao;

                    if (resposta.idpesquisa03 != opcao.idpesquisa03)
                    {
                        CriarResposta(opcao);
                    }

                    if (ListaRespostas != null)
                    {
                        ListaRespostas.Clear();
                    }
                    else
                    {
                        ListaRespostas = new List <CE_Pesquisa07>();
                    }

                    ListaRespostas.Add(resposta);
                }
                else
                {
                    CriarResposta(opcao);

                    if (opcao.retornopesquisa != null)
                    {
                        resposta.vlresposta = Decimal.Parse(opcao.retornopesquisa);
                    }

                    if (ListaRespostas == null)
                    {
                        ListaRespostas = new List <CE_Pesquisa07>();
                    }

                    ListaRespostas.Add(resposta);
                }

                ModalResposta modalRespostaOutros = new ModalResposta(modalResposta.Item, modalResposta.Pesquisa06, modalResposta.Item.pesquisa02outros.tipodado, 1);
                modalRespostaOutros.CodigoFormulario = itemViewModel.Item.Formulario.codigoformulario;
                ModalRespostaViewModel viewModel = new ModalRespostaViewModel(this.page, modalRespostaOutros, itemViewModel, resposta, 1, modalResposta.Item.pesquisa02outros.tipodado, ListaRespostas);
                modalRespostaOutros.BindingContext = viewModel;
                await this.page.Navigation.PushModalAsync(modalRespostaOutros);

                viewModel.SetarValores();
            }
            else
            {
                if (NPage == 0)
                {
                    //if (ListaRespostas != null)
                    //	ListaRespostas.Clear();
                    //else
                    //	ListaRespostas = new List<CE_Pesquisa07>();

                    if (ListaRespostas == null || modalResposta.Item.qtrespostas == 1)
                    {
                        ListaRespostas = new List <CE_Pesquisa07>();
                    }

                    CriarResposta(opcao);

                    if (opcao.retornopesquisa != null)
                    {
                        resposta.vlresposta = Decimal.Parse(opcao.retornopesquisa);
                    }

                    ListaRespostas.Add(resposta);
                }
            }
        }
Example #6
0
        private void ListView_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            var list = sender as ListView;

            CE_Pesquisa03 item = list.SelectedItem as CE_Pesquisa03;

            List <CE_Pesquisa03> selecionados = modalResposta.Item.Opcoes.Where(o => o.IsSelecionado).ToList();

            var selecionado = selecionados.Where(o => o.idpesquisa03 == item.idpesquisa03).FirstOrDefault();

            if (selecionado == null)
            {
                if (item.campotipooutros == 0)
                {
                    item.IsSelecionado = true;
                }

                TratarRespostaLista(item);
            }
            else
            {
                selecionado.IsSelecionado = !selecionado.IsSelecionado;

                if (selecionado.IsSelecionado)
                {
                    if (selecionado.IsSelecionado && selecionado.campotipooutros == 1)
                    {
                        selecionado.IsSelecionado = false;
                    }

                    TratarRespostaLista(selecionado);
                }
                else
                {
                    var resp = ListaRespostas.FirstOrDefault(o => o.idpesquisa03 == selecionado.idpesquisa03);
                    selecionado.descricao = selecionado.descricao.Replace(" - " + resp.txresposta, "").Replace(" - " + resp.txrespostaoutros, "").Replace(" - " + resp.vlresposta.ToString(), "").Replace(" - " + resp.vlrespostaoutros.ToString(), "");
                    ListaRespostas.Remove(resp);
                }
            }

            if (selecionados.Count >= modalResposta.Item.qtrespostas)
            {
                if (selecionado == null)
                {
                    selecionados.Last().IsSelecionado = false;
                    var resp = ListaRespostas.FirstOrDefault(o => o.idpesquisa03 == selecionados.Last().idpesquisa03);
                    selecionados.Last().descricao = selecionados.Last().descricao.Replace(" - " + resp.txresposta, "").Replace(" - " + resp.txrespostaoutros, "").Replace(" - " + resp.vlresposta.ToString(), "").Replace(" - " + resp.vlrespostaoutros.ToString(), "");
                    ListaRespostas.Remove(resp);
                }
                else
                {
                    if (selecionado.idpesquisa03 != item.idpesquisa03)
                    {
                        selecionados.Last().IsSelecionado = false;
                        var resp = ListaRespostas.FirstOrDefault(o => o.idpesquisa03 == selecionados.Last().idpesquisa03);
                        selecionados.Last().descricao = selecionados.Last().descricao.Replace(" - " + resp.txresposta, "").Replace(" - " + resp.txrespostaoutros, "").Replace(" - " + resp.vlresposta.ToString(), "").Replace(" - " + resp.vlrespostaoutros.ToString(), "");
                        ListaRespostas.Remove(resp);
                    }
                }
            }
        }
Example #7
0
        public MikePhil.Charting.Charts.PieChart getPieChart(List <CE_Pesquisa03> opcoes, List <CE_Pesquisa07> respostas)
        {
            MikePhil.Charting.Charts.PieChart pieChart = new MikePhil.Charting.Charts.PieChart(Android.App.Application.Context);
            pieChart.SetMinimumWidth(500);
            pieChart.SetMinimumHeight(500);
            pieChart.SetUsePercentValues(true);
            pieChart.SetDescription("");
            //chart.SetExtraOffsets(5, 10, 5, 5);
            //chart.DragDecelerationFrictionCoef = 0.95f;

            pieChart.DrawHoleEnabled = true;
            pieChart.SetHoleColor(Android.Graphics.Color.White);
            pieChart.SetTransparentCircleColor(Android.Graphics.Color.White);
            //chart.SetTransparentCircleAlpha(110);
            //chart.HoleRadius = 58f;
            //chart.TransparentCircleRadius = 61f;
            pieChart.HoleRadius = 7f;
            pieChart.TransparentCircleRadius = 10f;

            //chart.SetDrawCenterText(false);

            //rotação
            pieChart.RotationAngle          = 0;
            pieChart.RotationEnabled        = true;
            pieChart.HighlightPerTapEnabled = true;

            //chart.max SetMaxVisibleValueCount(60);
            //chart. SetPinchZoom(true);
            //chart.back SetDrawGridBackground(false);

            //chart.XAxis.SetAxisMinValue(0f);
            //chart.XAxis.SetAxisMaxValue()

            List <Int32> allColors = new List <Int32>();
            List <Int32> colors    = new List <Int32>();

            foreach (int c in MikePhil.Charting.Util.ColorTemplate.VordiplomColors)
            {
                allColors.Add(c);
            }

            foreach (int c in MikePhil.Charting.Util.ColorTemplate.JoyfulColors)
            {
                allColors.Add(c);
            }

            foreach (int c in MikePhil.Charting.Util.ColorTemplate.ColorfulColors)
            {
                allColors.Add(c);
            }

            foreach (int c in MikePhil.Charting.Util.ColorTemplate.LibertyColors)
            {
                allColors.Add(c);
            }

            foreach (int c in MikePhil.Charting.Util.ColorTemplate.PastelColors)
            {
                allColors.Add(c);
            }

            allColors.Add(MikePhil.Charting.Util.ColorTemplate.HoloBlue);

            List <MikePhil.Charting.Data.Entry> entries = new List <MikePhil.Charting.Data.Entry>();

            List <string> labels = new List <string>();

            Configuracao conf = ObterConfiguracao();

            float percentualMaximo = conf.PercentualMaximoGrafico;

            //respostas = respostas.OrderBy(o => o.txresposta).ToList();

            int qt = respostas.Count > 5 ? respostas.IndexOf(respostas.FirstOrDefault(o => o.totalpercentual > (decimal)percentualMaximo)) + 1 : respostas.Count;

            // NOTE: The order of the entries when being added to the entries array determines their position around the center of
            // the chart.
            for (int i = 0; i < qt; i++)
            {
                entries.Add(new MikePhil.Charting.Data.Entry((float)respostas[i].quantidade, i));
                labels.Add(respostas[i].txresposta != null ? respostas[i].txresposta : respostas[i].vlresposta.ToString());
                CE_Pesquisa03 opcao = opcoes.FirstOrDefault(o => o.retornopesquisa.Trim() == respostas[i].vlresposta.ToString().Trim());
                colors.Add(allColors[opcao.cor]);
            }

            if (respostas.Count > 5)
            {
                if (respostas.Count == 6)
                {
                    entries.Add(new MikePhil.Charting.Data.Entry((float)respostas[5].quantidade, 5));
                    labels.Add(respostas[5].txresposta != null ? respostas[5].txresposta : respostas[5].vlresposta.ToString());
                    CE_Pesquisa03 opcao = opcoes.FirstOrDefault(o => o.retornopesquisa.Trim() == respostas[5].vlresposta.ToString().Trim());
                    colors.Add(allColors[opcao.cor]);
                }
                else
                {
                    entries.Add(new MikePhil.Charting.Data.Entry((float)respostas.Where(o => o.totalpercentual > respostas[qt - 1].totalpercentual).Sum(o => o.quantidade), qt));
                    labels.Add("Outros");
                    colors.Add(allColors[25]);
                }
            }

            MikePhil.Charting.Data.PieDataSet dataSet = new MikePhil.Charting.Data.PieDataSet(entries, "");
            dataSet.SliceSpace     = 3f;
            dataSet.SelectionShift = 5f;
            dataSet.SetColors(colors.ToArray());
            //dataSet.setSelectionShift(0f);

            MikePhil.Charting.Data.PieData data = new MikePhil.Charting.Data.PieData(labels, dataSet);
            data.SetValueFormatter(new MikePhil.Charting.Formatter.PercentFormatter());
            data.SetValueTextSize(15f);
            data.SetValueTextColor(Android.Graphics.Color.Black);
            data.SetValueTypeface(Android.Graphics.Typeface.Default);
            pieChart.Data = data;

            // undo all highlights
            pieChart.HighlightValues(null);

            pieChart.Invalidate();

            //fim data

            //pieChart.AnimateY(1400, MikePhil.Charting.Animation.Easing.EasingOption.EaseInOutQuad);

            // mChart.spin(2000, 0, 360);

            MikePhil.Charting.Components.Legend l = pieChart.Legend;
            l.Enabled = false;

            //MikePhil.Charting.Components.Legend l = pieChart.Legend;
            //l.TextSize = 15f;
            //l.Position = MikePhil.Charting.Components.Legend.LegendPosition.LeftOfChart;
            //l.XEntrySpace = 7f;
            //l.YEntrySpace = 0f;
            //l.YOffset = 0f;

            return(pieChart);
        }