// method to return arraylist of Element Options from JSON delivered by ClayUI Web Service
        public List<ElementOption> GetElementOptions()
        {
            List<ElementOption> options = new List<ElementOption>();

            try
            {
                JArray array = JArray.Parse(GetWebServiceData(this._uri));

                // loop through array, pull JSON objects out and push the values into App Part objects
                for (int i = 0; i < array.Count; i++)
                {
                    JObject jObject = JObject.Parse(array[i].ToString());
                    ElementOption option = new ElementOption(int.Parse(jObject["ElementOptionID"].ToString().Replace("\"", "")),
                        int.Parse(jObject["AppPartID"].ToString().Replace("\"", "")),
                        int.Parse(jObject["ElementID"].ToString().Replace("\"", "")),
                        jObject["Value"].ToString().Replace("\"", ""),
                        jObject["Description"].ToString().Replace("\"", ""),
                        int.Parse(jObject["Version"].ToString().Replace("\"", "")));

                    // add to arraylist
                    options.Add(option);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return options;
        }
        // method to add an element option object to database
        public ElementOption CreateElementOption(int elementOptionID, int appPartID, int elementID, string value,
            string description, int version)
        {
            using (this._conn = new SqlCeConnection(this._dbHelper.DatabaseConnStr))
            {
                try
                {
                    this._conn.Open();
                    SqlCeDataAdapter adp = new SqlCeDataAdapter();
                    SqlCeCommand cmd = this._conn.CreateCommand();
                    cmd.CommandText = "INSERT INTO " + ElementOptionDatabaseHelper.TABLE_NAME + " (" +
                        ElementOptionDatabaseHelper.COLUMN_ID + ", " +
                        ElementOptionDatabaseHelper.COLUMN_APP_PART_ID + ", " +
                        ElementOptionDatabaseHelper.COLUMN_ELEMENT_ID + ", " +
                        ElementOptionDatabaseHelper.COLUMN_VALUE + ", " +
                        ElementOptionDatabaseHelper.COLUMN_DESCRIPTION + ", " +
                        ElementOptionDatabaseHelper.COLUMN_VERSION + ") VALUES (" +
                        "@" + ElementOptionDatabaseHelper.COLUMN_ID + ", " +
                        "@" + ElementOptionDatabaseHelper.COLUMN_APP_PART_ID + ", " +
                        "@" + ElementOptionDatabaseHelper.COLUMN_ELEMENT_ID + ", " +
                        "@" + ElementOptionDatabaseHelper.COLUMN_VALUE + ", " +
                        "@" + ElementOptionDatabaseHelper.COLUMN_DESCRIPTION + ", " +
                        "@" + ElementOptionDatabaseHelper.COLUMN_VERSION + ")";
                    SqlCeParameter p_id = cmd.Parameters.Add("@" + ElementOptionDatabaseHelper.COLUMN_ID, SqlDbType.Int);
                    p_id.Value = elementOptionID;
                    SqlCeParameter p_appPartID = cmd.Parameters.Add("@" + ElementOptionDatabaseHelper.COLUMN_APP_PART_ID, SqlDbType.Int);
                    p_appPartID.Value = appPartID;
                    SqlCeParameter p_elementID = cmd.Parameters.Add("@" + ElementOptionDatabaseHelper.COLUMN_ELEMENT_ID, SqlDbType.Int);
                    p_elementID.Value = elementID;
                    SqlCeParameter p_value = cmd.Parameters.Add("@" + ElementOptionDatabaseHelper.COLUMN_VALUE, SqlDbType.NVarChar);
                    p_value.Value = value;
                    SqlCeParameter p_descr = cmd.Parameters.Add("@" + ElementOptionDatabaseHelper.COLUMN_DESCRIPTION, SqlDbType.NVarChar);
                    p_descr.Value = description;
                    SqlCeParameter p_version = cmd.Parameters.Add("@" + ElementOptionDatabaseHelper.COLUMN_VERSION, SqlDbType.Int);
                    p_version.Value = version;
                    adp.InsertCommand = cmd;

                    DataSet ds = new DataSet();
                    adp.Fill(ds);

                    DataTable table = ds.Tables[0];
                    DataRow row = table.Rows[0];
                    ElementOption option = DataRowToElementOption(row);
                    ds.Dispose();
                    return option;
                }
                catch (Exception e)
                {
                    ElementOption option = new ElementOption(0, 0, 0, "", "", 0);
                    Console.WriteLine(e.Message);
                    return option;
                }
            }
        }
        // method to return a list array of element options
        public List<ElementOption> GetAllElementOptions()
        {
            List<ElementOption> elementOptions = new List<ElementOption>();

            using (this._conn = new SqlCeConnection(this._dbHelper.DatabaseConnStr))
            {
                try
                {
                    this._conn.Open();
                    SqlCeDataAdapter adp = new SqlCeDataAdapter();
                    SqlCeCommand cmd = this._conn.CreateCommand();
                    cmd.CommandText = "SELECT " + ElementOptionDatabaseHelper.COLUMN_ID + ", " +
                        ElementOptionDatabaseHelper.COLUMN_APP_PART_ID + ", " +
                        ElementOptionDatabaseHelper.COLUMN_ELEMENT_ID + ", " +
                        ElementOptionDatabaseHelper.COLUMN_VALUE + ", " +
                        ElementOptionDatabaseHelper.COLUMN_DESCRIPTION + ", " +
                        ElementOptionDatabaseHelper.COLUMN_VERSION + " FROM " +
                        ElementOptionDatabaseHelper.TABLE_NAME;
                    adp.SelectCommand = cmd;

                    DataSet ds = new DataSet();
                    adp.Fill(ds);

                    foreach (DataTable table in ds.Tables)
                    {
                        foreach (DataRow row in table.Rows)
                        {
                            ElementOption option = DataRowToElementOption(row);
                            elementOptions.Add(option);
                        }
                    }

                    ds.Dispose();
                    return elementOptions;
                }
                catch (Exception e)
                {
                    ElementOption option = new ElementOption(0, 0, 0, "", "", 0);
                    elementOptions.Add(option);
                    Console.WriteLine(e.Message);
                    return elementOptions;
                }
            }
        }