/*public bool UpdateInterests(int itemTypeID, List<int> tagIds) * { * return DBCollector.UpdateInterests(this.CollectorID, itemTypeID, tagIds); * }*/ /// <summary> /// Combines the DeleteInterests and InsertInterests method to update the interests associated with the passed collectorID /// for the passed item type /// </summary> /// <param name="collectorID">The id of the collector to update interests for</param> /// <param name="itemTypeID">The id of the type of item the interests are for</param> /// <param name="tagIds">The tag ids of the interests</param> /// <returns></returns> public static bool UpdateInterests(int collectorID, int itemTypeID, List <int> tagIds) { bool result = false; DBCollector.DeleteInterests(collectorID, itemTypeID); if (DBCollector.InsertInterests(collectorID, itemTypeID, tagIds)) { result = true; } return(result); }
private void BtnAdd_Click(object sender, EventArgs e) { MasterForm master = (this.Parent.Parent as MasterForm); try { //Input data gathered here to improve readability and centralize any processing //that needs to be done before insertion string firstName = this.txtFirstNameInput.Text.Trim(); string lastName = this.txtLastNameInput.Text.Trim(); string phoneNumber = this.mtxtPhoneNumberInput.Text.Trim(); int collectorTypeID = (int)this.cbxTypeInput.SelectedValue; string status = ""; if (String.IsNullOrEmpty(status = DBCollector.Validate(firstName, lastName, phoneNumber))) { object insertedID = DBCollector.InsertCollector(collectorTypeID, firstName, lastName, phoneNumber); if (insertedID != null) { status = "Collector " + firstName + " " + lastName + " has been added." + Environment.NewLine; List <int> bookTagValues = DBControlHelper.GetValuesFromCheckedControls(this.tlpBookTagsSelection); if (bookTagValues.Count > 0 && DBCollector.InsertInterests((int)insertedID, 1, bookTagValues)) { status += "Book interests added." + Environment.NewLine; } List <int> mapTagValues = DBControlHelper.GetValuesFromCheckedControls(this.tlpMapTagsSelection); if (mapTagValues.Count > 0 && DBCollector.InsertInterests((int)insertedID, 2, mapTagValues)) { status += "Map interests added." + Environment.NewLine; } List <int> periodicalTagValues = DBControlHelper.GetValuesFromCheckedControls(this.tlpPeriodicalTagsSelection); if (periodicalTagValues.Count > 0 && DBCollector.InsertInterests((int)insertedID, 3, periodicalTagValues)) { status += "Periodical interests added." + Environment.NewLine; } } } master.SetStatus(status); } catch (Exception ex) { master.SetStatus("Error! Add failed: " + ex.Message); } }