Esempio n. 1
0
File: OS.cs Progetto: sundowndk/qnax
        public static OS Load(Guid Id)
        {
            bool success = false;
            OS result = new OS ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns
                (
                    "id",
                    "name"
                );

            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._name = query.GetString (qb.ColumnPos ("name"));

                    success = true;
                }
            }

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

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

            return result;
        }
Esempio n. 2
0
File: OS.cs Progetto: sundowndk/qnax
        public static OS FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);

            OS result;

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

            if (item.ContainsKey ("name"))
            {
                result.Name = (string)item["name"];
            }

            return result;
        }