Exemple #1
0
        /// <summary>
        /// This method loads a 'FieldSet' object
        /// from the dataRow passed in.
        /// </summary>
        /// <param name='dataRow'>The 'DataRow' to load from.</param>
        /// <returns>A 'FieldSet' DataObject.</returns>
        public static FieldSet Load(DataRow dataRow)
        {
            // Initial Value
            FieldSet fieldSet = new FieldSet();

            // Create field Integers
            int databaseIdfield    = 0;
            int fieldSetIdfield    = 1;
            int namefield          = 2;
            int orderByModefield   = 3;
            int parameterModefield = 4;
            int projectIdfield     = 5;
            int readerModefield    = 6;
            int tableIdfield       = 7;

            try
            {
                // Load Each field
                fieldSet.DatabaseId = DataHelper.ParseInteger(dataRow.ItemArray[databaseIdfield], 0);
                fieldSet.UpdateIdentity(DataHelper.ParseInteger(dataRow.ItemArray[fieldSetIdfield], 0));
                fieldSet.Name          = DataHelper.ParseString(dataRow.ItemArray[namefield]);
                fieldSet.OrderByMode   = DataHelper.ParseBoolean(dataRow.ItemArray[orderByModefield], false);
                fieldSet.ParameterMode = DataHelper.ParseBoolean(dataRow.ItemArray[parameterModefield], false);
                fieldSet.ProjectId     = DataHelper.ParseInteger(dataRow.ItemArray[projectIdfield], 0);
                fieldSet.ReaderMode    = DataHelper.ParseBoolean(dataRow.ItemArray[readerModefield], false);
                fieldSet.TableId       = DataHelper.ParseInteger(dataRow.ItemArray[tableIdfield], 0);
            }
            catch
            {
            }

            // return value
            return(fieldSet);
        }
        /// <summary>
        /// Saves a 'FieldSet' object into the database.
        /// This method calls the 'Insert' or 'Update' method.
        /// </summary>
        /// <param name='fieldSet'>The 'FieldSet' object to save.</param>
        /// <returns>True if successful or false if not.</returns>
        public bool Save(ref FieldSet fieldSet)
        {
            // Initial value
            bool saved = false;

            // If the fieldSet exists.
            if (fieldSet != null)
            {
                // Is this a new FieldSet
                if (fieldSet.IsNew)
                {
                    // Insert new FieldSet
                    int newIdentity = this.Insert(fieldSet);

                    // if insert was successful
                    if (newIdentity > 0)
                    {
                        // Update Identity
                        fieldSet.UpdateIdentity(newIdentity);

                        // Set return value
                        saved = true;
                    }
                }
                else
                {
                    // Update FieldSet
                    saved = this.Update(fieldSet);
                }
            }

            // return value
            return(saved);
        }