コード例 #1
0
ファイル: Form1.cs プロジェクト: GhostA08/MooglenomicsV2
        private void Thread_Load_Categories()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load("ItemCategories.xml");
            foreach (XmlNode xmlNode1 in xmlDoc.GetElementsByTagName("Items"))
            {
                foreach (XmlNode xmlNode2 in xmlNode1.ChildNodes)
                {

                    int catID = Convert.ToInt32(xmlNode2.Attributes["id"].Value);
                    string catName = xmlNode2.Attributes["name"].Value.ToString().Trim();

                    statusStrip1.Invoke(new UpdateUI(UpdateUIStatusText), "Loading Categories in " + catName);
                    ItemCategory ic = db.ItemCategories.SingleOrDefault(p => p.ItemCategoryID == catID);
                    if (ic == null)
                    {
                        ic = new ItemCategory();
                        ic.ItemCategoryID = catID;
                        ic.CategoryName = catName;
                        db.ItemCategories.InsertOnSubmit(ic);
                    }
                    else if (!ic.CategoryName.Equals(catName))
                    {
                        ic.CategoryName = catName;
                    }
                    foreach (XmlNode xmlNode3 in xmlNode2.ChildNodes)
                    {
                        int subId = Convert.ToInt32(xmlNode3.Attributes["id"].Value);
                        string subName = xmlNode3.InnerText.Trim();
                        ItemSubCategory isc = db.ItemSubCategories.SingleOrDefault(p => p.ItemSubCat_ID == subId);
                        if (isc == null)
                        {
                            isc = new ItemSubCategory();
                            isc.ItemSubCat_ID = subId;
                            isc.Name = subName;
                            isc.ItemCategory = ic;
                            db.ItemSubCategories.InsertOnSubmit(isc);
                        }
                        else if (!isc.Name.Equals(subName))
                        {
                            isc.Name = subName;
                        }
                    }
                }
            }
            db.SubmitChanges();
            statusStrip1.Invoke(new UpdateUI(UpdateUIStatusText), "Categories Loaded");
            statusStrip1.Invoke(new UpdateUIFinish(UpdateUIFinished));
        }
コード例 #2
0
 partial void UpdateItemCategory(ItemCategory instance);
コード例 #3
0
 partial void DeleteItemCategory(ItemCategory instance);
コード例 #4
0
 partial void InsertItemCategory(ItemCategory instance);