예제 #1
0
        public static clsEmpresaCompetencia BuscarEmpresaCompetenciaPorId(Int64 Id)
        {
            ResultadoTransaccion  res     = BuscarEmpresCompetencia(Id, "-1");
            clsEmpresaCompetencia empresa = new clsEmpresaCompetencia();

            if (res.Estado == Entidades.Enums.Enums.EstadoTransaccion.Aceptada)
            {
                empresa = (clsEmpresaCompetencia)res.ObjetoTransaccion;
            }
            else
            {
                return(null);
            }

            return(empresa);
        }
예제 #2
0
        private static ResultadoTransaccion BuscarEmpresCompetencia(Int64 Id, string nombre)
        {
            ResultadoTransaccion  res     = new ResultadoTransaccion();
            clsEmpresaCompetencia empresa = null;

            try
            {
                //Abrir Conexion
                conn = BaseDatos.NuevaConexion();

                objParams          = SqlHelperParameterCache.GetSpParameterSet(conn, "SP_C_CLIENTES_TARGET_EMPRESA_COMPETENCIA");
                objParams[0].Value = Id;
                objParams[1].Value = nombre;

                SqlCommand command = new SqlCommand("SP_C_CLIENTES_TARGET_EMPRESA_COMPETENCIA", conn);
                command.Parameters.AddRange(objParams);
                command.CommandType = CommandType.StoredProcedure;
                dreader             = command.ExecuteReader();

                while (dreader.Read())
                {
                    empresa               = new clsEmpresaCompetencia();
                    empresa.Id            = Convert.ToInt64(dreader[0]);
                    empresa.Nombre        = dreader[1].ToString();
                    empresa.FechaCreacion = (DateTime)dreader[2];
                }

                res.Estado            = Entidades.Enums.Enums.EstadoTransaccion.Aceptada;
                res.Accion            = Entidades.Enums.Enums.AccionTransaccion.Consultar;
                res.ObjetoTransaccion = empresa;
            }
            catch (Exception ex)
            {
                res.Estado      = Entidades.Enums.Enums.EstadoTransaccion.Rechazada;
                res.Descripcion = ex.Message;
            }
            finally
            {
                conn.Close();
            }

            return(res);
        }