Пример #1
0
        public List <OfertaFase> Obtener_OfertaFaseActivas(int idOferta)
        {
            List <OfertaFase> listaOfertaFase = new List <OfertaFase>();

            DataTable dtResultado = adOferta.Obtener_OfertaFase(idOferta);

            foreach (DataRow fila in dtResultado.Rows)
            {
                if (Convert.ToBoolean(fila["Incluir"]))
                {
                    OfertaFase oFase = new OfertaFase();
                    oFase.IdOfertaFase = Convert.ToInt32(fila["IdOfertaFase"]);
                    oFase.IdOferta     = Convert.ToInt32(fila["IdOfertaFase"]);
                    oFase.Incluir      = Convert.ToBoolean(fila["Incluir"]);
                    oFase.IdListaValor = Convert.ToString(fila["IdListaValor"]);
                    oFase.FaseOferta   = Convert.ToString(fila["FaseOferta"]);

                    listaOfertaFase.Add(oFase);
                }
            }

            return(listaOfertaFase);
        }
        public int Insertar(Oferta oferta)
        {
            try
            {
                if (oferta.Funciones == null)
                {
                    oferta.Funciones = string.Empty;
                }
                if (oferta.Competencias == null)
                {
                    oferta.Competencias = string.Empty;
                }
                if (oferta.AreaEmpresa == null)
                {
                    oferta.AreaEmpresa = string.Empty;
                }
                if (oferta.TipoCargoIdListaValor == null)
                {
                    oferta.TipoCargoIdListaValor = string.Empty;
                }
                if (oferta.TipoContratoIdListaValor == null)
                {
                    oferta.TipoContratoIdListaValor = string.Empty;
                }
                if (oferta.Horario == null)
                {
                    oferta.Horario = string.Empty;
                }

                #region Se llena una lista con todas las fases de la oferta. Se marca las que van de manera obligatoria

                LNGeneral lnGeneral            = new LNGeneral();
                var       listaFasesDeLaOferta = lnGeneral.ObtenerListaValor(Constantes.IDLISTA_FASE_OFERTA).Where(m => m.EstadoValor.Equals(Constantes.Estado_Activo_ListaValor)).OrderBy(m => m.Peso);

                List <OfertaFase> listaOfertaFase = new List <OfertaFase>();

                foreach (var item in listaFasesDeLaOferta)
                {
                    OfertaFase nuevaOfertaFase = new OfertaFase();
                    nuevaOfertaFase.IdListaValor = item.IdListaValor;
                    nuevaOfertaFase.IdOferta     = 0;

                    //Al realizar las inserciones existen 4 fases que van obligatoriamente.
                    if (item.IdListaValor == "OFFAPR" || item.IdListaValor == "OFFACV" || item.IdListaValor == "OFFAFI" || item.IdListaValor == "OFFADE")
                    {
                        nuevaOfertaFase.Incluir = true;
                    }
                    else
                    {
                        nuevaOfertaFase.Incluir = false;
                    }

                    nuevaOfertaFase.CreadoPor = oferta.CreadoPor;

                    listaOfertaFase.Add(nuevaOfertaFase);
                }

                #endregion

                return(adOferta.Insertar(oferta, listaOfertaFase));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }