Beispiel #1
0
        private void addCategory_Click(object sender, EventArgs e)
        {
            AddCategory addCategoryForm = new AddCategory(this.currentUser);

            addCategoryForm.FormClosed += new FormClosedEventHandler(AddCategoryClosed);
            addCategoryForm.ShowDialog();
        }
Beispiel #2
0
        private void PictureBox17_Click(object sender, EventArgs e)
        {
            AddCategory p = new AddCategory();

            p.FormClosing += new FormClosingEventHandler(updAdminCategoryActions);
            p.Show();
        }
Beispiel #3
0
        public ActionResult EditCategory(AddCategory obj)
        {
            if (ModelState.IsValid)
            {
                var user     = dobj.Users.Where(x => x.EmailID == User.Identity.Name).FirstOrDefault();
                var category = dobj.NoteCategories.Where(x => x.ID == obj.ID).FirstOrDefault();

                if (category == null)
                {
                    return(HttpNotFound());
                }

                category.Name         = obj.Name.Trim();
                category.Description  = obj.Description.Trim();
                category.ModifiedDate = DateTime.Now;
                category.ModifiedBy   = user.ID;

                dobj.Entry(category).State = EntityState.Modified;
                dobj.SaveChanges();

                return(RedirectToAction("ManageCategory"));
            }
            else
            {
                return(View(obj));
            }
        }
Beispiel #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            BalanceState = await _inventorizationQueries.GetBalanceState();

            return(await AddCategory.ProcessAsync(ModelState, nameof(AddCategory),
                                                  async() =>
            {
                await _categoriesCommands.Update(new CategoryModel {
                    Name = AddCategory.Category
                });
                return RedirectToPage("./Categories", new { pageNumber = -1 });
            },
                                                  async() =>
            {
                await LoadCategoriesAsync(AddCategory.PageNumber);
                return Page();
            },
                                                  async vrList =>
            {
                if (!AddCategory.Category.IsNullOrEmpty())
                {
                    var category = await _categoriesQueries.GetByName(AddCategory.Category);
                    if (category != null)
                    {
                        vrList.Add(new ModelValidationResult(nameof(AddCategory.Category),
                                                             "Категория товаров с таким именем уже есть"));
                    }
                }
            }));
        }
Beispiel #5
0
        //elly 3leh el door
        private void btnCatEdit_Click(object sender, EventArgs e)
        {
            AddCategory addCat = new AddCategory();

            addCat.FormClosed += AddCatClosed;
            addCat.ShowDialog();
        }
        public ActionResult Add(int?id = 0)
        {
            var model = new AddCategory();

            // Get category tree
            IList <CategoryNode> nodes = new List <CategoryNode>();

            CategoryHierarchy.AppendChildCategories(ref nodes, null);

            // Generate select list items
            model.SelectCategoryItems = nodes.Select(x => new SelectListItem
            {
                Text     = StringExtensions.Repeat("\xA0", x.Level * 4) + x.CategoryName,
                Value    = x.CategoryId.ToString(),
                Selected = (x.CategoryId == id)
            }).ToList();

            // Add top root category
            model.SelectCategoryItems.Insert(0, new SelectListItem
            {
                Text     = "-- Chọn loại hàng cha--",
                Value    = "0",
                Selected = (id == null || id == 0)
            });

            return(View(model));
        }
Beispiel #7
0
        private void PictureBox2_Click(object sender, EventArgs e)
        {
            AddCategory a = new AddCategory();

            a.FormClosing += (sender2, e2) => check(sender2, e2, 2);
            a.ShowDialog();
        }
        //Show a form for adding a new category.
        private void btnAddWGroup_Click(object sender, RoutedEventArgs e)
        {
            AddCategory form = new AddCategory(_proxy, ServerData.Group);

            form.ShowDialog();
            btnWordsGroupsAct_Click(null, null);
        }
        public IActionResult ViewProduct(int id)
        {
            AddCategory Product = FindProductAndCategories(id);

            System.Console.WriteLine(Product.Existing.Count);
            return(View(Product));
        }
        public IActionResult NewCategory(AddCategory category, int id)
        {
            AddCategory Product        = FindProductAndCategories(id);
            Association newAssociation = new Association(id, category.CategoryId);

            newAssociation.Product  = FindProductById(id);
            newAssociation.Category = FindCategoryById(category.CategoryId);

            if (ModelState.IsValid)
            {
                System.Console.WriteLine(id);
                if (category.CategoryId != 0)
                {
                    dbContext.Associations.Add(newAssociation);
                    dbContext.SaveChanges();
                    return(RedirectToAction("ViewProduct", Product));
                }

                return(RedirectToAction("ViewProduct", Product));
            }
            else
            {
                ModelState.AddModelError("CategoryId", "There is no category to add!");
                return(RedirectToAction("ViewProduct", Product));
            }
        }
        public AddCategory FindProductAndCategories(int id)
        {
            AddCategory AddCategory = new AddCategory();
            Product     product     = dbContext.Products
                                      .Include(prod => prod.Categories)
                                      .ThenInclude(category => category.Category)
                                      .FirstOrDefault(p => p.ProductId == id);

            List <Category> existing = dbContext.Categories
                                       .Include(cat => cat.Products)
                                       .Where(assoc => assoc.Products
                                              .Any(pro => pro.ProductId == id))
                                       .ToList();

            List <Category> available = dbContext.Categories
                                        .Include(cat => cat.Products)
                                        .Where(Category => Category.Products
                                               .All(pro => pro.ProductId != id))
                                        .ToList();

            AddCategory.Product   = product;
            AddCategory.Available = available;
            AddCategory.Existing  = existing;

            return(AddCategory);
        }
