public void ShowItem() { int itemTypeID = DBItem.GetDBItemTypeOfId((int)nudItemID.Value); cbxItemType.SelectedValue = itemTypeID; DBItem tempItem = null; switch (itemTypeID) { case 1: tempItem = DBBook.GetBookOfId((int)nudItemID.Value); DBBook tempBook = (tempItem as DBBook); this.txtTitle.Text = tempBook.Title; this.txtAuthorFirst.Text = tempBook.GetAuthorFirst(); this.txtAuthorLast.Text = tempBook.GetAuthorLast(); this.cbxGenre.SelectedValue = tempBook.GetGenreID(); this.txtPublisher.Text = tempBook.Publisher; this.dtpPublishDate.Value = tempBook.PublishDate; break; case 2: tempItem = DBMap.GetMapOfId((int)nudItemID.Value); DBMap tempMap = (tempItem as DBMap); this.txtPublisher.Text = tempMap.Publisher; this.txtLocation.Text = tempMap.Location; this.nudYear.Value = tempMap.Year; break; case 3: tempItem = DBPeriodical.GetPeriodicalOfId((int)nudItemID.Value); DBPeriodical tempPeriodical = (tempItem as DBPeriodical); this.txtTitle.Text = tempPeriodical.Title; this.cbxGenre.SelectedValue = tempPeriodical.GetGenreID(); this.txtCompanyName.Text = tempPeriodical.CompanyName; this.dtpPublishDate.Value = tempPeriodical.PublishDate; break; } if (tempItem != null) { this.tkbCondition.Value = tempItem.GetConditionID(); this.nudQuantity.Value = tempItem.GetQuantity(); try { DBControlHelper.PopulateWithControls <DBTag, CheckBox>(this.tlpTagSelection, DBTag.GetTags(), "Description", "ID", tempItem.GetTags()); } catch (Exception ex) { (this.Parent.Parent as MasterForm).SetStatus("Error! Failed to load tags: " + ex.Message); } this.nudPrice.Value = tempItem.GetRegularPrice(); //Show the discount if (tempItem.HasDiscount()) { this.nudDiscountPrice.Value = tempItem.GetDiscount().Amount; this.dtpDiscountFrom.Value = tempItem.GetDiscount().StartDate; this.dtpDiscountTo.Value = tempItem.GetDiscount().EndDate; this.chkSetupDiscountTitle.Checked = true; } else { this.nudDiscountPrice.Value = 0; this.dtpDiscountFrom.ResetText(); this.dtpDiscountTo.ResetText(); this.chkSetupDiscountTitle.Checked = false; } } }