/// <summary> /// This method inserts a 'LastName' object. /// This method uses the 'LastName_Insert' procedure. /// </summary> /// <returns>The identity value of the new record.</returns> /// </summary> public int InsertLastName(InsertLastNameStoredProcedure insertLastNameProc, DataConnector databaseConnector) { // Initial Value int newIdentity = -1; // Verify database connection is connected if ((databaseConnector != null) && (databaseConnector.Connected)) { // Execute Non Query newIdentity = this.DataHelper.InsertRecord(insertLastNameProc, databaseConnector); } // return value return(newIdentity); }
/// <summary> /// This method inserts a 'LastName' object. /// </summary> /// <param name='List<PolymorphicObject>'>The 'LastName' to insert. /// <returns>A PolymorphicObject object with a Boolean value. internal PolymorphicObject InsertLastName(List <PolymorphicObject> parameters, DataConnector dataConnector) { // Initial Value PolymorphicObject returnObject = new PolymorphicObject(); // locals LastName lastName = null; // If the data connection is connected if ((dataConnector != null) && (dataConnector.Connected == true)) { // Create Insert StoredProcedure InsertLastNameStoredProcedure insertLastNameProc = null; // verify the first parameters is a(n) 'LastName'. if (parameters[0].ObjectValue as LastName != null) { // Create LastName Parameter lastName = (LastName)parameters[0].ObjectValue; // verify lastName exists if (lastName != null) { // Now create insertLastNameProc from LastNameWriter // The DataWriter converts the 'LastName' // to the SqlParameter[] array needed to insert a 'LastName'. insertLastNameProc = LastNameWriter.CreateInsertLastNameStoredProcedure(lastName); } // Verify insertLastNameProc exists if (insertLastNameProc != null) { // Execute Insert Stored Procedure returnObject.IntegerValue = this.DataManager.LastNameManager.InsertLastName(insertLastNameProc, dataConnector); } } else { // Raise Error Data Connection Not Available throw new Exception("The database connection is not available."); } } // return value return(returnObject); }
/// <summary> /// This method creates an instance of an /// 'InsertLastNameStoredProcedure' object and /// creates the sql parameter[] array needed /// to execute the procedure 'LastName_Insert'. /// </summary> /// <param name="lastName"The 'LastName' object to insert</param> /// <returns>An instance of a 'InsertLastNameStoredProcedure' object.</returns> public static InsertLastNameStoredProcedure CreateInsertLastNameStoredProcedure(LastName lastName) { // Initial Value InsertLastNameStoredProcedure insertLastNameStoredProcedure = null; // verify lastName exists if (lastName != null) { // Instanciate insertLastNameStoredProcedure insertLastNameStoredProcedure = new InsertLastNameStoredProcedure(); // Now create parameters for this procedure insertLastNameStoredProcedure.Parameters = CreateInsertParameters(lastName); } // return value return(insertLastNameStoredProcedure); }