Beispiel #12
0
        public async Task <IActionResult> Put(Guid parentCategoryId, [FromBody] AddCategory command)
        {
            var Id = Guid.NewGuid();
            await _categoryService.AddSubCategory(parentCategoryId, Id, command.name);

            return(Created($"/category/{Id}", null));
        }
Beispiel #13
0
        public async Task <IActionResult> Post([FromBody] AddCategory command)
        {
            var Id = Guid.NewGuid();
            await _categoryService.CreateAsync(Id, command.name);

            return(Created($"/category/{Id}", null));
        }
Beispiel #14
0
        private void treeViewCategories_Selected(object sender, RoutedEventArgs e)
        {
            const string iconsCategoryDirectory = @"Icons\IconsCategory";

            lastSelectedTreeViewItem = selectedTreeViewItem;
            lastSelectedItemType     = selectedItemType;
            selectedTreeViewItem     = e.OriginalSource as TreeViewItem;
            if (selectedTreeViewItem.Tag is Category <FurnitureObject> )
            {
                selectedItemType = LastSelectedItemType.Category;
                Category <FurnitureObject> currentCategory = selectedTreeViewItem.Tag as Category <FurnitureObject>;
                AddCategory addCategory = new AddCategory(currentCategory.Name, currentCategory, true, false, System.IO.Path.GetFullPath(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\", iconsCategoryDirectory)));
                Grid        grid        = new Grid();
                grid.Children.Add(addCategory);
                groupBoxRightSide.Content = grid;
            }
            else
            {
                if (selectedTreeViewItem.Tag is FurnitureObject)
                {
                    selectedItemType = LastSelectedItemType.FurnitureObject;
                    FurnitureObject currentObject  = selectedTreeViewItem.Tag as FurnitureObject;
                    double          tradeAllowance = ((selectedTreeViewItem.Parent as TreeViewItem).Tag as Category <FurnitureObject>).TradeAllowance;
                    ImportObject    importObject   = new ImportObject("Object", currentObject, configuration.Materials, true, false, tradeAllowance);
                    importObject.StatusUpdated += importObject_StatusUpdated;
                    Grid grid = new Grid();
                    grid.Children.Add(importObject);
                    groupBoxRightSide.Content = grid;
                }
            }
        }
Beispiel #15
0
        private void Btn_add_Click(object sender, RoutedEventArgs e)
        {
            AddCategory user = new AddCategory(this);

            user.ShowDialog();
            user.Close();
        }
        //Show a form for adding a new category.
        private void btnAddVCategory_Click(object sender, RoutedEventArgs e)
        {
            AddCategory form = new AddCategory(_proxy, ServerData.VideoCategory);

            form.ShowDialog();
            btnVideoCategoriesAct_Click(null, null);
        }
        public ActionResult AddType(int?id, AddCategory addCategory)
        {
            var  Emailid = User.Identity.Name.ToString();
            User user1   = dbobj.Users.Where(x => x.EmailId == Emailid).FirstOrDefault();

            if (ModelState.IsValid)
            {
                NoteType noteCategory = dbobj.NoteTypes.Find(id);
                if (noteCategory != null)
                {
                    noteCategory.Name               = addCategory.name;
                    noteCategory.Description        = addCategory.Description;
                    noteCategory.ModifiedBy         = user1.ID;
                    noteCategory.Modifieddate       = DateTime.Now;
                    dbobj.Entry(noteCategory).State = EntityState.Modified;
                    dbobj.SaveChanges();
                }
                else
                {
                    NoteType note = new NoteType
                    {
                        Name        = addCategory.name,
                        Description = addCategory.Description,
                        CreatedBy   = user1.ID,
                        CreatedDate = DateTime.Now,
                        IsActive    = true,
                    };
                    dbobj.NoteTypes.Add(note);
                    dbobj.SaveChanges();
                }
            }
            return(RedirectToAction("ManageType", "ManageSystem"));
        }
Beispiel #18
0
        //[Authorize(Roles = "admin,teacher")]
        public IActionResult UpdateCategory(int id, [FromBody] AddCategory addCategory)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            Category cat = _categoryRepository.GetById(id);

            if (cat == null)
            {
                return(NotFound("Category could not found"));
            }

            cat.Name        = addCategory.Name;
            cat.Description = addCategory.Description;
            cat.Image       = addCategory.Image;
            cat.Remarks     = addCategory.Remarks;

            var catObj = _mapper.Map <Category>(addCategory);

            _categoryRepository.Update(cat, catObj);
            var result = _mapper.Map <Category, AddCategory>(cat);

            return(Ok("Category updated successfully"));
        }
        private void Button_Click10(object sender, RoutedEventArgs e)
        {
            AddCategory add = new AddCategory();

            add.Show();
            this.Close();
        }
Beispiel #20
0
 private void button4_Click(object sender, EventArgs e)
 {
     using (AddCategory ac = new AddCategory())
     {
         ac.ShowDialog();
     }
 }
        private void buttonAddCategory_Click(object sender, EventArgs e)
        {
            AddCategory add = new AddCategory();

            if (add.ShowDialog() == DialogResult.OK)
            {
            }
        }
Beispiel #22
0
        public IActionResult Add([FromBody] AddCategory category)
        {
            var mappedCategory = _mapper.Map <Category>(category);

            var response = _service.Add(mappedCategory);

            return(Ok(response));
        }
        //Show a form for editting category.
        private void btnEditWGroup_Click(object sender, RoutedEventArgs e)
        {
            int         id   = Convert.ToInt32((sender as Button).Tag);
            AddCategory form = new AddCategory(_proxy, ServerData.Group, id);

            form.ShowDialog();
            btnWordsGroupsAct_Click(null, null);
        }
        //Show a form for editting category.
        private void btnEditBCategory_Click(object sender, RoutedEventArgs e)
        {
            int         id   = Convert.ToInt32((sender as Button).Tag);
            AddCategory form = new AddCategory(_proxy, ServerData.BookCategory, id);

            form.ShowDialog();
            btnBooksCategoriesAct_Click(null, null);
        }
Beispiel #25
0
        private void addCategoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseActiveChildForms();

            AddCategory addCategory = new AddCategory();

            addCategory.MdiParent = this;
            addCategory.Show();
        }
