Beispiel #1
0
 /// <summary>
 /// Update values in TitleAssociation. Returns an object of type TitleAssociation.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type TitleAssociation.</param>
 /// <returns>Object of type TitleAssociation.</returns>
 public TitleAssociation TitleAssociationUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     TitleAssociation value)
 {
     return(TitleAssociationUpdateAuto(sqlConnection, sqlTransaction, "BHL", value));
 }
Beispiel #2
0
        /// <summary>
        /// Get the title association from the Title stored in the Session object
        /// </summary>
        /// <param name="titleAssociationId"></param>
        /// <returns></returns>
        private TitleAssociation FindTitleAssociation(int titleAssociationId)
        {
            TitleAssociation titleAssociation = null;

            Title title = (Title)Session["Title" + hidTitleID.Value];

            if (title != null)
            {
                foreach (TitleAssociation ta in title.TitleAssociations)
                {
                    if (ta.IsDeleted)
                    {
                        continue;
                    }
                    if (titleAssociationId == 0 && ta.TitleAssociationID == 0)
                    {
                        titleAssociation = ta;
                        break;
                    }
                    else if (titleAssociationId > 0 && ta.TitleAssociationID == titleAssociationId)
                    {
                        titleAssociation = ta;
                        break;
                    }
                }
            }

            return(titleAssociation);
        }
Beispiel #3
0
 /// <summary>
 /// Manage TitleAssociation object.
 /// If the object is of type CustomObjectBase,
 /// then either insert values into, delete values from, or update values in TitleAssociation.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type TitleAssociation.</param>
 /// <returns>Object of type CustomDataAccessStatus<TitleAssociation>.</returns>
 public CustomDataAccessStatus <TitleAssociation> TitleAssociationManageAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     TitleAssociation value)
 {
     return(TitleAssociationManageAuto(sqlConnection, sqlTransaction, "BHL", value));
 }
Beispiel #4
0
        protected void identifiersList_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = identifiersList.Rows[e.RowIndex];

            if (row != null)
            {
                DropDownList ddlIdentifierName  = row.FindControl("ddlIdentifierName") as DropDownList;
                TextBox      txtIdentifierValue = row.FindControl("txtIdentifierValue") as TextBox;
                if (ddlIdentifierName != null && txtIdentifierValue != null)
                {
                    //int titleAssociationId = (int)Session["TitleAssociation"];
                    int titleAssociationId       = Convert.ToInt32(hidTitleAssociationID.Value);
                    TitleAssociation association = this.FindTitleAssociation(titleAssociationId);

                    TitleAssociation_TitleIdentifier taTitleIdentifier = FindTitleAssociation_TitleIdentifier(
                        association.TitleAssociationIdentifiers,
                        (int)identifiersList.DataKeys[e.RowIndex].Values[0],
                        (int)identifiersList.DataKeys[e.RowIndex].Values[1],
                        identifiersList.DataKeys[e.RowIndex].Values[2].ToString());

                    int    titleIdentifierId = int.Parse(ddlIdentifierName.SelectedValue);
                    String identifierValue   = txtIdentifierValue.Text;

                    taTitleIdentifier.TitleAssociationID = association.TitleAssociationID;
                    taTitleIdentifier.TitleIdentifierID  = titleIdentifierId;
                    taTitleIdentifier.IdentifierName     = ddlIdentifierName.SelectedItem.Text;
                    taTitleIdentifier.IdentifierValue    = identifierValue;
                }
            }

            identifiersList.EditIndex = -1;
            bindTitleIdentifierData();
        }
