/// <summary> /// Loads the item types. /// </summary> private void LoadItemTypes() { //item type can be changed by the project admin and the company admin. bool canEdit = !IsReadOnly && DisplayMode == CompleteItemHeaderDisplayMode.ItemDetails; divItemTypeSelect.Visible = canEdit; divItemTypeStatic.Visible = !canEdit; Data.ItemType itemType = this.GetBL <ItemBriefBL>().GetItemType(this.ItemTypeId); if (canEdit) { this.ddItemTypes.Items.Clear(); List <Data.ItemType> itemTypeList = Utils.GetALLItemTypes(); this.ddItemTypes.Items.Add(new ListItem(itemType.Name, ItemTypeId.ToString(CultureInfo.InvariantCulture))); ddItemTypes.SelectedIndex = 0; if (itemTypeList.Count > 0) { this.ddItemTypes.AddItemGroup("Change to:"); } foreach (var it in itemTypeList.OrderBy(it => it.Name)) { if (it.ItemTypeId != this.ItemTypeId) { this.ddItemTypes.Items.Add(new ListItem(it.Name, it.ItemTypeId.ToString(CultureInfo.InvariantCulture))); } } } else if (itemType != null) { lblItemType.Text = itemType.Name; } }
/// <summary> /// Generates the notifications for bookings. /// </summary> /// <param name="userID">The user identifier.</param> /// <param name="itemBriefId">The item brief identifier.</param> /// <param name="itemId">The item identifier.</param> /// <param name="projectId">The project identifier.</param> /// <param name="action">The action.</param> public void GenerateNotificationsForBookings(int userID, int itemBriefId, int itemId, int projectId, BookingAction action) { PersonalBL personalBL = new PersonalBL(DataContext); User user = personalBL.GetUser(userID); string userName = string.Concat(user.FirstName + " " + user.LastName).Trim(); InventoryBL inventoryBL = new InventoryBL(DataContext); Data.Item item = inventoryBL.GetItem(itemId); ItemBriefBL itemBriefBL = new ItemBriefBL(DataContext); Data.ItemType itemType = itemBriefBL.GetItemBriefType(itemBriefId).ItemType; if (itemType != null && item != null) { StageBitz.Data.Notification nf = new StageBitz.Data.Notification(); nf.CreatedByUserId = nf.LastUpdatedByUserId = userID; nf.CreatedDate = nf.LastUpdatedDate = Utils.Now; nf.RelatedId = itemBriefId; nf.ProjectId = projectId; nf.ModuleTypeCodeId = Utils.GetCodeIdByCodeValue("ModuleType", "ITEMBRIEFBOOKING"); string message = string.Empty; switch (action) { case BookingAction.Pin: message = "{0} pinned {1} from the Company Inventory to this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "PIN"); break; case BookingAction.Keep: message = "{0} confirmed {1} from the Company Inventory to use for this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "KEEP"); break; case BookingAction.Remove: message = "{0} returned {1} to the Company Inventory and removed it as an option for this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "REMOVE"); break; case BookingAction.RemoveWithSnapshot: message = "{0} released {1} to the Company Inventory and kept a record for this {2} Brief."; nf.OperationTypeCodeId = Utils.GetCodeIdByCodeValue("OperationType", "REMOVE"); break; } nf.Message = string.Format(message, userName, item.Name, itemType.Name); this.AddNotification(nf); } }
/// <summary> /// Loads the data. /// </summary> private void LoadData() { Data.ItemType itemType = Utils.GetItemTypeById(ItemTypeId); litTitle.Text = string.Format("Change '{0}' Booking Dates for selected {1} Items.", IsToDateChange ? "To" : "From", itemType != null ? itemType.Name : string.Empty); litDateTypeHeader.Text = litDateTypeBody.Text = IsToDateChange ? "'To'" : "'From'"; BookingDetailsEditRequest bookingDetailsEditRequest = new BookingDetailsEditRequest() { BookingId = BookingId, CompanyId = ViewingCompanyId, ItemTypeId = ItemTypeId, ToDay = Utils.Today, IsToDateEdit = IsToDateChange, IsInventoryManager = IsInventoryManager, UserId = UserID }; //dtPeriod.SelectedDate = Today; //Need to just initiate the grid by setting empty data set and a virtual Item count. gvBookingDetails.DataSource = new List <BookingDetailsToEdit>(); gvBookingDetails.DataBind(); gvBookingDetails.VirtualItemCount = 1000; ScriptManager.RegisterStartupScript(this.Page, GetType(), "LoadBookingDetails", string.Concat("LoadBookingDetails_", this.ClientID, "(", JsonConvert.SerializeObject(bookingDetailsEditRequest), ");"), true); }
/// <summary> /// Gets the item details. /// </summary> /// <param name="itemId">The item identifier.</param> /// <param name="itemBriefId">The item brief identifier.</param> /// <param name="userId">The user identifier.</param> /// <param name="itemTypeIdToBeLoad">The item type identifier to be load.</param> /// <param name="fromDate">From date.</param> /// <param name="toDate">To date.</param> /// <returns></returns> public ItemDetails GetItemDetails(int itemId, int itemBriefId, int userId, int?itemTypeIdToBeLoad, DateTime?fromDate = null, DateTime?toDate = null) { bool isItemCreated = false; bool isReadOnly = false; int itemTypeId = 0; InventoryBL inventoryBL = new InventoryBL(DataContext); ItemBriefBL itemBriefBL = new ItemBriefBL(DataContext); ItemDetails itemDetails = new ItemDetails(); InitializeIds(ref itemId, ref itemBriefId, ref isItemCreated); if (itemId > 0) { StageBitz.Data.Item item = inventoryBL.GetItem(itemId); if (item != null) { ItemBooking itemBooking = null; itemDetails.IsEditableToAdminOnly = true; if (itemBriefId > 0) { ProjectBL projectBL = new ProjectBL(DataContext); itemBooking = itemBriefBL.GetInUseItemBooking(itemBriefId); itemDetails.CanEditInItemBrief = inventoryBL.CanEditIteminItemBrief(itemBriefId, itemId); itemDetails.IsEditableToAdminOnly = inventoryBL.IsItemGeneretedFromGivenItemBrief(itemId, itemBriefId) && !projectBL.IsReadOnlyRightsForProject(itemBriefBL.GetItemBrief(itemBriefId).ProjectId, userId, true); } else { itemDetails.MinQuantity = inventoryBL.GetMaxBookedQuantityForAllDuration(item.ItemId); ItemStatusInformationForUser itemStatusInformationForUser = inventoryBL.GetItemStatusInformationForUser(item, item.CompanyId.Value, userId); isReadOnly = itemStatusInformationForUser.IsReadOnly; itemDetails.IsEditableToAdminOnly = itemStatusInformationForUser.CanEditQuantity; } itemDetails.Name = item.Name; itemDetails.Description = item.Description; itemDetails.LocationId = item.LocationId; itemDetails.Quantity = itemBooking != null ? itemBooking.Quantity : item.Quantity.HasValue ? item.Quantity.Value : item.Quantity; User bookingManager = inventoryBL.GetContactBookingManager(item.CompanyId.Value, item.LocationId); if (bookingManager != null) { itemDetails.BookingManagerName = Utils.GetFullName(bookingManager); itemDetails.BookingManagerEmail = bookingManager.Email1; } if (fromDate.HasValue && toDate.HasValue) { itemDetails.AvailableQty = DataContext.GetAvailableItemQuantity(itemId, fromDate.Value, toDate.Value, 0).FirstOrDefault().Value; } itemDetails.CreatedFor = item.CreatedFor; itemDetails.ItemBriefId = itemBriefId; itemDetails.LastUpdatedDate = item.LastUpdatedDate; itemTypeId = itemTypeIdToBeLoad.HasValue ? itemTypeIdToBeLoad.Value : item.ItemTypeId.Value; itemDetails.LastUpdatedDate = item.LastUpdatedDate; itemDetails.ItemStatus = itemBooking != null?inventoryBL.GetItemBookingStatus(itemBooking.ItemBookingId).Description : string.Empty; itemDetails.ItemId = itemId; itemDetails.ItemValues = GetItemFieldValues(itemId).Select(iv => new ValuesInfo { Id = iv.ItemValueId, FieldId = iv.FieldId, FieldOptionId = iv.FieldOptionId, Value = iv.Value }).ToList(); itemDetails.CountryId = inventoryBL.GetCountryIdByItemId(item.ItemId); itemDetails.ItemTypeId = item.ItemTypeId; itemDetails.Status = "OK"; } } else if (itemBriefId > 0) { Data.ItemVersionHistory itemVersionHistory = inventoryBL.GetItemVersionHistoryByItemBriefId(itemBriefId); itemDetails.ItemBriefId = itemBriefId; if (itemVersionHistory != null) { itemId = itemVersionHistory.ItemId; itemDetails.Name = itemVersionHistory.Name; itemDetails.Description = itemVersionHistory.Description; itemDetails.LocationId = null; //itemVersionHistory.Location; itemDetails.Quantity = itemVersionHistory.Quantity.HasValue ? itemVersionHistory.Quantity.Value : itemDetails.Quantity; itemDetails.IsEditableToAdminOnly = false; itemDetails.ItemBriefId = itemVersionHistory.ItemBriefId; itemDetails.ItemValues = GetItemVersionHistoryValues(itemVersionHistory.ItemVersionHistoryId).Select(ivhv => new ValuesInfo { Id = ivhv.ItemVersionHistoryId, FieldId = ivhv.FieldId, FieldOptionId = ivhv.FieldOptionId, Value = ivhv.Value }).ToList(); itemTypeId = itemTypeIdToBeLoad.HasValue ? itemTypeIdToBeLoad.Value : itemVersionHistory.ItemTypeId.Value; itemDetails.CountryId = inventoryBL.GetCountryIdByItemId(itemVersionHistory.ItemId); itemDetails.ItemTypeId = itemVersionHistory.ItemTypeId; itemDetails.Status = "OK"; } else { StageBitz.Data.ItemBrief itemBrief = itemBriefBL.GetItemBrief(itemBriefId); if (itemBrief != null) { itemDetails.Name = itemBrief.Name; itemDetails.Description = itemBrief.Description; itemDetails.LocationId = null; itemDetails.IsEditableToAdminOnly = true; itemDetails.ItemBriefId = itemBriefId; itemDetails.Quantity = itemBrief.Quantity.HasValue ? itemBrief.Quantity.Value : itemBrief.Quantity; itemDetails.ItemBriefId = itemBrief.ItemBriefId; itemDetails.ItemValues = GetItemBriefFieldValues(itemBriefId).Select(ibfv => new ValuesInfo { Id = 0, FieldId = ibfv.FieldId, FieldOptionId = ibfv.FieldOptionId, Value = ibfv.Value }).ToList(); itemTypeId = itemTypeIdToBeLoad.HasValue ? itemTypeIdToBeLoad.Value : itemBriefBL.GetItemBriefType(itemBrief.ItemBriefId).ItemTypeId; itemDetails.CountryId = itemBriefBL.GetCountryIdByItemBriefId(itemBrief.ItemBriefId); itemDetails.Status = "OK"; itemDetails.CanEditInItemBrief = true; itemDetails.ItemTypeId = itemBrief.ItemBriefTypes.FirstOrDefault().ItemTypeId; } } } itemDetails.IsReadOnly = isReadOnly; itemDetails.DisplayMarkUp = GetItemTypeHTML(itemTypeId); Data.ItemType itemType = Utils.GetItemTypeById(itemDetails.ItemTypeId.Value); itemDetails.ItemTypeName = itemType != null ? itemType.Name : string.Empty; return(itemDetails); }
public static Data.ItemType GetItemType(string key) { Data.ItemType ot = null; Data.ItemType.ObjectTypes.TryGetValue(key, out ot); return(ot); }