public void CanAddChildren()
        {
            Category art = new Category()
            {
                Name = "art", Group = "Art"
            };
            Category sports = new Category()
            {
                Name = "sports", Group = "Sports"
            };
            Category music = new Category()
            {
                Name = "music", Group = "Music"
            };

            art.Add(new Category()
            {
                Name = "painting"
            });
            art.Add(new Category()
            {
                Id = 20, Name = "photography",
            });
            sports.Add(new Category()
            {
                Name = "mma"
            });
            sports.Children[0].Add(new Category()
            {
                Name = "pride"
            });
            sports.Children[0].Add(new Category()
            {
                Name = "ufc"
            });

            // Test children count.
            Assert.AreEqual(art.Children.Count, 2);
            Assert.AreEqual(art.Count, 2);
            Assert.AreEqual(art.HasChildren, true);
            Assert.AreEqual(sports.HasChildren, true);
            Assert.AreEqual(sports.Children[0].HasChildren, true);
            Assert.AreEqual(sports.Children[0].Children[0].Name, "pride");

            // Test keys.
            Assert.AreEqual(art["painting"].Name, "painting");
            Assert.AreEqual(art[20].Name, "photography");
        }
Exemple #2
0
        public ActionResult <ReplyModel> Add([FromBody] CategoryParam msg)
        {
            ReplyModel replyModel = new ReplyModel();
            Expression <Func <Category, bool> > func = w => w.Title == msg.Title;
            CategoryDto category = CategoryDto.GetCategoryInfo(_categoryQuery, msg.Title);

            if (category == null)
            {
                Category.Add(_categoryRepository, msg.Title, msg.Description);
                bool result = ServiceProvider.GetService <IUnitOfWork>().Commit();
                if (result)
                {
                    replyModel.Status = "002";
                    replyModel.Msg    = "添加标题成功";
                }
                else
                {
                    replyModel.Msg = "添加标题失败";
                }
            }
            else
            {
                replyModel.Msg = "该分类已经存在";
            }
            return(replyModel);
        }
Exemple #3
0
        private void GenerateDemoData()
        {
            //generate Categories
            Category.Add(new ItemVm("My LEGO", "", new BitmapImage(new Uri("../Images/lego1.jpg", UriKind.Relative))));
            Category.Add(new ItemVm("My Playmobil", "", new BitmapImage(new Uri("../Images/playmobil1.jpg", UriKind.Relative))));

            //Add lego items to category
            Category[0].AddItemToCategory(new ItemVm("Helicopter", "10+", new BitmapImage(new Uri("../Images/lego4.jpg", UriKind.Relative))));
            Category[0].AddItemToCategory(new ItemVm("Digger", "12+", new BitmapImage(new Uri("../Images/lego2.jpg", UriKind.Relative))));
            Category[0].AddItemToCategory(new ItemVm("Chain Loader", "14+", new BitmapImage(new Uri("../Images/lego3.jpg", UriKind.Relative))));
            Category[0].AddItemToCategory(new ItemVm("Crawler Crane", "12+", new BitmapImage(new Uri("../Images/lego4.jpg", UriKind.Relative))));

            //Add playmobile items to category
            Category[1].AddItemToCategory(new ItemVm("Beach House", "5+", new BitmapImage(new Uri("../Images/playmobil1.jpg", UriKind.Relative))));
            Category[1].AddItemToCategory(new ItemVm("House", "8+", new BitmapImage(new Uri("../Images/playmobil2.jpg", UriKind.Relative))));
            Category[1].AddItemToCategory(new ItemVm("3 Knights", "8+", new BitmapImage(new Uri("../Images/playmobil3.jpg", UriKind.Relative))));
            Category[1].AddItemToCategory(new ItemVm("House 1", "10+", new BitmapImage(new Uri("../Images/playmobil2.jpg", UriKind.Relative))));
            Category[1].AddItemToCategory(new ItemVm("5 Knights", "8+", new BitmapImage(new Uri("../Images/playmobil3.jpg", UriKind.Relative))));
            Category[1].AddItemToCategory(new ItemVm("House 2", "12+", new BitmapImage(new Uri("../Images/playmobil2.jpg", UriKind.Relative))));
            Category[1].AddItemToCategory(new ItemVm("7 Knights", "8+", new BitmapImage(new Uri("../Images/playmobil3.jpg", UriKind.Relative))));

            //Testitem for Cart
            //Cart.Add(new ItemVm("Crawler Crane", "12+", new BitmapImage(new Uri("../Images/lego4.jpg", UriKind.Relative))));
            //Cart.Add(new ItemVm("Digger", "12+", new BitmapImage(new Uri("../Images/lego2.jpg", UriKind.Relative))));
        }
