/// <summary> /// Initializes the UI. /// </summary> public void InitializeUI() { if (this.ItemId == 0) { chkVisibilityInventoryObservers.Checked = chkVisibilityInventoryStaff.Checked = chkVisibilitySharedInventory.Checked = chkVisibilityInventoryTeam.Checked = false; } else { Data.Code aboveSharedInventoryCode = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_SHAREDINVENTORY"); Data.Code aboveInventoryObserverCode = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_IO"); Data.Code aboveInventoryStaffCode = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_IS"); Data.Code aboveInventoryAdminCode = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_IA"); Data.Item item = GetBL <InventoryBL>().GetItem(this.ItemId); if (item != null) { int sortOrder = item.Code.SortOrder; chkVisibilitySharedInventory.Checked = aboveSharedInventoryCode.SortOrder <= sortOrder; chkVisibilityInventoryObservers.Checked = aboveInventoryObserverCode.SortOrder <= sortOrder; chkVisibilityInventoryStaff.Checked = aboveInventoryStaffCode.SortOrder <= sortOrder; chkVisibilityInventoryTeam.Checked = chkVisibilityInventoryObservers.Checked || chkVisibilityInventoryStaff.Checked; this.CompanyId = item.CompanyId.Value; } } Data.Company company = GetBL <CompanyBL>().GetCompany(this.CompanyId); if (company != null) { ltrlChkVisibilityInventoryTeam.Text = string.Format("Inventory Team Members from <span title='{0}'>{1}</span>", company.CompanyName.Length > 30 ? company.CompanyName : string.Empty, Support.TruncateString(company.CompanyName, 30)); } }
/// <summary> /// Handles the Click event of the btnBulkUpdate control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void btnBulkUpdate_Click(object sender, EventArgs e) { if (!PageBase.StopProcessing) { if (this.Page.IsValid) { if (this.GetBL <CompanyBL>().HasEditPermissionForInventoryStaff(this.CompanyId, UserID, sbInventoryLocations.SelectedLocationId)) { int? locationId = sbInventoryLocations.SelectedLocationId; Data.Code userVisibilityLevel = GetBL <InventoryBL>().GetUserInventoryVisibilityLevel(this.CompanyId, UserID, sbInventoryLocations.SelectedLocationId, false); if (locationId.HasValue) { Data.Location location = GetBL <LocationBL>().GetLocation(locationId.Value); if (location == null) { popupInventoryLocationDeleted.ShowPopup(); sbInventoryLocations.SelectedLocationId = null; upnlBulkUpdate.Update(); return; } } lblToLocation.Text = Utils.ReverseEllipsize(GetBL <LocationBL>().GetLocationPath(locationId, this.CompanyId), 25); string[] itemIdStrings = hdnBulkUpdateSelectedItems.Value.Split(Delimiter.ToCharArray()); bool hasChanges = false; foreach (string itemIdString in itemIdStrings) { int itemId = 0; if (int.TryParse(itemIdString, out itemId) && itemId > 0) { Data.Item item = GetBL <InventoryBL>().GetItem(itemId); if (item != null && item.CompanyId.Value == this.CompanyId && item.Code.SortOrder >= userVisibilityLevel.SortOrder) { item.LocationId = locationId; hasChanges = true; } } } if (hasChanges) { GetBL <InventoryBL>().SaveChanges(); } if (InformCompanyInventoryToReloadBulkUpdate != null) { InformCompanyInventoryToReloadBulkUpdate(); } ScriptManager.RegisterStartupScript(this.Page, GetType(), "ShowSavedMessage", "showNotification('" + bulkUpdateSavedNotice.ClientID + "', 5000);", true); LoadData(); } else { if (OnInformCompanyInventoryToShowErrorPopup != null) { OnInformCompanyInventoryToShowErrorPopup(ErrorCodes.NoEditPermissionForInventory); } } } } }