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

            // Create field Integers
            int activefield      = 0;
            int namefield        = 1;
            int procedureIdfield = 2;
            int projectIdfield   = 3;
            int tableIdfield     = 4;

            try
            {
                // Load Each field
                dTNProcedure.Active = DataHelper.ParseBoolean(dataRow.ItemArray[activefield], false);
                dTNProcedure.Name   = DataHelper.ParseString(dataRow.ItemArray[namefield]);
                dTNProcedure.UpdateIdentity(DataHelper.ParseInteger(dataRow.ItemArray[procedureIdfield], 0));
                dTNProcedure.ProjectId = DataHelper.ParseInteger(dataRow.ItemArray[projectIdfield], 0);
                dTNProcedure.TableId   = DataHelper.ParseInteger(dataRow.ItemArray[tableIdfield], 0);
            }
            catch
            {
            }

            // return value
            return(dTNProcedure);
        }
Пример #2
0
        /// <summary>
        /// Saves a 'DTNProcedure' object into the database.
        /// This method calls the 'Insert' or 'Update' method.
        /// </summary>
        /// <param name='dTNProcedure'>The 'DTNProcedure' object to save.</param>
        /// <returns>True if successful or false if not.</returns>
        public bool Save(ref DTNProcedure dTNProcedure)
        {
            // Initial value
            bool saved = false;

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

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

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

            // return value
            return(saved);
        }