Example #1
0
        public int Compare(object obj1, object obj2)
        {
            TitleItem item1 = (TitleItem)obj1;
            TitleItem item2 = (TitleItem)obj2;

            int    ret = 0;
            string s1  = "";
            string s2  = "";

            switch (_compareEnum)
            {
            case CompareEnum.ItemID:
            {
                ret = item1.ItemID.CompareTo(item2.ItemID);
                break;
            }

            case CompareEnum.BarCode:
            {
                ret = TypeHelper.EmptyIfNull(item1.BarCode).CompareTo(
                    TypeHelper.EmptyIfNull(item2.BarCode));
                break;
            }

            case CompareEnum.ItemSequence:
            {
                ret = (TypeHelper.ZeroIfNull((int?)item1.ItemSequence)).CompareTo(
                    (TypeHelper.ZeroIfNull((int?)item2.ItemSequence)));
                break;
            }

            case CompareEnum.Volume:
            {
                ret = TypeHelper.EmptyIfNull(item1.Volume).CompareTo(
                    TypeHelper.EmptyIfNull(item2.Volume));
                break;
            }
            }

            if (_sortOrder == SortOrder.Descending)
            {
                ret = ret * -1;
            }

            return(ret);
        }
 /// <summary>
 /// Update values in TitleItem. Returns an object of type TitleItem.
 /// </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 TitleItem.</param>
 /// <returns>Object of type TitleItem.</returns>
 public TitleItem TitleItemUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     string connectionKeyName,
     TitleItem value)
 {
     return TitleItemUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName,
         value.TitleItemID,
         value.TitleID,
         value.ItemID,
         value.ItemSequence);
 }
 /// <summary>
 /// Update values in TitleItem. Returns an object of type TitleItem.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type TitleItem.</param>
 /// <returns>Object of type TitleItem.</returns>
 public TitleItem TitleItemUpdateAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     TitleItem value)
 {
     return TitleItemUpdateAuto(sqlConnection, sqlTransaction, "BHL", value );
 }
        /// <summary>
        /// Manage TitleItem object.
        /// If the object is of type CustomObjectBase, 
        /// then either insert values into, delete values from, or update values in TitleItem.
        /// </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 TitleItem.</param>
        /// <returns>Object of type CustomDataAccessStatus<TitleItem>.</returns>
        public CustomDataAccessStatus<TitleItem> TitleItemManageAuto(
            SqlConnection sqlConnection,
            SqlTransaction sqlTransaction,
            string connectionKeyName,
            TitleItem value)
        {
            if (value.IsNew && !value.IsDeleted)
            {

                TitleItem returnValue = TitleItemInsertAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.TitleID,
                        value.ItemID,
                        value.ItemSequence);

                return new CustomDataAccessStatus<TitleItem>(
                    CustomDataAccessContext.Insert,
                    true, returnValue);
            }
            else if (!value.IsNew && value.IsDeleted)
            {
                if (TitleItemDeleteAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.TitleItemID))
                {
                return new CustomDataAccessStatus<TitleItem>(
                    CustomDataAccessContext.Delete,
                    true, value);
                }
                else
                {
                return new CustomDataAccessStatus<TitleItem>(
                    CustomDataAccessContext.Delete,
                    false, value);
                }
            }
            else if (value.IsDirty && !value.IsDeleted)
            {

                TitleItem returnValue = TitleItemUpdateAuto(sqlConnection, sqlTransaction, connectionKeyName,
                    value.TitleItemID,
                        value.TitleID,
                        value.ItemID,
                        value.ItemSequence);

                return new CustomDataAccessStatus<TitleItem>(
                    CustomDataAccessContext.Update,
                    true, returnValue);
            }
            else
            {
                return new CustomDataAccessStatus<TitleItem>(
                    CustomDataAccessContext.NA,
                    false, value);
            }
        }
 /// <summary>
 /// Manage TitleItem object.
 /// If the object is of type CustomObjectBase, 
 /// then either insert values into, delete values from, or update values in TitleItem.
 /// </summary>
 /// <param name="sqlConnection">Sql connection or null.</param>
 /// <param name="sqlTransaction">Sql transaction or null.</param>
 /// <param name="value">Object of type TitleItem.</param>
 /// <returns>Object of type CustomDataAccessStatus<TitleItem>.</returns>
 public CustomDataAccessStatus<TitleItem> TitleItemManageAuto(
     SqlConnection sqlConnection,
     SqlTransaction sqlTransaction,
     TitleItem value)
 {
     return TitleItemManageAuto( sqlConnection, sqlTransaction, "BHL", value  );
 }
