Пример #1
0
        protected void DataPortal_Fetch(object criteria)
        {
            //crear la conexion a la base
            if (Db == null)
            {
                Db = DatabaseFactory.CreateDatabase();
            }
            Comando = Db.CreateSPCommand(ObtenerSp);

            //setear los parametros
            MethodInfo methodInfo = GetType().GetMethod(_nombreMetodo, BindingFlags.NonPublic | BindingFlags.Instance,
                Type.DefaultBinder, new[] {criteria.GetType()}, null);
            if (methodInfo != null)
            {
                methodInfo.Invoke(this, new[] {criteria});
            }
            else
            {
                if (criteria is int)
                {
                    Db.AddParameterWithValue(Comando, "en_id", DbType.Int32, criteria);
                }
                else if (criteria is string)
                {

                    Db.AddParameterWithValue(Comando, "ec_codigo", DbType.String, criteria);
                }
                else
                {
                    throw new JusException(
                        String.Format("No se implemento el metodo {0}, Ej: 'private void {0}({1} criteria)'",
                            _nombreMetodo, criteria.GetType()));
                }
            }
            Db.AddParameter(Comando, "sq_resultado", DbType.Object, ParameterDirection.Output);
            using (var dr = Db.ExecuteDataReader(Comando))

                while (dr.Read())
                {
                    AddCommonData(dr);
                    Fetch(dr);
                    if (dr.NextResult())
                    {
                        throw new JusException("Existe mas de un resultado");
                    }
                }
        }
Пример #2
0
        protected void DataPortal_Fetch(int id)
        {
            RaiseListChangedEvents = false;

            //crear la conexion a la base
            if (Db == null)
            {
                Db = DatabaseFactory.CreateDatabase();
            }
            Comando = Db.CreateSPCommand(NombreProcedimiento);
            Db.AddParameterWithValue(Comando, "en_padre", DbType.Int32, id);
            Db.AddParameter(Comando, "sq_resultado", DbType.Object, ParameterDirection.Output);

            using (IDataReader dr = Db.ExecuteDataReader(Comando))
            {
                while (dr.Read())
                {
                    Add(JusBusinessBaseEChild <TS> .Get(dr));
                }
            }
            RaiseListChangedEvents = true;
        }