Exemple #4
0
        private void MockData()
        {
            if (!Category.Any())
            {
                Category.Add(new Category {
                    categ_name = "Roupas", dt_created = DateTime.Now
                });
                Category.Add(new Category {
                    categ_name = "Casa e Construção", dt_created = DateTime.Now
                });
                Category.Add(new Category {
                    categ_name = "Eletrodomésticos", dt_created = DateTime.Now
                });
                Category.Add(new Category {
                    categ_name = "Perfumes", dt_created = DateTime.Now
                });
                this.SaveChanges();
            }

            if (!Product.Any())
            {
                Product.Add(new Product
                {
                    id_category = 2,
                    prod_name   = "Camiseta",
                    prod_desc   = "Camiseta Masculina de algodão estilo polo.",
                    price_buy   = (decimal)48.98,
                    price_sell  = (decimal)58.98,
                    dt_created  = DateTime.Now
                });
                Product.Add(new Product
                {
                    id_category = 2,
                    prod_name   = "Vestido",
                    prod_desc   = "Vestido estilo Midi Branco de linho ",
                    price_buy   = (decimal)88.35,
                    price_sell  = (decimal)122.58,
                    dt_created  = DateTime.Now
                });
                Product.Add(new Product
                {
                    id_category = 4,
                    prod_name   = "Perfume Olympea Legend",
                    prod_desc   = "Perfume Paco Rabanne, Feminino, 50ml ",
                    price_buy   = (decimal)352.42,
                    price_sell  = (decimal)479.90,
                    dt_created  = DateTime.Now
                });
                Product.Add(new Product
                {
                    id_category = 4,
                    prod_name   = "Perfume Invictus Legend",
                    prod_desc   = "Perfume Paco Rabanne, Masculino, 50ml ",
                    price_buy   = (decimal)300.75,
                    price_sell  = (decimal)449.90,
                    dt_created  = DateTime.Now
                });
                this.SaveChanges();
            }
        }
 /// <summary>
 /// 元器件类别改变
 /// </summary>
 private void OnComponentsChanged()
 {
     if (Components == Components.Resistance)
     {
         Category.Clear();
         PowerOrWithstanding.Clear();
         Unit.Clear();
         _resistanceList.ForEach(x => Category.Add(x));
         _powerList.ForEach(x => PowerOrWithstanding.Add(x));
         _resUnitList.ForEach(x => Unit.Add(x));
         SelectCategory            = _resistanceList[0];
         SelectPowerOrWithstanding = _powerList[2];
         SelectPrecision           = _precisionList[3];
         SelectUnit = _resUnitList[0];
     }
     if (components == Components.Capacitance)
     {
         Category.Clear();
         PowerOrWithstanding.Clear();
         Unit.Clear();
         _capacitanceList.ForEach(x => Category.Add(x));
         _withstandingList.ForEach(x => PowerOrWithstanding.Add(x));
         _capUnitList.ForEach(x => Unit.Add(x));
         SelectCategory            = _resistanceList[0];
         SelectPowerOrWithstanding = _withstandingList[2];
         SelectPrecision           = _precisionList[3];
         SelectUnit = _capUnitList[0];
     }
 }
Exemple #6
0
 private void HandleTags()
 {
     if (Tags != null && Tags.Length > 0)
     {
         foreach (var v in Tags)
         {
             var tag = v.ToLower();
             if (FastCategoryMatchMap.ContainsKey(tag))
             {
                 if (FastCategoryMatchMap[tag] != null)
                 {
                     Category.Add(FastCategoryMatchMap[tag]);
                 }
             }
             else
             {
                 var match = L4D2Type.Match(v);
                 if (match != null)
                 {
                     Category.Add(match);
                 }
                 FastCategoryMatchMap.Add(v, match);
             }
         }
     }
 }
        public async Task <ICommandResult> Handle(CategoryAddCommand mesage)
        {
            try
            {
                Category category = new Category();
                category.Add(mesage);
                await _categoryService.AddToDb(category);

                ICommandResult result = new CommandResult()
                {
                    Message  = "",
                    ObjectId = category.Id,
                    Status   = CommandResult.StatusEnum.Sucess
                };
                return(result);
            }
            catch (Exception e)
            {
                e.Data["Param"] = mesage;
                ICommandResult result = new CommandResult()
                {
                    Message = e.Message,
                    Status  = CommandResult.StatusEnum.Fail
                };
                return(result);
            }
        }
