Esempio n. 1
0
        public static RangePrice FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);

            RangePrice result;

            if (item.ContainsKey ("id"))
            {
                try
                {
                    result = RangePrice.Load (new Guid ((string)item["id"]));
                }
                catch
                {
                    result = new RangePrice ();
                    result._id = new Guid ((string)item["id"]);
                }
            }
            else
            {
                result = new RangePrice ();
            }

            if (item.ContainsKey ("type"))
            {
                result._type = SNDK.Convert.StringToEnum<Enums.RangePriceType> ((string)item["type"]);
            }

            if (item.ContainsKey ("callcharge"))
            {
                result._callcharge = decimal.Parse ((string)item["callcharge"]);
            }

            if (item.ContainsKey ("price"))
            {
                result._price = decimal.Parse ((string)item["price"]);
            }

            if (item.ContainsKey ("validfrom"))
            {
                result._validfrom = DateTime.Parse ((string)item["validfrom"]);
            }

            if (item.ContainsKey ("validto"))
            {
                result._validto = DateTime.Parse ((string)item["validto"]);
            }

            if (item.ContainsKey ("hourbegin"))
            {
                result._hourbegin = (string)item["hourbegin"];
            }

            if (item.ContainsKey ("hourend"))
            {
                result._hourend = (string)item["hourend"];
            }

            if (item.ContainsKey ("weekdays"))
            {
                result._weekdays = SNDK.Convert.StringToEnum<Enums.Weekday> ((string)item["weekdays"]);
            }

            return result;
        }
Esempio n. 2
0
        public static RangePrice Load(Guid Id)
        {
            bool success = false;
            RangePrice result = new RangePrice ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns
                (
                    "id",
                    "createtimestamp",
                    "updatetimestamp",
                    "type",
                    "validfrom",
                    "validto",
                    "callcharge",
                    "price",
                    "hourbegin",
                    "hourend",
                    "weekdays"
                );

            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._validfrom = query.GetDateTime (qb.ColumnPos ("validfrom"));
            //					result._validto  = query.GetDateTime (qb.ColumnPos ("validto"));
                    result._type = query.GetEnum<Enums.RangePriceType> (qb.ColumnPos ("type"));
                    result._validfrom = SNDK.Date.TimestampToDateTime (query.GetInt (qb.ColumnPos ("validfrom")));
                    result._validto = SNDK.Date.TimestampToDateTime (query.GetInt (qb.ColumnPos ("validto")));
                    result._callcharge = query.GetDecimal (qb.ColumnPos ("callcharge"));
                    result._price = query.GetDecimal (qb.ColumnPos ("price"));
                    result._hourbegin = query.GetString (qb.ColumnPos ("hourbegin"));
                    result._hourend = query.GetString (qb.ColumnPos ("hourend"));
                    result._weekdays = query.GetEnum<Enums.Weekday> (qb.ColumnPos ("weekdays"));

                    success = true;
                }
            }

            query.Dispose ();

            query = null;
            qb = null;

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

            return result;
        }
Esempio n. 3
0
        public static RangePrice FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);

            RangePrice result;

            if (item.ContainsKey ("id"))
            {
                try
                {
                    result = RangePrice.Load (new Guid ((string)item["id"]));
                }
                catch
                {
                    result = new RangePrice ();
                    result._id = new Guid ((string)item["id"]);
                }
            }
            else
            {
                result = new RangePrice ();
            }

            if (item.ContainsKey ("hourspanbegin"))
            {
                result._hourspanbegin = (string)item["hourspanbegin"];
            }

            if (item.ContainsKey ("hourspanend"))
            {
                result._hourspanend = (string)item["hourspanends"];
            }

            if (item.ContainsKey ("price"))
            {
                result._price = decimal.Parse ((string)item["price"]);
            }

            if (item.ContainsKey ("weekdays"))
            {
                result._weekdays = SNDK.Convert.StringToEnum<Enums.Weekday> ((string)item["weekdays"]);
            }

            return result;
        }