示例#1
0
 public bool AddorUpdateCategory(uint ID, string name, string auto, uint color)
 {
     uint newID = ID;
     CCategory newCategory = null;
     //if ID>0 check if already exists
     if (newID > 0)
     {
         foreach (CCategory category in List)
         {
             if (category.ID == newID) newCategory = category;
         }
     }
     else
     {
         uint maxID = 1;
         foreach (CCategory category in List)
         {
             if (category.ID >= maxID) maxID = category.ID + 1;
         }
         newID = maxID;
     }
     if (newCategory == null)
     {
         newCategory = new CCategory();
         List.Add(newCategory);
     }
     newCategory.ID = newID;
     newCategory.Name = name;
     newCategory.Color = color;
     newCategory.AutoString = auto;
     return true;
 }
示例#2
0
 private void m_SetValueFromXmlElement(XmlElement element)
 {
     try
     {
         XmlNodeList nodes = element.ChildNodes;
         foreach (XmlElement el in nodes)
         {
             if (el.Name == "Category")
             {
                 CCategory category = new CCategory();
                 category.Name = el.Attributes["Name"].InnerText;
                 category.AutoString = el.Attributes["AutoString"].InnerText;
                 category.Color = uint.Parse(el.Attributes["Color"].InnerText);
                 category.ID = uint.Parse(el.Attributes["ID"].InnerText);
                 List.Add(category);
             }
         }
     }
     catch
     {
         CLog.Log(Constants.Log.Info, "Error loading categories list");
     }
 }