Exemple #8
0
        /// <summary>
        /// Creates
        /// Creates a list of items from the EXD files
        /// </summary>
        public void FillTree()
        {
            var exdDict = ExdReader.GetEXDData();

            if (exdDict == null)
            {
                Properties.Settings.Default.FFXIV_Directory = "";
                Properties.Settings.Default.Language        = "en";
                Properties.Settings.Default.Save();
                System.Windows.Application.Current.Shutdown();
            }
            else
            {
                foreach (var cat in Info.MainCategoryList)
                {
                    TreeNode cm = new TreeNode
                    {
                        Name     = cat,
                        _subNode = exdDict[cat]
                    };
                    if (Category == null)
                    {
                        Category = new ObservableCollection <CategoryViewModel>();
                    }

                    var cvm = new CategoryViewModel(cm);
                    Category.Add(cvm);
                }

                oCategory = Category;
            }
        }
        private static Category GetTestTree()
        {
            // 1) Создаём объект класса категория, заполняем его поля name и description
            // Placeholder
            Category rootCategory = new Category();

            rootCategory.Name        = "ROOT";
            rootCategory.Description = "Root category should not be displayed to user";

            // 2) Создаем еще одну категорию (будущую подкатегорию), аналогично
            // cat1 CATEGORY
            Category cat1 = new Category();

            cat1.Name        = "Cat 1";
            cat1.Description = "Cat1 desc";

            // 3) Создаём задачу - объект класса learningTask. Заполняем его поля, создаем
            // в нем нужные методы. Каждая задача должна быть описана таким уникальным классом.
            // task1 TASK
            LearningTask task1 = new LearningTask();

            task1.Name        = "Task 1";
            task1.Description = "task1 na opisaniye";
            task1.TaskText    = "Какой-то текст задачи с двумя звёздочками";
            task1.Picture     = null;

            // Связываем задачу (объект learningTask) с категорией. В категории лежит данная задача.
            cat1.Add(task1);

            // Связываем категории. cat1 лежит В rootCategory.
            rootCategory.Add(cat1);

            return(rootCategory);
        }
        private void miProgramsAddCategory_Click(object sender, RoutedEventArgs e)
        {
            MenuItem        mi = sender as MenuItem;
            ApplicationInfo ai = mi.DataContext as ApplicationInfo;

            Common.MessageControls.Input inputControl = new Common.MessageControls.Input();
            inputControl.Initialize(DisplayString.sAppGrabber_Untitled);

            CairoMessage.ShowControl(DisplayString.sProgramsMenu_AddCategoryInfo,
                                     DisplayString.sProgramsMenu_AddCategoryTitle,
                                     CairoMessageImage.Default,
                                     inputControl,
                                     DisplayString.sInterface_OK,
                                     DisplayString.sInterface_Cancel,
                                     (bool?result) => {
                if (result == true)
                {
                    Category newCat = new Category(inputControl.Text);
                    MenuBar._appGrabber.CategoryList.Add(newCat);

                    ai.Category.Remove(ai);
                    newCat.Add(ai);

                    MenuBar._appGrabber.Save();
                }

                MenuBar.ProgramsMenu.IsSubmenuOpen = true;
            });
        }
        private ObservableCollection <Category> SelectSuitableProducts(List <String> suitableProducts, ObservableCollection <Category> categories)
        {
            foreach (Category treeViewItem in service.GetCategories())
            {
                int selectedProductsCount = 0;

                Category c = new Category(treeViewItem.Name);
                categories.Add(c);
                c.IsExpanded = true;
                foreach (var treeViewProduct in treeViewItem.Products)
                {
                    if (treeViewProduct != null)
                    {
                        if (IsSuitableItem(treeViewProduct.Name, suitableProducts))
                        {
                            //treeViewProduct.IsSelected = true;
                            c.Add(treeViewProduct);
                            selectedProductsCount++;
                        }
                        else
                        {
                            //treeViewProduct.IsSelected = false;
                            c.Remove(treeViewProduct);
                        }
                    }
                }

                if (selectedProductsCount == 0)
                {
                    categories.Remove(c);
                }
            }
            return(categories);
        }
