public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction, Institution institution) { SqlConnection connection = sqlConnection; SqlTransaction transaction = sqlTransaction; if ( connection == null ) { connection = CustomSqlHelper.CreateConnection( CustomSqlHelper.GetConnectionStringFromConnectionStrings( "BHL" ) ); } bool isTransactionCoordinator = CustomSqlHelper.IsTransactionCoordinator( transaction ); try { transaction = CustomSqlHelper.BeginTransaction( connection, transaction, isTransactionCoordinator ); new InstitutionDAL().InstitutionManageAuto( connection, transaction, institution ); CustomSqlHelper.CommitTransaction( transaction, isTransactionCoordinator ); } catch ( Exception ex ) { CustomSqlHelper.RollbackTransaction( transaction, isTransactionCoordinator ); throw new Exception( "Exception in Save", ex ); } finally { CustomSqlHelper.CloseConnection( connection, isTransactionCoordinator ); } }
protected void Page_Load(object sender, EventArgs e) { //Master.Page.Header.Controls.Add( ControlGenerator.GetScriptControl( "/Scripts/Ubio.js" ) ); Master.Page.Header.Controls.Add(ControlGenerator.GetScriptControl("/Scripts/BotanicusDropInViewerUtils.js")); //Master.Page.Header.Controls.Add( ControlGenerator.GetScriptControl( "/Scripts/Highlighter.js" ) ); pageListContentPanel.SetTableID("pageListTable"); namesListContentPanel.SetTableID("nameListTable"); //ControlGenerator.AddScriptControl(Page.Master.Page.Header.Controls, "/Scripts/ResizeContentPanelUtils.js"); ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onload", "SetContentPanelWidth('pageListTable', 250);SetContentPanelWidth('nameListTable', 250);"); ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onresize", "resizeViewerHeight(157);"); main.SetPageType(Main.PageType.TitleViewer); main.HideOverflow(); if (!Page.IsPostBack) { PageSummaryView ps = null; if ((Request["BibId"] != null) && ((Request["volume"] != null) || (Request["issue"] != null) || (Request["year"] != null) || (Request["startpage"] != null)) && Request["resolved"] == null) { Response.Redirect("PageResolve.aspx?" + Request.ServerVariables["QUERY_STRING"]); } if (ps == null) { if (Request.QueryString["pageid"] != null) { int pageid; if (int.TryParse(Request.QueryString["pageid"], out pageid)) { ps = bhlProvider.PageSummarySelectByPageId(pageid); } } else if (Request.QueryString["titleid"] != null) { int titleid; if (int.TryParse(Request.QueryString["titleid"], out titleid)) { // Check to make sure this title hasn't been replaced. If it has, redirect // to the appropriate titleid. Title title = bhlProvider.TitleSelect(titleid); if (title.RedirectTitleID != null) { Response.Redirect("/title/" + title.RedirectTitleID.ToString()); Response.End(); } ps = bhlProvider.PageTitleSummarySelectByTitleId(titleid); } } else if (Request.QueryString["itemid"] != null) { int itemid; if (int.TryParse(Request.QueryString["itemid"], out itemid)) { ps = bhlProvider.PageSummarySelectByItemId(itemid); } } else if (Request["BibId"] != null) { ps = bhlProvider.PageTitleSummarySelectByBibID(Request["bibID"].ToString()); } else if (Request["Barcode"] != null) { ps = bhlProvider.PageSummarySelectByBarcode(Request["Barcode"].ToString()); } else if (Request["Prefix"] != null) { ps = bhlProvider.PageSummarySelectByPrefix(Request["Prefix"].ToString()); } } if (ps != null) { hidItemID.Value = ps.ItemID.ToString(); ControlGenerator.AddAttributesAndPreserveExisting(main.Body, "onload", "changePage(" + ps.SequenceOrder + ");resizeViewerHeight(157);"); } else { // if our PageSummaryView is still null, then redirect because we couldn't find the requested title. Response.Redirect("/TitleNotFound.aspx"); Response.End(); } if (ps != null) { Master.Page.Title = "Biodiversity Heritage Library: " + ps.ShortTitle; // Set the item for the COinS COinSControl1.ItemID = ps.ItemID; CustomGenericList <MOBOT.BHL.DataObjects.Page> pages = bhlProvider.PageMetadataSelectByItemID(ps.ItemID); pageListBox.DataTextField = "WebDisplay"; pageListBox.DataValueField = "PageID"; pageListBox.DataSource = pages; pageListBox.DataBind(); int totalPageCount = bhlProvider.PageSelectCountByItemID(ps.ItemID); hidSequenceMax.Value = totalPageCount.ToString(); hidPageID.Value = ps.PageID.ToString(); pageLink.InnerText = "/page/" + ps.PageID.ToString(); titleVolumeSelectionControl.PopulateControl(ps); Data.Institution institution = bhlProvider.InstitutionSelectByItemID(ps.ItemID); if (institution != null) { if (institution.InstitutionUrl != null && institution.InstitutionUrl.Trim().Length > 0) { HyperLink link = new HyperLink(); link.Text = institution.InstitutionName; link.NavigateUrl = institution.InstitutionUrl; link.Target = "_blank"; attributionPlaceHolder.Controls.Add(link); } else { Literal literal = new Literal(); literal.Text = institution.InstitutionName; attributionPlaceHolder.Controls.Add(literal); } string attributionDivAttributesString = ""; if (BrowserUtility.IsBrowserIE6OrBelow(Request)) { attributionDivAttributesString = ConfigurationManager.AppSettings["attributionDivPropertiesIE6"]; } else { attributionDivAttributesString = ConfigurationManager.AppSettings["attributionDivPropertiesDefault"]; } string[] attributionDivAttributeParts = attributionDivAttributesString.Split('|'); attributionDiv.Style.Add("position", attributionDivAttributeParts[0]); attributionDiv.Style.Add("bottom", attributionDivAttributeParts[1]); } } } }
public void SaveInstitution( Institution institution ) { InstitutionDAL.Save( null, null, institution ); }
private void fillCombos() { BHLProvider bp = new BHLProvider(); CustomGenericList<Institution> institutions = bp.InstituationSelectAll(); Institution emptyInstitution = new Institution(); emptyInstitution.InstitutionCode = ""; emptyInstitution.InstitutionName = ""; institutions.Insert(0, emptyInstitution); ddlInst.DataSource = institutions; ddlInst.DataTextField = "InstitutionName"; ddlInst.DataValueField = "InstitutionCode"; ddlInst.DataBind(); CustomGenericList<Language> languages = bp.LanguageSelectAll(); Language emptyLanguage = new Language(); emptyLanguage.LanguageCode = ""; emptyLanguage.LanguageName = ""; languages.Insert( 0, emptyLanguage ); ddlLang.DataSource = languages; ddlLang.DataTextField = "LanguageName"; ddlLang.DataValueField = "LanguageCode"; ddlLang.DataBind(); CustomGenericList<Vault> vaults = bp.VaultSelectAll(); Vault emptyVault = new Vault(); emptyVault.VaultID = 0; emptyVault.Description = ""; vaults.Insert( 0, emptyVault ); ddlVault.DataSource = vaults; ddlVault.DataTextField = "Description"; ddlVault.DataValueField = "VaultID"; ddlVault.DataBind(); CustomGenericList<ItemStatus> itemStatuses = bp.ItemStatusSelectAll(); ddlItemStatus.DataSource = itemStatuses; ddlItemStatus.DataTextField = "ItemStatusName"; ddlItemStatus.DataValueField = "ItemStatusID"; ddlItemStatus.DataBind(); }
/// <summary> /// Update values in Institution. Returns an object of type Institution. /// </summary> /// <param name="sqlConnection">Sql connection or null.</param> /// <param name="sqlTransaction">Sql transaction or null.</param> /// <param name="connectionKeyName">Connection key name located in config file.</param> /// <param name="value">Object of type Institution.</param> /// <returns>Object of type Institution.</returns> public Institution InstitutionUpdateAuto( SqlConnection sqlConnection, SqlTransaction sqlTransaction, string connectionKeyName, Institution value) { return InstitutionUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName, value.InstitutionCode, value.InstitutionName, value.Note, value.InstitutionUrl, value.BHLMemberLibrary); }
/// <summary> /// Manage Institution object. /// If the object is of type CustomObjectBase, /// then either insert values into, delete values from, or update values in Institution. /// </summary> /// <param name="sqlConnection">Sql connection or null.</param> /// <param name="sqlTransaction">Sql transaction or null.</param> /// <param name="connectionKeyName">Connection key name located in config file.</param> /// <param name="value">Object of type Institution.</param> /// <returns>Object of type CustomDataAccessStatus<Institution>.</returns> public CustomDataAccessStatus<Institution> InstitutionManageAuto( SqlConnection sqlConnection, SqlTransaction sqlTransaction, string connectionKeyName, Institution value) { if (value.IsNew && !value.IsDeleted) { Institution returnValue = InstitutionInsertAuto(sqlConnection, sqlTransaction, connectionKeyName, value.InstitutionCode, value.InstitutionName, value.Note, value.InstitutionUrl, value.BHLMemberLibrary); return new CustomDataAccessStatus<Institution>( CustomDataAccessContext.Insert, true, returnValue); } else if (!value.IsNew && value.IsDeleted) { if (InstitutionDeleteAuto(sqlConnection, sqlTransaction, connectionKeyName, value.InstitutionCode)) { return new CustomDataAccessStatus<Institution>( CustomDataAccessContext.Delete, true, value); } else { return new CustomDataAccessStatus<Institution>( CustomDataAccessContext.Delete, false, value); } } else if (value.IsDirty && !value.IsDeleted) { Institution returnValue = InstitutionUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName, value.InstitutionCode, value.InstitutionName, value.Note, value.InstitutionUrl, value.BHLMemberLibrary); return new CustomDataAccessStatus<Institution>( CustomDataAccessContext.Update, true, returnValue); } else { return new CustomDataAccessStatus<Institution>( CustomDataAccessContext.NA, false, value); } }
/// <summary> /// Update values in Institution. Returns an object of type Institution. /// </summary> /// <param name="sqlConnection">Sql connection or null.</param> /// <param name="sqlTransaction">Sql transaction or null.</param> /// <param name="value">Object of type Institution.</param> /// <returns>Object of type Institution.</returns> public Institution InstitutionUpdateAuto( SqlConnection sqlConnection, SqlTransaction sqlTransaction, Institution value) { return InstitutionUpdateAuto(sqlConnection, sqlTransaction, "BHL", value ); }
/// <summary> /// Manage Institution object. /// If the object is of type CustomObjectBase, /// then either insert values into, delete values from, or update values in Institution. /// </summary> /// <param name="sqlConnection">Sql connection or null.</param> /// <param name="sqlTransaction">Sql transaction or null.</param> /// <param name="value">Object of type Institution.</param> /// <returns>Object of type CustomDataAccessStatus<Institution>.</returns> public CustomDataAccessStatus<Institution> InstitutionManageAuto( SqlConnection sqlConnection, SqlTransaction sqlTransaction, Institution value) { return InstitutionManageAuto( sqlConnection, sqlTransaction, "BHL", value ); }
protected void saveAsNewButton_Click( object sender, EventArgs e ) { BHLProvider bp = new BHLProvider(); if ( validate() ) { if ( codeTextBox.Text.Trim().Length == 0 ) { errorControl.AddErrorText( "Please include a unique institution code before saving" ); errorControl.Visible = true; return; } else { CustomGenericList<Institution> institutions = bp.InstituationSelectAll(); string code = codeTextBox.Text.Trim().ToUpper(); foreach ( Institution inst in institutions ) { if ( inst.InstitutionCode.ToUpper().Equals( code ) ) { errorControl.AddErrorText( "The institution code " + inst.InstitutionCode.ToUpper() + " is not a unique code, please use another one." ); errorControl.Visible = true; return; } } } Institution institution = new Institution( codeTextBox.Text.Trim().ToUpper(), nameTextBox.Text.Trim(), noteTextBox.Text.Trim(), urlTextBox.Text.Trim(), chkIsMemberLibrary.Checked ); institution.IsNew = true; bp.SaveInstitution( institution ); } else { return; } Response.Redirect( "/Admin/Dashboard.aspx" ); }
private void fillInstitutions() { BHLProvider bp = new BHLProvider(); CustomGenericList<Institution> institutions = bp.InstituationSelectAll(); Institution emptyInstitution = new Institution(); emptyInstitution.InstitutionCode = ""; emptyInstitution.InstitutionName = ""; institutions.Insert( 0, emptyInstitution ); ddlInstitutions.DataSource = institutions; ddlInstitutions.DataTextField = "InstitutionName"; ddlInstitutions.DataValueField = "InstitutionCode"; ddlInstitutions.DataBind(); }
protected void saveButton_Click( object sender, EventArgs e ) { if ( validate() ) { if ( hidCode.Value.Length == 0 ) { errorControl.AddErrorText("Please select an instution before saving" ); errorControl.Visible = true; return; } Institution institution = new Institution( hidCode.Value, nameTextBox.Text.Trim(), noteTextBox.Text.Trim(), urlTextBox.Text.Trim(), chkIsMemberLibrary.Checked ); institution.IsNew = false; BHLProvider bp = new BHLProvider(); bp.SaveInstitution( institution ); } else { return; } Response.Redirect( "/Admin/Dashboard.aspx" ); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BHLProvider bp = new BHLProvider(); CustomGenericList<Institution> institutions = bp.InstituationSelectAll(); Institution emptyInstitution = new Institution(); emptyInstitution.InstitutionName = "(select institution)"; emptyInstitution.InstitutionCode = ""; institutions.Insert(0, emptyInstitution); listInstitutions.DataSource = institutions; listInstitutions.DataBind(); } else { spanTitle.Visible = chkTitle.Checked; spanSubject.Visible = chkSubject.Checked; spanAssociation.Visible = chkAssociation.Checked; spanCreator.Visible = chkCreator.Checked; spanItem.Visible = chkItem.Checked; } Page.SetFocus(listInstitutions); Page.Title = "BHL Admin - Character Encoding Problems"; }