public void Add(ItemViewModel itemViewModel)
        {
            TemplateItem templateItem = new TemplateItem(TemplateModel, itemViewModel.ItemModel);

            TemplateModel.TemplateItems.Add(templateItem);
            ItemViewModels.Add(ItemViewModelFactory.GetItemViewModel(templateItem));
        }
Exemplo n.º 2
0
        public void Add(ItemViewModel itemViewModel)
        {
            PanelItem panelItem = new PanelItem(PanelModel, itemViewModel.ItemModel);

            panelItem.Quantity = itemViewModel.Quantity;
            PanelModel.PanelItems.Add(panelItem);
            ItemViewModels.Add(ItemViewModelFactory.GetItemViewModel(panelItem));
        }
Exemplo n.º 3
0
        private void AddItem(int quantity)
        {
            bool isItemSame = false;

            ItemViewModel itemViewModel = new ItemViewModel();

            itemViewModel.Id          = 1;
            itemViewModel.CompanyId   = Convert.ToInt32(companyDropDownList.SelectedValue);
            itemViewModel.CompanyName = companyDropDownList.SelectedItem.ToString();
            itemViewModel.ItemId      = Convert.ToInt32(itemDropDownList.SelectedValue);
            itemViewModel.ItemName    = itemDropDownList.SelectedItem.ToString();
            itemViewModel.Quantity    = quantity;

            if (ViewState["itemVS"] == null)
            {
                ItemViewModels.Add(itemViewModel);
                ViewState["itemVS"] = ItemViewModels;

                stockOutGridView.DataSource = ItemViewModels;
                stockOutGridView.DataBind();
                outputLabel.Text = "Item Added";
            }
            else
            {
                ItemViewModels = (List <ItemViewModel>)ViewState["itemVS"];
                foreach (ItemViewModel itemView in ItemViewModels)
                {
                    if (itemView.CompanyId == itemViewModel.CompanyId && itemView.ItemId == itemViewModel.ItemId)
                    {
                        isItemSame = true;
                        break;
                    }
                }

                if (isItemSame)
                {
                    outputLabel.Text = "Item can not be same";
                }
                else
                {
                    itemViewModel.Id += ItemViewModels.Count;
                    ItemViewModels.Add(itemViewModel);
                    ViewState["itemVS"] = ItemViewModels;

                    stockOutGridView.DataSource = ItemViewModels;
                    stockOutGridView.DataBind();
                    outputLabel.Text = "Item Added";
                }
            }
        }
        private void GetItems()
        {
            foreach (Item item in Items)
            {
                Company  = ItemManager.GetCompanyById(item.CompanyId);
                Category = ItemManager.GetCategoryById(item.CategoryId);

                ItemViewModel itemViewModel = new ItemViewModel();
                itemViewModel.Id           = ItemViewModels.Count + 1;
                itemViewModel.ItemName     = item.Name;
                itemViewModel.CompanyName  = Company.Name;
                itemViewModel.CategoryName = Category.Name;
                itemViewModel.Quantity     = item.Quantity;
                itemViewModel.ReorderLevel = item.ReorderLevel;

                ItemViewModels.Add(itemViewModel);
            }

            itemsGridView.DataSource = ItemViewModels;
            itemsGridView.DataBind();
        }