Exemple #12
0
    private void Insert()
    {
        Data objdata = new Data(Global.ConnectionSql);

        try
        {
            Category obj = new Category();
            obj.DataObject   = objdata;
            obj.CategoryName = txtTitle.Text.Trim();
            obj.IsActived    = true;
            obj.Links        = txtTitle.Text.Trim().Replace(" ", "");
            obj.RandID       = Convert.ToInt32(txtRandID.Text);
            obj.ParentID     = Convert.ToInt32(ddlParentName.SelectedValue.ToString());
            if (this.uplImage.HasFile)
            {
                Neodynamic.WebControls.ImageDraw.ImageElement uploadedImage;
                uploadedImage = Neodynamic.WebControls.ImageDraw.ImageElement.FromBinary(this.uplImage.FileBytes);
                Neodynamic.WebControls.ImageDraw.Resize actResize = new Neodynamic.WebControls.ImageDraw.Resize();
                actResize.Width  = 150;
                actResize.Height = 150;
                uploadedImage.Actions.Add(actResize);
                Neodynamic.WebControls.ImageDraw.ImageDraw imgDraw = new Neodynamic.WebControls.ImageDraw.ImageDraw();
                imgDraw.Elements.Add(uploadedImage);
                imgDraw.ImageFormat          = Neodynamic.WebControls.ImageDraw.ImageDrawFormat.Jpeg;
                imgDraw.JpegCompressionLevel = 90;
                string filename = GetDate + "_" + uplImage.FileName;
                imgDraw.Save(Server.MapPath(Global.GetConfigKey("uploadproduct") + filename));
                obj.Images = Global.GetConfigKey("uploadproduct") + filename;
            }
            else
            {
                obj.Images = Global.GetConfigKey("uploadproduct") + "alternate.png";
            }
            int result = Convert.ToInt32(obj.Add());
            if (result > 0)// no error
            {
                Response.Write("<script>window.location='Category.aspx'</script>");
            }
            else if (result == 0)
            {
                lblMessage.Text = "Trùng dữ liệu vui lòng kiểm tra lại";
                return;
            }
            else
            {
                lblMessage.Text = "Lỗi xảy ra trong quá trình lưu dữ liệu. Liên hệ với người quản trị để khắc phục";
                return;
            }
        }
        catch (Exception ex)
        {
            Global.WriteLogError("Insert() " + ex);
            lblMessage.Text = "Lỗi xảy ra trong quá trình lưu dữ liệu. Liên hệ với người quản trị để khắc phục";
            return;
        }
        finally
        {
            objdata.DeConnect();
        }
    }
Exemple #13
0
 protected void OnButtonOkClicked(object sender, EventArgs e)
 {
     try
     {
         if (cat != null)
         {
             int    id   = GetId(cat, idEntry.Text);
             string name = GetName(nameEntry.Text);
             doc = new Document(cat, id, name, dateCalendar.Date);
             cat.Add(doc);
             this.Respond(Gtk.ResponseType.Ok);
         }
         else
         {
             throw new Exception("You must select a category");
         }
     }
     catch (Exception ex)
     {
         Gtk.MessageDialog msg = new Gtk.MessageDialog(this, Gtk.DialogFlags.Modal, Gtk.MessageType.Error, Gtk.ButtonsType.Close, true, String.Format(ex.Message.ToString()));
         if ((Gtk.ResponseType)msg.Run() == Gtk.ResponseType.Close)
         {
             msg.Destroy();
         }
     }
 }
        public IActionResult RegisterCategory(string titre)
        {
            List <string> errors = new List <string>();
            Category      c      = new Category {
                Titre = titre
            };

            if (titre == null)
            {
                errors.Add("Merci de saisir un Nom de Catégorie");
            }
            ViewBag.errors = errors;
            if (errors.Count > 0)
            {
                UserConnect(ViewBag);
                List <Category> liste = Category.GetCategories();
                return(View("listecategory", liste));
            }
            else
            {
                c.Add();
                ViewBag.Categories = true;
                ViewBag.Message    = "Catégorie ajoutée";
                UserConnect(ViewBag);
                List <Category> liste = Category.GetCategories();
                return(View("ListeCategory", liste));
            }
        }
