Example #1
0
        public static List<RangePriceGroup> List(Range Range)
        {
            List<RangePriceGroup> result = new List<RangePriceGroup> ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns ("id");
            qb.AddWhere ("rangeid", "=", Range.Id);

            Query query = Runtime.DBConnection.Query (qb.QueryString);
            if (query.Success)
            {
                while (query.NextRow ())
                {
                    try
                    {
                        result.Add (Load (query.GetGuid (qb.ColumnPos ("id"))));
                    }
                    catch
                    {}
                }
            }

            query.Dispose ();
            query = null;
            qb = null;

            return result;
        }
Example #2
0
        public static Range Load(Guid Id)
        {
            bool success = false;
            Range result = new Range ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns (
                "id",
                "createtimestamp",
                "updatetimestamp",
                "costrangepricegroupids",
                "retailrangepricegroupids",
                "name",
                "dialcode"
                );

            qb.AddWhere ("id", "=", Id);

            Query query = Runtime.DBConnection.Query (qb.QueryString);

            if (query.Success)
            {
                if (query.NextRow ())
                {
                    result._id = query.GetGuid (qb.ColumnPos ("id"));
                    result._createtimestamp = query.GetInt (qb.ColumnPos ("createtimestamp"));
                    result._updatetimestamp = query.GetInt (qb.ColumnPos ("updatetimestamp"));
                    result._costrangepricegroupsasstring = query.GetString (qb.ColumnPos ("costrangepricegroupids"));
                    result._retailpricegroupsasstring = query.GetString (qb.ColumnPos ("retailrangepricegroupids"));
                    result._name = query.GetString (qb.ColumnPos ("name"));
                    result._dialcode = query.GetString (qb.ColumnPos ("dialcode"));

                    success = true;
                }
            }

            query.Dispose ();
            query = null;
            qb = null;

            if (!success)
            {
                throw new Exception (string.Format (Strings.Exception.RangeLoad, Id));
            }

            return result;
        }