Example #6
0
        protected void saveButton_Click(object sender, EventArgs e)
        {
            Item item = (Item)Session["Item" + itemIdTextBox.Text];

            if ( validate( item ) )
            {
                // Gather up data on form
                short? s = null;
                int? i = null;
                item.MARCItemID = marcItemIDTextBox.Text.Trim();
                item.CallNumber = callNumberTextBox.Text.Trim();
                item.Volume = volumeTextBox.Text.Trim();
                item.InstitutionCode = (ddlInst.SelectedValue.Length == 0 ? null : ddlInst.SelectedValue);
                item.LanguageCode = ( ddlLang.SelectedValue.Length == 0 ? null : ddlLang.SelectedValue );
                item.Note = notesTextBox.Text.Trim();
                item.Year = yearTextBox.Text.Trim();
                item.IdentifierBib = identifierBibTextBox.Text.Trim();
                item.ZQuery = zQueryTextBox.Text.Trim();
                item.Sponsor = sponsorTextBox.Text.Trim();
                item.LicenseUrl = licenseUrlTextBox.Text.Trim();
                item.Rights = rightsTextBox.Text.Trim();
                item.DueDiligence = dueDiligenceTextBox.Text.Trim();
                item.CopyrightStatus = copyrightStatusTextBox.Text.Trim();
                item.CopyrightRegion = copyrightRegionTextBox.Text.Trim();
                item.CopyrightComment = copyrightCommentTextBox.Text.Trim();
                item.CopyrightEvidence = copyrightEvidenceTextBox.Text.Trim();
                item.VaultID = ( ddlVault.SelectedIndex == 0 ? i : int.Parse(ddlVault.SelectedValue) );
                item.ItemStatusID = int.Parse( ddlItemStatus.SelectedValue );

                item.IsNew = false;

                //----------------------------------------
                // Update the title information
                CustomGenericList<ItemTitle> itemTitles = (CustomGenericList<ItemTitle>)Session["ItemTitleList" + itemIdTextBox.Text];

                // Add new titles
                foreach (ItemTitle itemTitle in itemTitles)
                {
                    bool found = false;
                    foreach (TitleItem titleItem in item.TitleItems)
                    {
                        if (itemTitle.TitleID == titleItem.TitleID)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        TitleItem newTitleItem = new TitleItem();
                        newTitleItem.TitleID = itemTitle.TitleID;
                        newTitleItem.ItemID = item.ItemID;
                        newTitleItem.ItemSequence = 1;
                        newTitleItem.IsNew = true;
                        item.TitleItems.Add(newTitleItem);
                    }
                }

                // Flag deleted titles
                foreach (TitleItem titleItem in item.TitleItems)
                {
                    bool found = false;
                    foreach (ItemTitle itemTitle in itemTitles)
                    {
                        if (titleItem.TitleID == itemTitle.TitleID)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found) titleItem.IsDeleted = true;
                }
                //----------------------------------------

                BHLProvider bp = new BHLProvider();
                try
                {
                    bp.ItemSave( item, 1 );
                }
                catch ( Exception ex )
                {
                    Session[ "Exception" ] = ex;
                    Response.Redirect( "/Error.aspx" );
                }
            }
            else
            {
                return;
            }

            litMessage.Text = "<span class='liveData'>Item Saved.</span>";
            Page.MaintainScrollPositionOnPostBack = false;
            //Response.Redirect("/Admin/Dashboard.aspx");
        }