Exemple #15
0
        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Category category = null;

            if ((_categoryTree.SelectedNode != null) && (_categoryTree.SelectedNode.Name != ""))
            {
                category = FindCategoryByName(_categoryTree.SelectedNode.Name);
                if (category == null)
                {
                    // this may be a middle node;
                    Category newCat = Category.FromFormat(_categoryTree.SelectedNode.Name);
                    this.template.Add(newCat);
//				AddCategoryToTree(newCat.Name);  // not necessary
                    category = newCat;
                }
            }
            else
            {
                category = orphan;
            }
            CategoryItem item = new CategoryItem();

            item.Value = "Pattern " + (category.Items.Count + 1);
            category.Add(item);
            _templateTable.TableModel.Rows.Add(CategoryItemToRow(item));
        }
        public void RequestDataFromServer(TaskListReadingCallback callback)
        {
            _readingCallback = callback;
            // TODO Retreiving task list from tutor's server

            // Placeholder
            Category rootCategory = new Category();

            rootCategory.Name        = "ROOT";
            rootCategory.Description = "Root category should not be displayed to user";
            Category integralsSubCat = new Category();

            // Integrals demo
            integralsSubCat.Name        = "Integrals";
            integralsSubCat.Description = "Various exercises related to integral equations";
            LearningTask taskInt1 = new LearningTask
            {
                Name     = "Task 1",
                TaskText = "Do smth"
            };

            integralsSubCat.Add(taskInt1);
            LearningTask taskInt2 = new LearningTask
            {
                Name     = "Task 2",
                TaskText = "Do smth"
            };

            integralsSubCat.Add(taskInt2);
            rootCategory.Add(integralsSubCat);

            // Quadratic equations demo
            Category qeqSubCat = new Category();

            qeqSubCat.Name        = "Quadratic equations";
            qeqSubCat.Description = "Quadratic equations resolving";
            rootCategory.Add(qeqSubCat);

            // Derivatives demo
            Category derivativesSubCat = new Category();

            derivativesSubCat.Name        = "Derivatives";
            derivativesSubCat.Description = "Some exercises about derivatives";
            rootCategory.Add(derivativesSubCat);

            _readingCallback(rootCategory);
        }
