/// <summary>
        ///
        /// </summary>
        /// <param name="lstDetelhe"></param>
        /// <param name="banco"></param>
        /// <returns></returns>
        public static bool Salvar(Guid tde_id, List <CFG_DeficienciaDetalhe> lstDetalhe, TalkDBTransaction banco = null)
        {
            CFG_DeficienciaDetalheDAO dao = new CFG_DeficienciaDetalheDAO();

            if (banco == null)
            {
                dao._Banco.Open(IsolationLevel.ReadCommitted);
            }
            else
            {
                dao._Banco = banco;
            }

            try
            {
                //Carrega os detalhes ligados a deficiencia
                List <CFG_DeficienciaDetalhe> lstDetalheBanco = CFG_DeficienciaDetalheBO.SelectDetalheBy_Deficiencia(tde_id, dao._Banco);

                //Salva questões
                foreach (CFG_DeficienciaDetalhe dfd in lstDetalhe)
                {
                    if (dfd.IsNew)
                    {
                        dfd.dfd_id          = -1;
                        dfd.dfd_dataCriacao = DateTime.Now;
                        dfd.tde_id          = tde_id;
                    }
                    dfd.dfd_dataAlteracao = DateTime.Now;
                    if (!CFG_DeficienciaDetalheBO.Save(dfd, dao._Banco))
                    {
                        return(false);
                    }
                }

                //Remove logicamente no banco detalhes que foram removidas da deficiencia
                foreach (CFG_DeficienciaDetalhe dfdB in lstDetalheBanco)
                {
                    if (!lstDetalhe.Any(q => q.dfd_id == dfdB.dfd_id && q.dfd_situacao != 3))
                    {
                        CFG_DeficienciaDetalheBO.Delete(dfdB, dao._Banco);
                    }
                }

                return(true);
            }
            catch (Exception err)
            {
                if (banco == null)
                {
                    dao._Banco.Close(err);
                }

                throw;
            }
            finally
            {
                if (banco == null)
                {
                    dao._Banco.Close();
                }
            }
        }
Beispiel #2
0
        public static string RetornaValorDetalhado(REL_GraficoAtendimentoFiltrosFixos tipoFiltro, string valor)
        {
            string[] codDetalhe = valor.Split(',');
            string   retorno    = string.Empty;

            switch (tipoFiltro)
            {
            case REL_GraficoAtendimentoFiltrosFixos.DetalheDeficiencia:
                List <string> valoresDetalhados = new List <string>();
                foreach (var item in codDetalhe)
                {
                    CFG_DeficienciaDetalhe def = new CFG_DeficienciaDetalhe {
                        dfd_id = Convert.ToInt32(item)
                    };
                    def = CFG_DeficienciaDetalheBO.GetDetalhamento(def);
                    valoresDetalhados.Add(def.dfd_nome);
                }
                codDetalhe = valoresDetalhados.ToArray();

                if (codDetalhe.Length == 1)
                {
                    retorno = codDetalhe[0];
                }
                else if (codDetalhe.Length == 2)
                {
                    retorno = codDetalhe[0] + " e " + codDetalhe[1];
                }
                else if (codDetalhe.Length >= 3)
                {
                    string[] concat = new string[codDetalhe.Length - 1];
                    Array.Copy(codDetalhe, 0, concat, 0, codDetalhe.Length - 1);

                    retorno  = string.Join(", ", concat);
                    retorno += " e " + codDetalhe[codDetalhe.Length - 1];
                }
                else
                {
                    retorno = string.Empty;
                }
                break;

            case REL_GraficoAtendimentoFiltrosFixos.FaixaIdade:
                retorno = codDetalhe.Length >= 2 ? codDetalhe[0] + " até " + codDetalhe[1] + " anos" : string.Empty;
                break;

            case REL_GraficoAtendimentoFiltrosFixos.Sexo:
                retorno = codDetalhe.Length >= 1 ? MetodosExtensao.SexoFormatado(Convert.ToInt32(codDetalhe[0])) : string.Empty;
                break;

            case REL_GraficoAtendimentoFiltrosFixos.PeriodoPreenchimento:
                retorno = codDetalhe.Length >= 2 ? codDetalhe[0] + " até " + codDetalhe[1] : string.Empty;
                break;

            case REL_GraficoAtendimentoFiltrosFixos.RacaCor:
                retorno = codDetalhe.Length >= 1 ? MetodosExtensao.RacaCorFormatado(Convert.ToInt32(codDetalhe[0])) : string.Empty;
                break;

            default:
                break;
            }
            return(retorno);
        }