Esempio n. 1
0
        public static SubscriptionItem FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item;
            SubscriptionItem result = new SubscriptionItem ();

            try
            {
                item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (xmlDocument.SelectSingleNode ("(//allectuslib.subscriptionitem)[1]")));
            }
            catch
            {
                item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);
            }

            if (item.ContainsKey ("id"))
            {
                result._id = new Guid ((string)item["id"]);
            }
            else
            {
                throw new Exception (string.Format (Strings.Exception.SubscriptionItemFromXmlDocument, "ID"));
            }

            if (item.ContainsKey ("createtimestamp"))
            {
                result._createtimestamp = int.Parse ((string)item["createtimestamp"]);
            }

            if (item.ContainsKey ("updatetimestamp"))
            {
                result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]);
            }

            if (item.ContainsKey ("subscriptionid"))
            {
                result._subscriptionid = new Guid ((string)item["subscriptionid"]);
            }
            else
            {
                throw new Exception (string.Format (Strings.Exception.SubscriptionItemFromXmlDocument, "SUBSCRIPTIONID"));
            }

            if (item.ContainsKey ("erpid"))
            {
                result._erpid = (string)item["erpid"];
            }

            if (item.ContainsKey ("recurrencetype"))
            {
                result._recurrencetype = SNDK.Convert.StringToEnum<Enums.ItemRecurrenceType> ((string)item["recurrencetype"]);
            }

            if (item.ContainsKey ("recurrencecount"))
            {
                result._recurrencecount = int.Parse ((string)item["recurrencecount"]);
            }

            if (item.ContainsKey ("text"))
            {
                result._text = (string)item["text"];
            }

            if (item.ContainsKey ("unit"))
            {
                result._unit = (string)item["unit"];
            }

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

            if (item.ContainsKey ("notes"))
            {
                result._notes = (string)item["notes"];
            }

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

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns
                (
                    "id",
                    "createtimestamp",
                    "updatetimestamp",
                    "subscriptionid",
                    "erpid",
                    "recurrencetype",
                    "recurrencecount",
                    "text",
                    "unit",
                    "price",
                    "notes"
                    );

            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._subscriptionid = query.GetGuid (qb.ColumnPos ("subscriptionid"));
                    result._erpid = query.GetString (qb.ColumnPos ("erpid"));
                    result._recurrencetype = SNDK.Convert.IntToEnum<Enums.ItemRecurrenceType> (query.GetInt (qb.ColumnPos ("recurrencetype")));
                    result._recurrencecount = query.GetInt (qb.ColumnPos ("recurrencecount"));
                    result._text = query.GetString (qb.ColumnPos ("text"));
                    result._unit = query.GetString (qb.ColumnPos ("unit"));
                    result._price = query.GetDecimal (qb.ColumnPos ("price"));
                    result._notes = query.GetString (qb.ColumnPos ("notes"));

                    success = true;
                }
            }

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

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

            return result;
        }
Esempio n. 3
0
 public static void Delete(SubscriptionItem SubscriptionItem)
 {
     Delete (SubscriptionItem.Id);
 }