예제 #1
0
        /// <summary>
        /// Loads the control.
        /// </summary>
        public void LoadControl()
        {
            InitailizeValidationGroup();
            LoadData();
            DisplayItemThumbnail();

            switch (this.DisplayMode)
            {
            case CompleteItemHeaderDisplayMode.ItemDetails:
                divDescription.Visible          = false;
                trCreatedFor.Visible            = true;
                trLocation.Visible              = true;
                sbItemVisibilityToolTip.Visible = true;
                Data.Item item = GetBL <InventoryBL>().GetItem(this.ItemId);

                upnlVisibility.Visible = Utils.HasLocationManagerPermission(this.CompanyId, this.UserID, item.LocationId);
                bool hasBooking = GetBL <InventoryBL>().IsItemInUse(this.ItemId) ||
                                  GetBL <InventoryBL>().IsItemOverDue(this.ItemId) ||
                                  GetBL <InventoryBL>().HasFutureBookingsForItem(this.ItemId);
                lbtnChangeVisibility.Visible = !hasBooking;
                lblChangeVisibility.Visible  = hasBooking;
                break;

            case CompleteItemHeaderDisplayMode.ItemBriefDetails:
                divDescription.Visible          = true;
                trCreatedFor.Visible            = false;
                trLocation.Visible              = false;
                upnlVisibility.Visible          = false;
                sbItemVisibilityToolTip.Visible = false;
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// Determines whether [is action valid].
        /// </summary>
        /// <returns></returns>
        private bool IsActionValid()
        {
            Data.Item item = null;
            if (this.GetBL <InventoryBL>().IsItemDeleted(this.ItemId))
            {
                popupItemDeletedWarning.ShowItemDeleteMessagePopup(this.ItemId, CompanyId);
                return(false);
            }
            else
            {
                item = GetBL <InventoryBL>().GetItem(this.ItemId);
            }

            if (!(Utils.IsCompanyInventoryAdmin(this.CompanyId, UserID) || Utils.IsCompanyInventoryStaffMember(CompanyId, this.UserID, item.LocationId, DataContext)))
            {
                bool canAccessInventory = Support.CanAccessInventory(this.CompanyId);
                projectWarningPopup.ShowErrorPopup(ErrorCodes.NoEditPermissionForInventory, !canAccessInventory);
                return(false);
            }
            else if (this.GetBL <InventoryBL>().CheckPermissionsForItemDetailsPage(UserID, ItemId, CompanyId, false) == null)
            {
                projectWarningPopup.ShowErrorPopup(ErrorCodes.ItemNotVisible);
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #3
0
        /// <summary>
        /// Exports the report.
        /// </summary>
        /// <param name="exportType">Type of the export.</param>
        private void ExportReport(ReportTypes exportType)
        {
            if (!this.IsFromSharedCompany)
            {
                Data.Item item = GetBL <InventoryBL>().GetItem(this.ItemId);
                if (item != null)
                {
                    ItemBookingListReportParameters parameters = new ItemBookingListReportParameters
                    {
                        ItemId         = this.ItemId,
                        SortExpression = gvBookingList.MasterTableView.SortExpressions.GetSortString(),
                        UserId         = this.UserID
                    };

                    string fileName = item.Name + "_Bookings";
                    string fileNameExtension;
                    string encoding;
                    string mimeType;

                    byte[] reportBytes = UserWebReportHandler.GenerateItemBookingListReport(parameters, exportType,
                                                                                            out fileNameExtension, out encoding, out mimeType);
                    Utils.ExportReport(reportBytes, mimeType, fileNameExtension, fileName);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Handles the Click event of the btnSendEmailToIM 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 btnSendEmailToBookingManager_Click(object sender, EventArgs e)
        {
            if (!PageBase.StopProcessing)
            {
                Data.Item item = GetBL <InventoryBL>().GetItem(this.ciItemCompleteTab.ItemId);
                if (item != null)
                {
                    Data.User    user           = GetBL <PersonalBL>().GetUser(this.UserID);
                    Data.Booking booking        = GetBL <InventoryBL>().GetBooking(this.ProjectId, GlobalConstants.RelatedTables.Bookings.Project);
                    Data.User    bookingManager = GetBL <InventoryBL>().GetContactBookingManager(item.CompanyId.Value, item.LocationId);

                    if (user != null && booking != null && bookingManager != null)
                    {
                        string userWebUrl   = Utils.GetSystemValue("SBUserWebURL");
                        string userInput    = HttpUtility.HtmlDecode(txtContactIMEmailBody.Text.Trim());
                        string emailContent = Utils.GetSafeHtmlFragments(userInput);
                        string itemUrl      = string.Format("{0}/Inventory/ItemDetails.aspx?ItemId={1}&CompanyId={2}", userWebUrl, item.ItemId, item.CompanyId.Value);
                        string bookingUrl   = string.Format("{0}/Inventory/BookingDetails.aspx?BookingId={1}&CompanyId={2}", userWebUrl, booking.BookingId, item.CompanyId.Value);

                        EmailSender.SendContactInventoryManagerForItemChangesDuetoBookingOverlapEmail(bookingManager.Email1,
                                                                                                      bookingManager.FirstName, user.FirstName, item.Name, itemUrl,
                                                                                                      GetBL <InventoryBL>().GetCompanyBookingNumber(booking.BookingId, item.CompanyId.Value).BookingNumber.ToString(CultureInfo.InvariantCulture),
                                                                                                      bookingUrl, emailContent);
                        popupBookingOverlapContactBookingManager.HidePopup();
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Update the specified item, or it doesn't exist, insert it.
        /// </summary>
        /// <param name="block_id"></param>
        /// <param name="min_level"></param>
        /// <param name="stack"></param>
        /// <param name="max_stack"></param>
        /// <param name="code"></param>
        /// <param name="name"></param>
        protected void updateItem(int block_id, int min_level, int stack, int max_stack, string code, string name)
        {
            Data.Item item = mDb.Items.SingleOrDefault(i => i.Block_Decimal_ID == block_id);

            if (item == null)
            {
                mDb.Items.InsertOnSubmit(new Data.Item()
                {
                    Code = code,
                    Name = name,
                    Block_Decimal_ID = block_id,
                    Min_Level = min_level,
                    Stack_Size = stack,
                    Max = max_stack
                });
            }
            else
            {
                item.Block_Decimal_ID = block_id;
                item.Code = code;
                item.Max = max_stack;
                item.Min_Level = min_level;
                item.Name = name;
                item.Stack_Size = stack;
            }
            mDb.SubmitChanges();
        }
예제 #6
0
        public static Item CreateItem(Data.IItem data, Transform rowTransform, bool useItemTypePrefabs, GameObject itemTypeText, GameObject itemTypeButton, GameObject itemTypeToggle)
        {
            Item item = null;

            Data.Item tmpData = data.Copy();

            if (tmpData != null)
            {
                if (useItemTypePrefabs)
                {
                    item = CreateItemFromPrefab(tmpData.GetItemType(), itemTypeText, itemTypeButton, itemTypeToggle);
                }
                if (item == null)
                {
                    GameObject objItem = new GameObject("Item");
                    item = objItem.AddComponent <List.Item>();
                }
                item.transform.SetParent(rowTransform);
                //item.SetIdManager(_idManager);
                item.AddData(tmpData);
                item.Initialize();
                item.SetFont(Font.CreateDynamicFontFromOSFont(Font.GetOSInstalledFontNames()[0], 12));
                //task.Invoke(task.Method.Name);
                //RegisterItemEvents(item, rowTransform.GetComponent<Row>());
            }
            return(item);
        }
예제 #7
0
        public ActionResult Update(Models.Item item)
        {
            Data.Item persistentItem = Mapper.Map <Models.Item, Data.Item>(item);
            Itemizing.Update(persistentItem);

            return(Content(JsonConvert.SerializeObject(Mapper.Map <Data.Item, Models.Item>(persistentItem))));
        }
예제 #8
0
        /// <summary>
        /// Returns the item information for the items with the given ID
        /// </summary>
        /// <param name="itemID">ID of the item</param>
        /// <returns>Item object containing all item information, or null if the itemName is invalid</returns>
        public GW2PAO.API.Data.Item GetItem(int itemID)
        {
            GW2PAO.API.Data.Item item = null;

            try
            {
                var itemDetails = this.itemService.Find(itemID);
                if (itemDetails != null)
                {
                    item                  = new Data.Item(itemID, itemDetails.Name);
                    item.Icon             = itemDetails.IconFileUrl;
                    item.Description      = itemDetails.Description;
                    item.Rarity           = (Data.Enums.ItemRarity)itemDetails.Rarity;
                    item.Flags            = (Data.Enums.ItemFlags)itemDetails.Flags;
                    item.GameTypes        = (Data.Enums.ItemGameTypes)itemDetails.GameTypes;
                    item.LevelRequirement = itemDetails.Level;
                    item.VenderValue      = itemDetails.VendorValue;
                    item.ChatCode         = itemDetails.GetItemChatLink().ToString();
                    item.Prices           = this.GetItemPrices(itemID);

                    // Since there is no need to use ALL details right now, we'll just get what we need...
                    // TODO: Finish this up, get all details, such as Type, SkinID
                }
            }
            catch (GW2DotNET.Common.ServiceException ex)
            {
                // Don't crash, just return null
                logger.Warn("Error finding item with id {0}: {1}", itemID, ex);
            }

            return(item);
        }
예제 #9
0
 /// <summary>
 /// Get the basic data of the item.
 /// </summary>
 private void GetBasicInformation()
 {
     Data.Item item = Data.ItemTemplate[itemCategory][itemType]; // Find the data of the item from array itemTemplate (stored in class Init).
     itemName        = item.name;
     itemMass        = item.mass;
     itemRotateSpeed = item.rotateSpeed;
 }
예제 #10
0
        /// <summary>
        /// Initializes the popup.
        /// </summary>
        private void InitializePopup()
        {
            if (this.CompanyId > 0 && this.ItemId > 0)
            {
                btnDoneItemDeleted.CommandArgument = this.CompanyId.ToString();
                DeletedItemDatails deletedItemData = this.GetBL <InventoryBL>().GetDeleteItemData(this.ItemId);
                if (deletedItemData != null)
                {
                    ltrItemDeletedUser.Text           = deletedItemData.ItemDeletedUser;
                    lnkItemDeletedUserEmail.InnerText = deletedItemData.ItemDeletedUserEmail;
                    lnkItemDeletedUserEmail.HRef      = "mailto:" + deletedItemData.ItemDeletedUserEmail;
                }
                else
                {
                    Data.Item item = GetBL <InventoryBL>().GetItem(this.ItemId);
                    if (item != null)
                    {
                        Data.User inventoryAdmin = GetBL <InventoryBL>().GetContactBookingManager(item.CompanyId.Value, item.LocationId);
                        if (inventoryAdmin != null)
                        {
                            ltrItemDeletedUser.Text           = "An user";
                            lnkItemDeletedUserEmail.InnerText = inventoryAdmin.FirstName + " " + inventoryAdmin.LastName;
                            lnkItemDeletedUserEmail.HRef      = "mailto:" + inventoryAdmin.Email1;
                        }
                    }
                }

                popupItemDeleted.IsDefault = this.IsDefault;
            }
        }
예제 #11
0
        public string End()
        {
            if (this.IsBinding() == false)
            {
                return("Bind needs to be opened!");
            }

            var item = new Data.Item(this.bindingName, this.bindingCommands.ToArray());

            this.data.items.Add(item);

            this.Save();

            for (int i = 0; i < this.bindingCommands.Count; ++i)
            {
                this.screen.AddLine("Put command into binding: " + this.bindingCommands[i]);
            }
            this.screen.AddLine("Commands added into " + this.bindingName + ": " + this.bindingCommands.Count);

            this.binding     = false;
            this.bindingName = string.Empty;
            this.bindingCommands.Clear();

            return(string.Empty);
        }
예제 #12
0
 public NavigatePanelNode(Data.Item item)
 {
     this.itemRef = new WeakReference <Data.Item>(item);
     this.Name    = item.Name;
     if (NavigatePanelNodeCreated != null)
     {
         NavigatePanelNodeCreated(this);
     }
 }
예제 #13
0
 public Item(Data.Item AssocItem, uint OwnerId, byte Plus, bool IsBlue, uint Amount, uint ObjectId)
 {
     this.AssocItem = AssocItem;
     this.OwnerId   = OwnerId;
     this.Plus      = Plus;
     this.IsBlue    = IsBlue;
     this.ObjectId  = ObjectId;
     this.Amount    = Amount;
 }
예제 #14
0
        /// <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);
            }
        }
예제 #15
0
        private void AddPreviousItemButton_Click_Click(object sender, RoutedEventArgs e)
        {
            DependencyObject button           = e.Source as DependencyObject;
            DependencyObject contentpresenter = VisualTreeHelper.GetParent(button); // ContentPresenter

            if (contentpresenter is ContentPresenter)
            {
                Data.Item itemtoadd = (Data.Item)((ContentPresenter)contentpresenter).Content;
                //itemtoadd.DisplayOrder = PawnItems.Count();
                PawnItems.Add(itemtoadd);
                itemsupdated(PawnItems);
                PreviousItemsListView.Visibility = Visibility.Collapsed;
            }
        }
        /// <summary>
        /// Updates the items.
        /// </summary>
        /// <param name="itemIds">The item ids.</param>
        public void UpdateItems(List <int> itemIds)
        {
            if (!PageBase.StopProcessing)
            {
                bool hasChanges = false;
                ErrorItemIds = new Dictionary <int, string>();

                foreach (int itemId in itemIds)
                {
                    Data.Item item = GetBL <InventoryBL>().GetItem(itemId);
                    if (item != null && item.IsActive && item.CompanyId.Value == this.CompanyId)
                    {
                        if (Utils.HasLocationManagerPermission(this.CompanyId, this.UserID, item.LocationId))
                        {
                            if (GetBL <InventoryBL>().IsItemInUse(itemId) || GetBL <InventoryBL>().IsItemOverDue(itemId) || GetBL <InventoryBL>().HasFutureBookingsForItem(itemId))
                            {
                                ErrorItemIds.Add(itemId, "Please complete or remove the booking for this item before changing its visibility.");
                            }
                            else
                            {
                                item.VisibilityLevelCodeId = this.VisibilityLevel;
                                hasChanges = true;
                            }
                        }
                        else
                        {
                            ErrorItemIds.Add(itemId, "Sorry, you're not allowed to change this item's visibility.");
                        }
                    }
                }

                if (hasChanges)
                {
                    GetBL <InventoryBL>().SaveChanges();
                }

                if (ErrorItemIds.Count > 0)
                {
                    if (this.ItemId > 0)
                    {
                        popupConcurrencyVisibilityItemDetails.ShowPopup();
                    }
                    else
                    {
                        popupConcurrencyVisibilityBulkEdit.ShowPopup();
                    }
                }
            }
        }
예제 #17
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        private void LoadData()
        {
            reqName.ControlToValidate      = itemNameEdit.TextBox.ID;
            sbInventoryLocations.CompanyId = this.CompanyId;

            bool showAll = false;

            InitializeIds();
            LoadItemTypes();

            if (ItemId > 0)
            {
                sbItemVisibilityToolTip.ItemId = this.ItemId;
                sbItemVisibilityToolTip.LoadData();

                // Show/Hide in the place it's being used (ItemDetails or ItemBriefDetails)
                divBookedQty.Visible = !(ItemBriefId > 0);
                trItemStatus.Visible = false;
                Data.Item item = GetBL <InventoryBL>().GetItem(this.ItemId);

                // Show location for users have No Access + Shared Inventory permissions
                if (item != null)
                {
                    Code visibilityCode = GetBL <InventoryBL>().GetUserInventoryVisibilityLevel(item.CompanyId.Value,
                                                                                                this.UserID, item.LocationId, false);
                    showAll = visibilityCode.SortOrder >= Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_IO").SortOrder;
                }

                if (ItemBriefId > 0)
                {
                    Data.ItemBooking itemBooking = this.GetBL <InventoryBL>().GetItemBookingByRelatedTable(ItemBriefId, "ItemBrief", true);
                    if (itemBooking != null && itemBooking.ToDate.HasValue)
                    {
                        trItemStatus.Visible = true;
                    }
                }
            }
            else if (ItemBriefId > 0)
            {
                trItemStatus.Visible = false;
                lblItemStatus.Text   = string.Empty;
                divBookedQty.Visible = false;
            }

            sbInventoryLocations.LoadData(showAll: showAll);
            upnlItemBriefThumb.Update();
        }
예제 #18
0
 /// <summary>
 /// Handles the Click event of the lnkAddToWatchList 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 lnkAddToWatchList_Click(object sender, EventArgs e)
 {
     if (!StopProcessing)
     {
         Data.Item item = DataContext.Items.Where(i => i.ItemId == ItemId).FirstOrDefault();
         if (item.CompanyId.Value != CompanyId && this.GetBL <InventoryBL>().IsCompanyInventorySharingRemoved(item.CompanyId.Value, CompanyId))
         {
             popupInventorySharingRemovedWarning.ShowInventorySharingRemoved(CompanyId, item.CompanyId.Value);
             return;
         }
         else
         {
             Support.AddToWatchList(ItemId, CompanyId);
             LoadData();
         }
     }
 }
예제 #19
0
        /// <summary>
        /// Returns the item information for the items with the given IDs
        /// </summary>
        /// <param name="itemIDs">IDs of the items to retrieve</param>
        /// <returns>Collection of Item objects containing all item information</returns>
        public IDictionary <int, GW2PAO.API.Data.Item> GetItems(ICollection <int> itemIDs)
        {
            Dictionary <int, GW2PAO.API.Data.Item> items = new Dictionary <int, GW2PAO.API.Data.Item>();

            try
            {
                // Remove all items with itemID of 0 or less
                var validIDs = itemIDs.Where(id => id > 0).ToList();

                var itemDetails = this.itemService.FindAll(validIDs);
                var prices      = this.GetItemPrices(validIDs);

                foreach (var itemDetail in itemDetails)
                {
                    GW2PAO.API.Data.Item item = new Data.Item(itemDetail.Key, itemDetail.Value.Name);
                    item.Icon             = itemDetail.Value.IconFileUrl;
                    item.Description      = itemDetail.Value.Description;
                    item.Rarity           = (Data.Enums.ItemRarity)itemDetail.Value.Rarity;
                    item.Flags            = (Data.Enums.ItemFlags)itemDetail.Value.Flags;
                    item.GameTypes        = (Data.Enums.ItemGameTypes)itemDetail.Value.GameTypes;
                    item.LevelRequirement = itemDetail.Value.Level;
                    item.VenderValue      = itemDetail.Value.VendorValue;
                    item.ChatCode         = itemDetail.Value.GetItemChatLink().ToString();
                    if (prices.ContainsKey(item.ID))
                    {
                        item.Prices = prices[item.ID];
                    }
                    else
                    {
                        item.Prices = new ItemPrices(); // empty, no prices found
                    }
                    // Since there is no need to use ALL details right now, we'll just get what we need...
                    // TODO: Finish this up, get all details, such as Type, SkinID

                    items.Add(item.ID, item);
                }
            }
            catch (GW2DotNET.Common.ServiceException ex)
            {
                // Don't crash, just return null
                logger.Warn("Error finding item: {0}", ex);
            }

            return(items);
        }
예제 #20
0
        /// <summary>
        /// Initializes the ids.
        /// </summary>
        /// <param name="itemId">The item identifier.</param>
        /// <param name="itemBriefId">The item brief identifier.</param>
        /// <param name="isItemCreated">if set to <c>true</c> [is item created].</param>
        public void InitializeIds(ref int itemId, ref int itemBriefId, ref bool isItemCreated)
        {
            InventoryBL inventoryBL = new InventoryBL(DataContext);
            ItemBriefBL itemBriefBL = new ItemBriefBL(DataContext);

            if (itemId > 0)
            {
                StageBitz.Data.Item item = inventoryBL.GetItem(itemId);

                if (item != null)
                {
                    isItemCreated = true;
                }
            }
            else if (itemBriefId > 0)
            {
                StageBitz.Data.ItemBrief itemBrief = itemBriefBL.GetItemBrief(itemBriefId);

                if (itemBrief != null)
                {
                    ItemBooking itemBooking = itemBriefBL.GetInUseItemBooking(itemBriefId);

                    Data.Item item = null;
                    if (itemBooking != null)
                    {
                        item = itemBooking.Item;
                    }

                    if (item != null)
                    {
                        itemId        = item.ItemId;
                        isItemCreated = true;
                    }
                    else
                    {
                        isItemCreated = false;
                    }
                }
            }
        }
예제 #21
0
 /// <summary>
 /// Handles the Click event of the lbtnOk 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 lbtnOk_Click(object sender, EventArgs e)
 {
     if (!PageBase.StopProcessing)
     {
         if (rntxtQuntity.Value.HasValue && RelatedTable == "Item" && ItemBriefId.HasValue)
         {
             Data.Item        item        = this.GetBL <InventoryBL>().GetItem(ItemId);
             Data.ItemBooking itemBooking = GetBL <InventoryBL>().GetItemBookingByItemID(ItemId, ItemBriefId.Value, "ItemBrief");
             if (itemBooking != null && itemBooking.ItemBookingStatusCodeId == Utils.GetCodeIdByCodeValue("ItemBookingStatusCode", "PINNED"))
             {
                 if (item != null && itemBooking.ToDate.HasValue)
                 {
                     int?availableQuntity = this.GetBL <InventoryBL>().GetAvailableItemQuantity(this.ItemId, itemBooking.FromDate, itemBooking.ToDate.Value);
                     if (availableQuntity.HasValue && (availableQuntity + itemBooking.Quantity) >= rntxtQuntity.Value.Value)
                     {
                         itemBooking.Quantity       = (int)rntxtQuntity.Value.Value;
                         itemBooking.LastUpdateDate = Now;
                         itemBooking.LastUpdatedBy  = UserID;
                         this.GetBL <InventoryBL>().SaveChanges();
                     }
                     else
                     {
                         if (ShowConcurencyErrorPopup != null)
                         {
                             ShowConcurencyErrorPopup(ItemBrief.PinnedItems.PinnedItemsConcurrencyType.InvalidAvailableQuntity);
                         }
                     }
                 }
             }
             else
             {
                 if (ShowConcurencyErrorPopup != null)
                 {
                     ShowConcurencyErrorPopup(ItemBrief.PinnedItems.PinnedItemsConcurrencyType.ItemAlreadyConfirmed);
                 }
             }
         }
     }
 }
        /// <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));
            }
        }
예제 #23
0
        /// <summary>
        /// Initializes the ids.
        /// </summary>
        private void InitializeIds()
        {
            if (ItemId > 0)
            {
                StageBitz.Data.Item item = this.GetBL <InventoryBL>().GetItem(ItemId);

                if (item != null)
                {
                    IsItemCreated   = true;
                    this.ItemTypeId = item.ItemTypeId.Value;
                }
            }
            else if (ItemBriefId > 0)
            {
                StageBitz.Data.ItemBrief itemBrief = this.GetBL <ItemBriefBL>().GetItemBrief(ItemBriefId);

                if (itemBrief != null)
                {
                    Data.ItemBooking itemBooking = this.GetBL <InventoryBL>().GetItemBookingByRelatedTable(ItemBriefId, "ItemBrief", true);
                    Data.Item        item        = null;
                    if (itemBooking != null)
                    {
                        item = itemBooking.Item;
                    }

                    if (item != null)
                    {
                        ItemId          = item.ItemId;
                        IsItemCreated   = true;
                        this.ItemTypeId = item.ItemTypeId.Value;
                    }
                    else
                    {
                        IsItemCreated   = false;
                        this.ItemTypeId = itemBrief.ItemBriefTypes.FirstOrDefault().ItemTypeId;
                    }
                }
            }
        }
예제 #24
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        public void LoadData()
        {
            if (this.ItemId > 0)
            {
                Code above_sharedInventory = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_SHAREDINVENTORY");
                Code above_IO = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_IO");
                Code above_IS = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_IS");
                Code above_IA = Utils.GetCodeByValue("InventoryVisibilityLevel", "ABOVE_IA");

                Data.Item item = GetBL <InventoryBL>().GetItem(this.ItemId);
                if (item != null)
                {
                    string template = "<div>This item is visible to:</div><div><ul>{0}{1}{2}{3}</ul></div>";
                    string text     = string.Empty;
                    if (item.VisibilityLevelCodeId == above_IA.CodeId)
                    {
                        text = string.Format(template, "<li>Administrators only</li>", string.Empty, string.Empty, string.Empty);
                    }
                    else if (item.VisibilityLevelCodeId == above_IS.CodeId)
                    {
                        text = string.Format(template, string.Empty, "<li>Inventory Staff</li>", string.Empty, string.Empty);
                    }
                    else if (item.VisibilityLevelCodeId == above_IO.CodeId)
                    {
                        text = string.Format(template, string.Empty, "<li>Inventory Staff</li>", "<li>Inventory Observers</li>", string.Empty);
                    }
                    else if (item.VisibilityLevelCodeId == above_sharedInventory.CodeId)
                    {
                        text = string.Format(template, string.Empty, "<li>Inventory Staff</li>", "<li>Inventory Observers</li>", "<li>Visitors from Shared Inventories</li>");
                    }

                    ltrlVisibility.Text = text;
                }

                upnlVisibility.Update();
            }
        }
예제 #25
0
 /// <summary>
 /// Loads the item.
 /// </summary>
 /// <param name="item">The item.</param>
 private void LoadItem(Data.Item item)
 {
     documentList.RelatedTableName = "Item";
     documentList.RelatedId        = item.ItemId;
 }
예제 #26
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        public void LoadData()
        {
            int relatedId    = (RelatedTable == "ItemBrief") && ItemBriefId.HasValue ? ItemBriefId.Value : ItemId;
            var defaultImage = (from m in DataContext.DocumentMedias
                                where m.RelatedTableName == RelatedTable && m.RelatedId == relatedId &&
                                m.IsImageFile == true
                                orderby m.SortOrder descending
                                select new { m.DocumentMediaId, m.Name }).FirstOrDefault();

            if (defaultImage != null)
            {
                thumbItem.DocumentMediaId = defaultImage.DocumentMediaId;
                thumbItem.ImageTitle      = defaultImage.Name;
            }

            if (RelatedTable == "ItemBrief")
            {
                if (ItemBriefId.HasValue)
                {
                    Data.ItemBrief itemBrief = GetBL <ItemBriefBL>().GetItemBrief(ItemBriefId.Value);
                    if (itemBrief != null)
                    {
                        lblName.Text = Support.TruncateString(itemBrief.Name, 20);
                        if (itemBrief.Name.Length > 20)
                        {
                            lblName.ToolTip = itemBrief.Name;
                        }

                        if (itemBrief.Quantity != null)
                        {
                            lblQuantity.Text   = itemBrief.Quantity.ToString();
                            rntxtQuntity.Value = itemBrief.Quantity;
                        }
                        else
                        {
                            trQuantity.Visible = false;
                        }

                        trStatus.Visible         = false;
                        trCompany.Visible        = false;
                        lblDescription.InnerText = Support.TruncateString(itemBrief.Description, 60);
                        if (itemBrief.Description != null && itemBrief.Description.Length > 60)
                        {
                            lblDescription.Attributes.Add("title", itemBrief.Description);
                        }
                    }

                    trLocation.Visible = false;
                }
            }
            else
            {
                Data.Item item = this.GetBL <InventoryBL>().GetItem(ItemId);
                if (item != null)
                {
                    lblName.Text = Support.TruncateString(item.Name, 20);
                    if (item.Name.Length > 20)
                    {
                        lblName.ToolTip = item.Name;
                    }

                    if (item.Quantity != null)
                    {
                        lblQuantity.Text = item.Quantity.ToString();
                    }
                    else
                    {
                        trQuantity.Visible = false;
                    }

                    trCompany.Visible = true;
                    string companyName = Support.GetCompanyNameById(Convert.ToInt32(item.CompanyId));
                    lblcompany.Text = Support.TruncateString(companyName, 20);
                    if (companyName.Length > 20)
                    {
                        lblcompany.ToolTip = companyName;
                    }

                    string path = GetBL <LocationBL>().GetLocationPath(item.LocationId, item.CompanyId.Value);
                    lblLocation.Text = Utils.ReverseEllipsize(path, 22);
                    if (path.Length > 22)
                    {
                        lblLocation.ToolTip = path;
                    }

                    // If both ItemBriefId and ItemId exists need to get information from ItemBooking (this is specific for Pinboard tab)
                    if (ItemBriefId.HasValue)
                    {
                        Data.ItemBooking itemBooking = GetBL <InventoryBL>().GetItemBookingByItemID(ItemId, ItemBriefId.Value, "ItemBrief");

                        if (itemBooking != null && itemBooking.ToDate.HasValue)
                        {
                            litStatus.Text  = GetBL <InventoryBL>().GetItemBookingStatus(itemBooking.ItemBookingId).Description;
                            lnkName.Visible = true;
                            lblName.Visible = false;

                            lnkName.Text        = Support.TruncateString(item.Name, 20);
                            lnkName.NavigateUrl = string.Format("~/Inventory/ItemDetails.aspx?ItemId={0}&CompanyId={1}", this.ItemId, GetBL <ItemBriefBL>().GetItemBrief(itemBooking.RelatedId).Project.CompanyId);
                            if (item.Name.Length > 20)
                            {
                                lnkName.ToolTip = item.Name;
                            }

                            int availableQuntity = this.GetBL <InventoryBL>().GetAvailableItemQuantity(this.ItemId, itemBooking.FromDate, itemBooking.ToDate.Value);
                            int maxQty           = availableQuntity + itemBooking.Quantity;
                            rntxtQuntity.MaxValue = maxQty;
                            lblAvailableQty.Text  = maxQty.ToString(CultureInfo.InvariantCulture);

                            rntxtQuntity.MinValue = availableQuntity == 0 ? 0 : 1;
                            rntxtQuntity.Value    = itemBooking.Quantity >= rntxtQuntity.MinValue ? itemBooking.Quantity : rntxtQuntity.MinValue;
                            lblQuantity.Text      = itemBooking.Quantity.ToString(CultureInfo.InvariantCulture);

                            litFromDate.Text      = Support.FormatDate(itemBooking.FromDate);
                            litToDate.Text        = Support.FormatDate(itemBooking.ToDate);
                            trBookingFrom.Visible = true;
                            trBookingTo.Visible   = true;
                        }
                        else
                        {
                            trStatus.Visible = false;
                        }

                        this.IsReadOnly = this.IsReadOnly ||
                                          itemBooking.ItemBookingStatusCodeId != Utils.GetCodeIdByCodeValue("ItemBookingStatusCode", "PINNED") || !itemBooking.ToDate.HasValue ||
                                          itemBooking.ToDate < Utils.Today;
                    }
                    else
                    {
                        trStatus.Visible = false;
                    }

                    lblDescription.InnerText = Support.TruncateString(item.Description, 60);
                    if (item.Description != null && item.Description.Length > 60)
                    {
                        lblDescription.Attributes.Add("title", item.Description);
                    }
                }
            }

            InitializeEditMode();
        }
예제 #27
0
        private void subBgtimer_Tick(object sender, EventArgs e)
        {
            DocumentParser parser = subBackGroundParser.GetResult();

            if (parser == null)   // entry parse
            {
                if (subBackGroundParser.RemainingStocks != 0)
                {
                    return;
                }
                NavigatePanel.NavigatePanelNode node;
                Controller.NavigatePanel.GetSelectedNode(out node);
                if (node == null || node.Item == null)
                {
                    return;
                }
                Data.Project project = node.Item.Project;

                Data.Item item = project.FetchReparseTarget();
                if (item == null)
                {
                    return;
                }

                checkID("before entry parse");

                DocumentParser newParser = item.CreateDocumentParser(DocumentParser.ParseModeEnum.BackgroundParse);
                if (newParser != null)
                {
                    subBackGroundParser.EntryParse(newParser);
                    Controller.AppendLog("entry parse " + item.ID + " " + DateTime.Now.ToString());
                }
                checkID("after entry parse");
            }
            else
            { // receive result
                if (TextFile != null && TextFile == parser.TextFile)
                {
                    if (CodeDocument != null && CodeDocument.EditID != parser.EditId)
                    {
                        Controller.AppendLog("parsed mismatch sub " + parser.TextFile.Name + " " + DateTime.Now.ToString());
//                        TextFile.ParseRequested = false;
                        return;
                    }
                }

                Controller.AppendLog("parsed sub  " + parser.TextFile.Name + " " + DateTime.Now.ToString());
                if (parser.TextFile.Name == "TOP_0")
                {
                    string a = "";
                }
                Data.TextFile textFile = parser.TextFile;

                if (textFile == null)
                {
                    return;
                }
                //if (textFile.ParsedDocument == null)
                //{
                //    textFile.Close();
                //    textFile.ParseRequested = false;
                //    return;
                //}

                checkID("before accept parsed document");

                textFile.AcceptParsedDocument(parser.ParsedDocument);
                if (TextFile != textFile)
                {
                    textFile.Close();
                }
                if (textFile.NavigatePanelNode != null)
                {
                    textFile.NavigatePanelNode.Update();
                }

                Controller.NavigatePanel.UpdateVisibleNode();
                Controller.NavigatePanel.Refresh();
                parser.Dispose();

                checkID("after accept parsed document");
            }
        }
예제 #28
0
		private string Import_INTERNAL(string filename, bool silent, ImportFlag flag) {

			filename = filename.ToLower();

			var filepath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), filename + ".xml");
			if (File.Exists(filepath) == false) {

				if (silent == true) return string.Empty;

				return "File `" + filepath + "` not found.";

			}
			
			this.screen.AddLine("<color=grey>Importing `" + filepath + "`...</color>");

			XmlSerializer serializer =  new XmlSerializer(typeof(Data));
			FileStream fs = new FileStream(filepath, FileMode.Open);
			
			var data = (Data)serializer.Deserialize(fs);
			if (flag == ImportFlag.Override) {

				this.data = data;
				this.AutoStartPlay(this.data);

			} else if (flag == ImportFlag.Merge) {
				
				foreach (var newItem in data.items) {
					
					if (this.Exists(newItem.name) == false) {

						var item = new Data.Item(newItem);
						this.data.items.Add(item);

					}
			    
			    }

				foreach (var item in this.data.items) {

					foreach (var newItem in data.items) {

						if (item.name.ToLower().Trim() == newItem.name.ToLower().Trim()) {

							item.autostart = newItem.autostart;
							item.commands = newItem.commands;

							if (item.autostart == true) {

								this.Play(item.name);

							}

						}

					}

				}

			}

			fs.Close();

			this.Save();

			this.screen.AddLine("<color=grey>File `" + filepath + "` has been imported.</color>");

			return string.Empty;
			
		}
예제 #29
0
        /// <summary>
        /// Creates an ItemWrapper from an Item
        /// </summary>
        public static ItemWrapper ToItemWrapper(this Data.Item item)
        {
            ItemWrapper wrapper = new ItemWrapper(item);

            return(wrapper);
        }
예제 #30
0
        /// <summary>
        /// Loads the data.
        /// </summary>
        public void LoadData()
        {
            bool canEditIteminItemBrief = GetBL <InventoryBL>().CanEditIteminItemBrief(ItemBriefId);

            this.IsReadOnly = IsItemBriefReadOnly || !canEditIteminItemBrief;

            Data.ItemBooking        itemBooking        = GetBL <InventoryBL>().GetInUseOrCompleteItemBooking(ItemBriefId);
            Data.Item               completedItem      = null;
            Data.ItemVersionHistory itemVersionHistory = null;
            if (itemBooking != null)
            {
                completedItem = itemBooking.Item;
            }
            else
            {
                itemVersionHistory = GetBL <InventoryBL>().GetItemVersionHistoryByItemBriefId(ItemBriefId);
            }

            if (completedItem == null && itemVersionHistory == null)
            {
                ShowHideItemCompleteTab(false);
                this.HasItem = false;
                if (HasCompanyReachedInventoryLimit())
                {
                    if (this.GetBL <ItemBriefBL>().HasPinnedItems(ItemBriefId))
                    {
                        liInventoryLimitReachedMsg.Visible   = true;
                        liInventoryLimitReachedMsg.InnerText = "Update its listing in the Company Inventory";
                    }
                    else
                    {
                        liInventoryLimitReachedMsg.Visible = false;
                    }
                }
                else
                {
                    liInventoryLimitReachedMsg.Visible = true;
                }

                var pinnedItems     = this.GetBL <ItemBriefBL>().GetAllPinnedItems(ItemBriefId);
                int pinnedItemCount = pinnedItems.Count();

                //If the Item(s) were pined from Inventory. If so, display the text.
                if (pinnedItemCount > 1 || pinnedItemCount == 1 && !this.GetBL <InventoryBL>().IsItemGeneretedFromGivenItemBrief(pinnedItems.FirstOrDefault().ItemId, ItemBriefId))
                {
                    string headerText = (string.Format("<b>{0} {1}  been suggested for this {2} Brief. </b>", pinnedItemCount, pinnedItemCount == 1 ?
                                                       "Item has" : "Items have", this.GetBL <ItemBriefBL>().GetItemBriefType(ItemBriefId).ItemType.Name));
                    string bodyText = "</br>It's decision time...Before you can complete this you'll need to confirm if you wish to use an Item booked from the Inventory that is currently showing on the Pinboard tab. Once you've done that the details will appear here for you to check.</br></br>";
                    litForNotYetKeptItem.Text = string.Concat(headerText, bodyText);
                    divBlankNotice.Visible    = false;
                }
                else
                {
                    litForNotYetKeptItem.Visible = false;
                    divBlankNotice.Visible       = true;
                }
            }
            else
            {
                ShowHideItemCompleteTab(true);
                litForNotYetKeptItem.Visible = false;
                this.HasItem = true;
                if (itemVersionHistory == null)
                {
                    litNormalText.Visible = true;

                    litNormalText.Text = this.GetBL <InventoryBL>().GetDefaultMessageToDisplayInCompleteItemTab(completedItem.ItemId, ItemBriefId);
                }
                else
                {
                    divOriginalVersionText.Visible = true;
                    litNormalText.Visible          = false;
                    if (GetBL <ProjectBL>().IsProjectClosed(ProjectId))
                    {
                        litProjCloseDate.Text = "when the project was closed on " + Support.FormatDate(GetBL <ProjectBL>().GetProjectArchive(ProjectId).ProjectClosedDate) + ".";
                    }
                    else
                    {
                        litProjCloseDate.Text = "when it was released to the Inventory on " + Support.FormatDate(GetBL <InventoryBL>().GetItemBriefItemReleaseDate(ItemBriefId)) + ".";
                    }

                    if (!this.GetBL <InventoryBL>().IsItemHidden(itemVersionHistory.ItemId) &&
                        itemVersionHistory.Item.Code.SortOrder >= GetBL <InventoryBL>().GetUserInventoryVisibilityLevel(itemVersionHistory.Item.CompanyId.Value, this.UserID, itemVersionHistory.Item.LocationId, false).SortOrder)
                    {
                        lnkItemName.Visible = true;
                        lblItemName.Visible = false;
                        lnkItemName.Text    = Support.TruncateString(itemVersionHistory.Name, 40);
                        if (itemVersionHistory.Name.Length > 40)
                        {
                            lnkItemName.ToolTip = itemVersionHistory.Name;
                        }
                        lnkItemName.NavigateUrl = ResolveUrl(string.Format("~/Inventory/ItemDetails.aspx?ItemId={0}&CompanyId={1}", itemVersionHistory.ItemId, Support.GetCompanyByProjectId(ProjectId).CompanyId));
                    }
                    else
                    {
                        lnkItemName.Visible = false;
                        lblItemName.Visible = true;
                        lblItemName.Text    = Support.TruncateString(itemVersionHistory.Name, 40);
                        if (itemVersionHistory.Name.Length > 40)
                        {
                            lblItemName.ToolTip = itemVersionHistory.Name;
                        }
                    }
                }
            }

            InitailizeValidationGroup();

            InitializeItemCompletePopup();
            InitializeItemCompleteTab();
            IntializeCompleteButton();

            UpdateUpdatePanels();
        }
예제 #31
0
		public string End() {
			
			if (this.IsBinding() == false) {
				
				return "Bind needs to be opened!";
				
			}

			var item = new Data.Item(this.bindingName, this.bindingCommands.ToArray());
			this.data.items.Add(item);

			this.Save();
			
			for (int i = 0; i < this.bindingCommands.Count; ++i) this.screen.AddLine("Put command into binding: " + this.bindingCommands[i]);
			this.screen.AddLine("Commands added into " + this.bindingName + ": " + this.bindingCommands.Count);

			this.binding = false;
			this.bindingName = string.Empty;
			this.bindingCommands.Clear();

			return string.Empty;

		}
예제 #32
0
        /// <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);
                        }
                    }
                }
            }
        }