protected void addPageNameButton_Click( object sender, EventArgs e ) { PageSummaryView ps = (PageSummaryView)Session["Page" + pageIdTextBox.Text]; PageName pn = new PageName(); pn.PageID = ps.PageID; CustomGenericList<PageName> pageNames = (CustomGenericList<PageName>)Session["PageNames" + pageIdTextBox.Text]; pageNames.Add( pn ); pageNameList.EditIndex = pageNames.Count - 1; bindPageNameData( false ); }
/// <summary> /// Update values in PageName. Returns an object of type PageName. /// </summary> /// <param name="sqlConnection">Sql connection or null.</param> /// <param name="sqlTransaction">Sql transaction or null.</param> /// <param name="value">Object of type PageName.</param> /// <returns>Object of type PageName.</returns> public PageName PageNameUpdateAuto( SqlConnection sqlConnection, SqlTransaction sqlTransaction, PageName value) { return PageNameUpdateAuto(sqlConnection, sqlTransaction, value.PageNameID, value.PageID, value.Source, value.NameFound, value.NameConfirmed, value.NameBankID, value.Active, value.IsCommonName); }
/// <summary> /// Manage PageName object. /// If the object is of type CustomObjectBase, /// then either insert values into, delete values from, or update values in PageName. /// </summary> /// <param name="sqlConnection">Sql connection or null.</param> /// <param name="sqlTransaction">Sql transaction or null.</param> /// <param name="value">Object of type PageName.</param> /// <returns>Object of type CustomDataAccessStatus<PageName>.</returns> public CustomDataAccessStatus<PageName> PageNameManageAuto( SqlConnection sqlConnection, SqlTransaction sqlTransaction, PageName value) { if (value.IsNew && !value.IsDeleted) { PageName returnValue = PageNameInsertAuto(sqlConnection, sqlTransaction, value.PageID, value.Source, value.NameFound, value.NameConfirmed, value.NameBankID, value.Active, value.IsCommonName); return new CustomDataAccessStatus<PageName>( CustomDataAccessContext.Insert, true, returnValue); } else if (!value.IsNew && value.IsDeleted) { if (PageNameDeleteAuto(sqlConnection, sqlTransaction, value.PageNameID)) { return new CustomDataAccessStatus<PageName>( CustomDataAccessContext.Delete, true, value); } else { return new CustomDataAccessStatus<PageName>( CustomDataAccessContext.Delete, false, value); } } else if (value.IsDirty && !value.IsDeleted) { PageName returnValue = PageNameUpdateAuto(sqlConnection, sqlTransaction, value.PageNameID, value.PageID, value.Source, value.NameFound, value.NameConfirmed, value.NameBankID, value.Active, value.IsCommonName); return new CustomDataAccessStatus<PageName>( CustomDataAccessContext.Update, true, returnValue); } else { return new CustomDataAccessStatus<PageName>( CustomDataAccessContext.NA, false, value); } }
public PageName PageNameInsertAuto( PageName value ) { return GetPageNameDalInstance().PageNameInsertAuto( null, null, value ); }
/// <summary> /// For each page name in the list, it inserts a new row in the database or /// or updates an existing row. Then, any previously-existing rows that /// were not updated are set to inactive. /// </summary> /// <param name="pageID">Identifier of the page whose page names are being updated</param> /// <param name="items">List of page names</param> public int[] PageNameUpdateList( int pageID, FindItItem[] items ) { int[] updateStats = new int[ 4 ]; foreach ( FindItItem item in items ) { PageName pageName = this.PageNameSelectByPageIDAndNameFound( pageID, item.Name ); if ( pageName == null ) { // Insert new page name pageName = new PageName(); pageName.NameFound = item.Name; pageName.NameConfirmed = item.Name; pageName.NameBankID = item.NamebankID; if ( pageName.NameBankID <= 0 ) pageName.NameBankID = null; pageName.Active = !( pageName.NameBankID == null ); pageName.PageID = pageID; pageName.Source = "uBio"; pageName.IsCommonName = false; this.PageNameInsertAuto( pageName ); updateStats[ 0 ]++; // number inserted } else { // Update existing page name if the namebankid has changed if ( ( pageName.NameBankID ?? 0 ) != item.NamebankID ) { pageName.NameBankID = item.NamebankID; if ( pageName.NameBankID <= 0 ) pageName.NameBankID = null; pageName.Active = !( pageName.NameBankID == null ); this.PageNameUpdateAuto( pageName ); updateStats[ 1 ]++; // number updated } else { updateStats[ 3 ]++; // number unchanged } } } // Deactivate any names that are in the database, but were not not returned // by the just-completed UBIO request (this means they've fallen out of the // list of page names for this page) CustomGenericList<PageName> pageNames = this.PageNameSelectByPageID( pageID ); foreach ( PageName pageName in pageNames ) { if ( !this.PageNameIsInList( pageName.NameFound, items ) ) { if ( pageName.NameBankID != null ) { pageName.Active = false; pageName.NameBankID = null; this.PageNameUpdateAuto( pageName ); updateStats[ 2 ]++; // number deleted } else { updateStats[ 3 ]++; // number unchanged } } } return updateStats; }