Exemple #17
0
 public async Task <IActionResult> Post([FromBody] Category category)
 {
     if (category != null)
     {
         return(Ok(await category.Add()));
     }
     return(BadRequest("Parameters are null"));
 }
        public void CanCheckProps()
        {
            Category art = new Category()
            {
                Name = "art", Group = "Art"
            };
            Category sports = new Category()
            {
                Name = "sports", Group = "Sports"
            };
            Category music = new Category()
            {
                Name = "music", Group = "Music"
            };
            Category kungfu = new Category()
            {
                Name = "Kung Fu", Group = "Martial Arts"
            };
            Category judo = new Category()
            {
                Name = "Judo", Group = "Martial Arts"
            };

            art.Add(new Category()
            {
                Name = "painting"
            });
            art.Add(new Category()
            {
                Id = 20, Name = "photography"
            });
            sports.Add(new Category()
            {
                Id = 21, Name = "Martial Arts"
            });
            sports.Children[0].Add(kungfu);
            sports.Children[0].Add(judo);

            Assert.IsTrue(art.IsRoot);
            Assert.IsTrue(art.Parent == null);
            Assert.IsTrue(kungfu.Parent != null);
            Assert.IsTrue(kungfu.ParentId == 21);
            Assert.IsFalse(kungfu.IsRoot);
            Assert.IsTrue(judo.ParentId == 21);
            Assert.IsTrue(sports[21].Name == "Martial Arts");
        }
        public ActionResult Add(Category category)
        {
            MySQLUtility connection = new MySQLUtility();

            try
            {
                connection.Connect();
            }catch (DBException e)
            {
                ViewBag.ErrorMessage = e.Message;
                return(View("_Error"));
            }


            Authenticate authenticate = new Authenticate(connection);

            User user = authenticate.GetUser();

            try
            {
                if (user.IsLogin() && user.HaveRole(NewsApplication.Models.User.ADMIN))
                {
                    //Đặt giá trị cho biến chấp nhận rỗng null => ""
                    category.link = category.link == null ? "" : category.link;
                    category.SetConnection(connection);
                    category.CheckValidForLink().CheckValidForName();
                    if (category.GetErrorsMap().Count == 0)
                    {
                        category.Add();
                        TempData["SuccessMessage"] = "Bạn đã tạo thành công danh mục " + category.name;
                        return(RedirectToAction("Index", "CategoryManage"));
                    }
                    else
                    {
                        throw new InputException(1, category.GetErrorsMap());
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = "Bạn không thể truy cập trang này";
                    return(View("_Error"));
                }
            }
            catch (DBException e)
            {
                ViewBag.ErrorMessage = e.Message;
                return(View(category));
            }catch (InputException e)
            {
                ViewBag.ErrorsMap = e.Errors;
                return(View(category));
            }
            finally
            {
                connection.Close();
            }
        }
        private void Add_Click_Function(bool is_edit)
        {
            category_name       = (tb_category_name.Text.Trim()).Replace('\'', ' ');
            pic_new_source_path = picture_event.Pic_source_file;

            lbl_category_message.Text = "";

            if (tb_category_name.Text.Trim() == "Category's Name" || tb_category_name.Text.Trim() == "")
            {
                lbl_category_message.Text      = "* Please enter your category's name";
                lbl_category_message.ForeColor = Color.Red;
                lbl_category_message.Focus();
                return;
            }
            if (pic_new_source_path == null || pic_new_source_path == pic_default_file)
            {
                lbl_category_message.Text      = "* Please choose a picture.";
                lbl_category_message.ForeColor = Color.Red;
                picture_event.Choose_Image();
                return;
            }

            if (is_edit == false)
            {
                picture_event.Copy_The_Picture(category_name);
                pic_new_source_path = picture_event.Pic_source_file;
                Category category = new Category(0, category_name, 0, popularity_score, pic_new_source_path);
                category.Add();

                tb_category_name.Text = "Category's Name";
            }
            else
            {
                if (change_image)
                {
                    if (category_to_edit.Category_cover_path_file != pic_default_file)
                    {
                        Picture_Events.Delete_The_Picture(category_to_edit.Category_cover_path_file);
                    }

                    picture_event.Copy_The_Picture(category_name);
                    pic_new_source_path = picture_event.Pic_source_file;
                    change_image        = false;
                }
                lbl_category_message.Text      = "* Category changed succesfully";
                lbl_category_message.ForeColor = Color.LightGreen;

                category_to_edit.Category_name            = category_name;
                category_to_edit.Category_cover_path_file = picture_event.Pic_source_file;

                category_to_edit.Edit();

                main_page.Main_book_list.Delete_All_List();
                Book.Show_All_Books(main_page);
            }
        }
Exemple #21
0
 public ActionResult Add(CategoryViewModel model)
 {
     if (ModelState.IsValid)
     {
         category.Add(model);
         TempData["result"] = category.Result;
         return(RedirectToAction("List"));
     }
     return(Add());
 }
 private static void GetLevel2Categories(Config config, dynamic startNode, Category parentCategory, Dictionary <string, Category> categoryList)
 {
     foreach (var node in startNode.Children)
     {
         Category.Add(config, categoryList, parentCategory.Id, node.Name.Value, node.Url.Value);
         if (config.DevMode)
         {
             return;                 //only get one
         }
     }
 }
Exemple #23
0
 public void SetCategory(string category)
 {
     if (Category.Contains(category))
     {
         Category.Remove(category);
     }
     else
     {
         Category.Add(category);
     }
     NotifyStateChanged();
 }
 private static void GetLevel1Categories(Config config, dynamic startNode, Category parentCategory, Dictionary <string, Category> categoryList)
 {
     foreach (var categoryNode in startNode.Sections)
     {
         Category category = Category.Add(config, categoryList, parentCategory.Id, categoryNode.Name.Value, "");
         GetLevel2Categories(config, categoryNode, category, categoryList);
         if (config.DevMode)
         {
             return;                 //only get one
         }
     }
 }
Exemple #25
0
        private void miProgramsChangeCategory_Click(object sender, RoutedEventArgs e)
        {
            MenuItem mi = sender as MenuItem;

            object[]        appNewCat = mi.DataContext as object[];
            ApplicationInfo ai        = appNewCat[0] as ApplicationInfo;
            Category        newCat    = appNewCat[1] as Category;

            ai.Category.Remove(ai);
            newCat.Add(ai);

            appGrabber.Save();
        }
        private static void GetLevel2Categories(Config config, HtmlNode startNode, Category parentCategory, Dictionary <string, Category> categoryList)
        {
            var categoryNodeList = startNode.SelectNodes("./ul/li/a");

            if (categoryNodeList == null)
            {
                return;
            }
            foreach (var node in categoryNodeList)
            {
                Category.Add(config, categoryList, parentCategory.Id, node.InnerHtml, node.Attributes["href"] != null ? node.Attributes["href"].Value : "");
            }
        }
        private static void GetRootCategories(Config config, HtmlNode startNode, Dictionary <string, Category> categoryList)
        {
            var categoryNodeList = startNode.SelectNodes(".//ol/ul/li[starts-with(@class, 'level0')]");

            foreach (var categoryNode in categoryNodeList)
            {
                var node = categoryNode.SelectSingleNode(".//a[contains(@class, 'level0')]");

                Console.WriteLine();
                Console.WriteLine($"***************************************************************************************");

                var category = Category.Add(config, categoryList, "", node.InnerHtml, node.Attributes["href"] != null ? node.Attributes["href"].Value : "");
                GetLevel1Categories(config, categoryNode, category, categoryList);
            }
        }
        private static void GetRootCategories(Config config, dynamic menu, Dictionary <string, Category> categoryList)
        {
            foreach (var categoryNode in menu.Children)
            {
                Console.WriteLine();
                Console.WriteLine($"***************************************************************************************");

                var category = Category.Add(config, categoryList, "", categoryNode.Name.Value, categoryNode.Url.Value);
                GetLevel1Categories(config, categoryNode, category, categoryList);
                if (config.DevMode)
                {
                    return;                 //only get one
                }
            }
        }
Exemple #29
0
        private void addbtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateBeforeAdd())
                {
                    using (Category sc = new Category(true))
                    {
                        sc.Name = nameTextBoxX.Text;

                        if (occuID == 0)
                        {
                            if (sc.Add() == 1)
                            {
                                MessageView.ShowMsg("Sucessfully Added");

                                //errorProvider1.SetError(idTxt, string.Empty);
                                //errorProvider1.SetError(nameTxt, string.Empty);

                                clear();
                            }
                        }
                        else
                        {
                            sc.ID = occuID;

                            if (MessageView.ShowQuestionMsg("Update School") == DialogResult.OK)
                            {
                                if (sc.Update() == 1)
                                {
                                    MessageView.ShowMsg("Sucessfully Updated");

                                    //errorProvider1.SetError(idTxt, string.Empty);
                                    //errorProvider1.SetError(nameTxt, string.Empty);

                                    clear();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageView.ShowErrorMsg(ex.Message);
            }
        }
Exemple #30
0
 public void PersistAllChanges(TemplateProvider template, IEnumerable <EXListViewItem> listItems)
 {
     foreach (EXListViewItem listItem in listItems)
     {
         CategoryItem catiItem = listItem.TagData as CategoryItem;
         if (catiItem != null)
         {
             catiItem.Value = listItem.SubItems[0].Text;
             catiItem.Type  = (CategoryItemType)Enum.Parse(typeof(CategoryItemType), listItem.SubItems[1].Text);
             Category category = FindCategory(listItem.SubItems[2].Text);
             if (catiItem.Parent != category)
             {
                 category.Add(catiItem);
             }
             catiItem.Type = (CategoryItemType)Enum.Parse(typeof(CategoryItemType), listItem.SubItems[1].Text);
         }
     }
 }
Exemple #31
0
        private Task CreateTask(string taskText, Category category)
        {
            Task task = backend.CreateTask (taskText);
            if (category == null)
                category = GtkApplication.Instance.Backend.DefaultCategory;
            category.Add (task);

            if (task == null) {
                Debug.WriteLine ("Error creating a new task!");
                // Show error status
                status = Catalog.GetString ("Error creating a new task");
                TaskWindow.ShowStatus (status);
            } else {
                // Show successful status
                status = Catalog.GetString ("Task created successfully");
                TaskWindow.ShowStatus (status);
                // Clear out the entry
                addTaskEntry.Text = string.Empty;
                addTaskEntry.GrabFocus ();
            }

            return task;
        }