Beispiel #26
0
        public ResultWithEntity <Category> CreateCategory(AddCategory item)
        {
            var jsonTest = Newtonsoft.Json.JsonConvert.SerializeObject(item);
            var obj      = Newtonsoft.Json.JsonConvert.DeserializeObject <Category>(jsonTest);

            var result = categoryRepository.AddOne(obj);

            return(result);
        }
Beispiel #27
0
        public ActionResult <Category> CreateCategory([FromBody] AddCategory addCategory)
        {
            var CategoryToCreate = new Category()
            {
                Description = addCategory.Description,
            };
            var CreatedCategory = dbContext.Category.Add(CategoryToCreate).Entity;

            dbContext.SaveChanges();
            return(CreatedCategory);
        }
Beispiel #28
0
        public IActionResult Save()
        {
            var b = new CategoryEntity
            {
                Name = HttpContext.Request.Form["Name"],
                Type = HttpContext.Request.Form["Type"],
            };
            var q = new AddCategory(_configuration);

            q.InsertCategory(b);
            return(RedirectToAction("Index"));
        }
Beispiel #29
0
        public ActionResult UpdateCategory(int cid)
        {
            var         category = _context.GetCategory(cid);
            AddCategory model    = new AddCategory
            {
                cId          = cid,
                CategoryName = category.Name,
                Description  = category.Description
            };

            return(View("AddCategory", model));
        }
Beispiel #30
0
        public object Post(AddCategory request)
        {
            var result = icategoryService.CreateCategory(request);

            if (result.Success)
            {
                return(null);
            }

            // STATUS CODE
            return(null);
        }
 private void AddCategory()
 {
     AddCategory f2 = new AddCategory();
     f2.Show();
 }