Beispiel #5
0
        /// <summary>
        /// Select values from TitleAssociation by primary key(s).
        /// </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="titleAssociationID"></param>
        /// <returns>Object of type TitleAssociation.</returns>
        public TitleAssociation TitleAssociationSelectAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            int titleAssociationID)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings(connectionKeyName), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("TitleAssociationSelectAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("TitleAssociationID", SqlDbType.Int, null, false, titleAssociationID)))
            {
                using (CustomSqlHelper <TitleAssociation> helper = new CustomSqlHelper <TitleAssociation>())
                {
                    CustomGenericList <TitleAssociation> list = helper.ExecuteReader(command);
                    if (list.Count > 0)
                    {
                        TitleAssociation o = list[0];
                        list = null;
                        return(o);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Beispiel #6
0
        private void addTitleAssociation(int titleID)
        {
            Title            title = (Title)Session["Title" + titleID.ToString()];
            TitleAssociation ta    = new TitleAssociation();

            ta.TitleID = title.TitleID;
            ta.Active  = true;
            ta.IsNew   = true;
            title.TitleAssociations.Add(ta);
        }
Beispiel #7
0
        protected void addTitleIdentifierButton_Click(object sender, EventArgs e)
        {
            //int titleAssociationId = (int)Session["TitleAssociation"];
            int titleAssociationId       = Convert.ToInt32(hidTitleAssociationID.Value);
            TitleAssociation association = this.FindTitleAssociation(titleAssociationId);

            TitleAssociation_TitleIdentifier ti = new TitleAssociation_TitleIdentifier();

            ti.TitleAssociationID = association.TitleAssociationID;
            association.TitleAssociationIdentifiers.Add(ti);
            identifiersList.EditIndex = identifiersList.Rows.Count;
            bindTitleIdentifierData();
        }
Beispiel #8
0
        /// <summary>
        /// Update values in TitleAssociation. Returns an object of type TitleAssociation.
        /// </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="titleAssociationID"></param>
        /// <param name="titleID"></param>
        /// <param name="titleAssociationTypeID"></param>
        /// <param name="title"></param>
        /// <param name="section"></param>
        /// <param name="volume"></param>
        /// <param name="heading"></param>
        /// <param name="publication"></param>
        /// <param name="relationship"></param>
        /// <param name="active"></param>
        /// <param name="associatedTitleID"></param>
        /// <returns>Object of type TitleAssociation.</returns>
        public TitleAssociation TitleAssociationUpdateAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            int titleAssociationID,
            int titleID,
            int titleAssociationTypeID,
            string title,
            string section,
            string volume,
            string heading,
            string publication,
            string relationship,
            bool active,
            int?associatedTitleID)
        {
            SqlConnection  connection  = CustomSqlHelper.CreateConnection(CustomSqlHelper.GetConnectionStringFromConnectionStrings(connectionKeyName), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            using (SqlCommand command = CustomSqlHelper.CreateCommand("TitleAssociationUpdateAuto", connection, transaction,
                                                                      CustomSqlHelper.CreateInputParameter("TitleAssociationID", SqlDbType.Int, null, false, titleAssociationID),
                                                                      CustomSqlHelper.CreateInputParameter("TitleID", SqlDbType.Int, null, false, titleID),
                                                                      CustomSqlHelper.CreateInputParameter("TitleAssociationTypeID", SqlDbType.Int, null, false, titleAssociationTypeID),
                                                                      CustomSqlHelper.CreateInputParameter("Title", SqlDbType.NVarChar, 500, false, title),
                                                                      CustomSqlHelper.CreateInputParameter("Section", SqlDbType.NVarChar, 500, false, section),
                                                                      CustomSqlHelper.CreateInputParameter("Volume", SqlDbType.NVarChar, 500, false, volume),
                                                                      CustomSqlHelper.CreateInputParameter("Heading", SqlDbType.NVarChar, 500, false, heading),
                                                                      CustomSqlHelper.CreateInputParameter("Publication", SqlDbType.NVarChar, 500, false, publication),
                                                                      CustomSqlHelper.CreateInputParameter("Relationship", SqlDbType.NVarChar, 500, false, relationship),
                                                                      CustomSqlHelper.CreateInputParameter("Active", SqlDbType.Bit, null, false, active),
                                                                      CustomSqlHelper.CreateInputParameter("AssociatedTitleID", SqlDbType.Int, null, true, associatedTitleID),
                                                                      CustomSqlHelper.CreateReturnValueParameter("ReturnCode", SqlDbType.Int, null, false)))
            {
                using (CustomSqlHelper <TitleAssociation> helper = new CustomSqlHelper <TitleAssociation>())
                {
                    CustomGenericList <TitleAssociation> list = helper.ExecuteReader(command);
                    if (list.Count > 0)
                    {
                        TitleAssociation o = list[0];
                        list = null;
                        return(o);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
        }
Beispiel #9
0
        public static void Save(SqlConnection sqlConnection, SqlTransaction sqlTransaction,
                                TitleAssociation titleAssociation)
        {
            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);

                CustomDataAccessStatus <TitleAssociation> updatedTitleAssociation =
                    new TitleAssociationDAL().TitleAssociationManageAuto(connection, transaction, titleAssociation);

                if (titleAssociation.TitleAssociationIdentifiers.Count > 0)
                {
                    TitleAssociation_TitleIdentifierDAL titleAssociationTitleIdentifierDAL = new TitleAssociation_TitleIdentifierDAL();
                    foreach (TitleAssociation_TitleIdentifier titleAssociationTitleIdentifier in titleAssociation.TitleAssociationIdentifiers)
                    {
                        if (titleAssociationTitleIdentifier.TitleAssociationID == 0)
                        {
                            titleAssociationTitleIdentifier.TitleAssociationID = updatedTitleAssociation.ReturnObject.TitleAssociationID;
                        }
                        titleAssociationTitleIdentifierDAL.TitleAssociation_TitleIdentifierManageAuto(connection, transaction, titleAssociationTitleIdentifier);
                    }
                }

                CustomSqlHelper.CommitTransaction(transaction, isTransactionCoordinator);
            }
            catch (Exception ex)
            {
                CustomSqlHelper.RollbackTransaction(transaction, isTransactionCoordinator);

                throw new Exception("Exception in Save", ex);
            }
            finally
            {
                CustomSqlHelper.CloseConnection(connection, isTransactionCoordinator);
            }
        }
Beispiel #10
0
        public TitleAssociation TitleAssociationSelectExtended(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            int titleAssociationID)
        {
            SqlConnection connection = CustomSqlHelper.CreateConnection(
                CustomSqlHelper.GetConnectionStringFromConnectionStrings("BHL"), sqlConnection);
            SqlTransaction transaction = sqlTransaction;

            TitleAssociation titleAssociation = this.TitleAssociationSelectAuto(connection, transaction, titleAssociationID);

            if (titleAssociation != null)
            {
                titleAssociation.TitleAssociationIdentifiers = new TitleAssociation_TitleIdentifierDAL().TitleAssociation_TitleIdentifierSelectByTitleAssociationID(connection, transaction, titleAssociation.TitleAssociationID);
            }

            return(titleAssociation);
        }
Beispiel #11
0
 /// <summary>
 /// Insert values into TitleAssociation. Returns an object of type TitleAssociation.
 /// </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 TitleAssociation.</param>
 /// <returns>Object of type TitleAssociation.</returns>
 public TitleAssociation TitleAssociationInsertAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     string connectionKeyName,
     TitleAssociation value)
 {
     return(TitleAssociationInsertAuto(sqlConnection, sqlTransaction, connectionKeyName,
                                       value.TitleID,
                                       value.TitleAssociationTypeID,
                                       value.Title,
                                       value.Section,
                                       value.Volume,
                                       value.Heading,
                                       value.Publication,
                                       value.Relationship,
                                       value.Active,
                                       value.AssociatedTitleID));
 }
Beispiel #12
0
        private void bindTitleIdentifierData()
        {
            //int titleAssociationId = (int)Session["TitleAssociation"];
            int titleAssociationId       = Convert.ToInt32(hidTitleAssociationID.Value);
            TitleAssociation association = this.FindTitleAssociation(titleAssociationId);

            // filter out deleted items
            CustomGenericList <TitleAssociation_TitleIdentifier> titleIdentifiers = new CustomGenericList <TitleAssociation_TitleIdentifier>();

            foreach (TitleAssociation_TitleIdentifier ti in association.TitleAssociationIdentifiers)
            {
                if (ti.IsDeleted == false)
                {
                    titleIdentifiers.Add(ti);
                }
            }

            identifiersList.DataSource = titleIdentifiers;
            identifiersList.DataBind();
        }
Beispiel #13
0
        protected void identifiersList_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName.Equals("RemoveButton"))
            {
                int rowNum = int.Parse(e.CommandArgument.ToString());

                //int titleAssociationId = (int)Session["TitleAssociation"];
                int titleAssociationId       = Convert.ToInt32(hidTitleAssociationID.Value);
                TitleAssociation association = this.FindTitleAssociation(titleAssociationId);

                TitleAssociation_TitleIdentifier taTitleIdentifier = FindTitleAssociation_TitleIdentifier(
                    association.TitleAssociationIdentifiers,
                    (int)identifiersList.DataKeys[rowNum].Values[0],
                    (int)identifiersList.DataKeys[rowNum].Values[1],
                    identifiersList.DataKeys[rowNum].Values[2].ToString());

                taTitleIdentifier.IsDeleted = true;
                identifiersList.EditIndex   = -1;
                bindTitleIdentifierData();
            }
        }
Beispiel #14
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            //int titleAssociationId = (int)Session["TitleAssociation"];
            int titleAssociationId = Convert.ToInt32(hidTitleAssociationID.Value);

            if (validate())
            {
                TitleAssociation association = this.FindTitleAssociation(titleAssociationId);

                // Gather up data on form
                association.TitleAssociationTypeID = Convert.ToInt32(ddlType.SelectedValue);
                association.TitleAssociationName   = ddlType.SelectedItem.Text;
                association.Title        = titleTextBox.Text.Trim();
                association.Section      = sectionTextBox.Text.Trim();
                association.Volume       = volumeTextBox.Text.Trim();
                association.Heading      = headingTextBox.Text.Trim();
                association.Publication  = publicationTextBox.Text.Trim();
                association.Relationship = relationshipTextBox.Text.Trim();
                if (hidAssociatedTitleID.Value.Trim() == String.Empty)
                {
                    association.AssociatedTitleID = null;
                }
                else
                {
                    association.AssociatedTitleID = Convert.ToInt32(hidAssociatedTitleID.Value);
                }
                association.Active = activeCheckBox.Checked;
                association.IsNew  = (association.TitleAssociationID == 0);

                // Forces deletes to happen first
                association.TitleAssociationIdentifiers.Sort(SortOrder.Descending, "IsDeleted");
            }
            else
            {
                return;
            }

            ClientScript.RegisterClientScriptBlock(this.GetType(), "scptDone", "<script language='javascript'>parent.updateAssociations();</script>");
        }
Beispiel #15
0
        private void fillUI(int id, int titleID)
        {
            //Session["TitleAssociation"] = id;
            hidTitleID.Value            = titleID.ToString();
            hidTitleAssociationID.Value = id.ToString();

            TitleAssociation association = this.FindTitleAssociation(id);

            if (association != null)
            {
                if (association.TitleAssociationTypeID != 0)
                {
                    ddlType.SelectedValue = ddlType.Items.FindByValue(association.TitleAssociationTypeID.ToString()).Value;
                }
                else
                {
                    ddlType.SelectedIndex = 0;
                }
                titleTextBox.Text        = association.Title;
                sectionTextBox.Text      = association.Section;
                volumeTextBox.Text       = association.Volume;
                headingTextBox.Text      = association.Heading;
                publicationTextBox.Text  = association.Publication;
                relationshipTextBox.Text = association.Relationship;
                activeCheckBox.Checked   = association.Active;

                if (association.AssociatedTitleID != null)
                {
                    Title title = new BHLProvider().TitleSelectAuto((int)association.AssociatedTitleID);
                    litAssociatedTitle.Text    = association.AssociatedTitleID.ToString() + ": " + title.ShortTitle;
                    hidAssociatedTitleID.Value = association.AssociatedTitleID.ToString();
                }

                this.bindTitleIdentifierData();
            }
        }
Beispiel #16
0
        /// <summary>
        /// Manage TitleAssociation object.
        /// If the object is of type CustomObjectBase,
        /// then either insert values into, delete values from, or update values in TitleAssociation.
        /// </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 TitleAssociation.</param>
        /// <returns>Object of type CustomDataAccessStatus<TitleAssociation>.</returns>
        public CustomDataAccessStatus <TitleAssociation> TitleAssociationManageAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            TitleAssociation value)
        {
            if (value.IsNew && !value.IsDeleted)
            {
                TitleAssociation returnValue = TitleAssociationInsertAuto(sqlConnection, sqlTransaction, connectionKeyName,
                                                                          value.TitleID,
                                                                          value.TitleAssociationTypeID,
                                                                          value.Title,
                                                                          value.Section,
                                                                          value.Volume,
                                                                          value.Heading,
                                                                          value.Publication,
                                                                          value.Relationship,
                                                                          value.Active,
                                                                          value.AssociatedTitleID);

                return(new CustomDataAccessStatus <TitleAssociation>(
                           CustomDataAccessContext.Insert,
                           true, returnValue));
            }
            else if (!value.IsNew && value.IsDeleted)
            {
                if (TitleAssociationDeleteAuto(sqlConnection, sqlTransaction, connectionKeyName,
                                               value.TitleAssociationID))
                {
                    return(new CustomDataAccessStatus <TitleAssociation>(
                               CustomDataAccessContext.Delete,
                               true, value));
                }
                else
                {
                    return(new CustomDataAccessStatus <TitleAssociation>(
                               CustomDataAccessContext.Delete,
                               false, value));
                }
            }
            else if (value.IsDirty && !value.IsDeleted)
            {
                TitleAssociation returnValue = TitleAssociationUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName,
                                                                          value.TitleAssociationID,
                                                                          value.TitleID,
                                                                          value.TitleAssociationTypeID,
                                                                          value.Title,
                                                                          value.Section,
                                                                          value.Volume,
                                                                          value.Heading,
                                                                          value.Publication,
                                                                          value.Relationship,
                                                                          value.Active,
                                                                          value.AssociatedTitleID);

                return(new CustomDataAccessStatus <TitleAssociation>(
                           CustomDataAccessContext.Update,
                           true, returnValue));
            }
            else
            {
                return(new CustomDataAccessStatus <TitleAssociation>(
                           CustomDataAccessContext.NA,
                           false, value));
            }
        }
 public void TitleAssociationSave(TitleAssociation titleAssociation)
 {
     TitleAssociationDAL.Save(null, null, titleAssociation);
 }