private static void LoadFarmTran() { var nodeList = new List <FarmTran>(); XDocument docNew = XDocument.Load(@"C:\Users\user\Downloads\XMLanalysis-master\XMLanalysis-master\FarmTransData.xml"); //Console.WriteLine(docNew.ToString()); IEnumerable <XElement> nodes = docNew.Element("DocumentElement").Elements("row"); nodeList = nodes .Select(node => { var item = new FarmTran(); item.transactionDate = getValue(node, "交易日期"); item.cropCode = getValue(node, "作物代號"); item.cropName = getValue(node, "作物名稱"); item.marketCode = getValue(node, "市場代號"); item.marketName = getValue(node, "市場名稱"); item.priceHigh = getValue(node, "上價"); item.priceMid = getValue(node, "中價"); item.priceLow = getValue(node, "下價"); item.priceAvg = getValue(node, "平均價"); item.transactionNum = getValue(node, "交易量"); return(item); }).ToList(); FarmTranTable mFarm = new FarmTranTable(); nodeList.ForEach(item => { mFarm.InsertData(item); }); Console.ReadKey(); }
static void Main(string[] args) { MGenericsDB <FarmTran> mFarm = new FarmTranTable(); /*var nodeList = mFarm.Xml_Load(); * nodeList.ForEach(item => * { * mFarm.InsertData(item); * });*/ mFarm.ShowData(mFarm.QueryData("作物名稱", "椰子")); Console.ReadKey(); }
static void Main(string[] args) { //-------------------------------------------------------------ShengYaoo MGenericsDB <FarmTran> mFarm = new FarmTranTable(); /* * var nodeList = mFarm.Xml_Load(); * nodeList.ForEach(item => * { * mFarm.InsertData(item); * });*/ mFarm.ShowData(mFarm.QueryData("作物名稱", "椰子")); var farm = new FarmTran(); farm.transactionDate = "107.4.13"; mFarm.UpdateData(1, farm); mFarm.ShowData(mFarm.QueryData("交易日期", "107.4.13")); Console.ReadKey(); Console.Clear(); mFarm.DeleteData("交易日期", "107.4.13"); mFarm.ShowData(mFarm.QueryData("交易日期", "107.4.13")); Console.ReadKey(); //-------------------------------------------------------------YuSyuan1208 MGenericsDB <Pharmacy_03> mPharmacy_03 = new PharmacyTable_03(); /*var nodeList = mPharmacy_03.Xml_Load(); * nodeList.ForEach(item => * { * PharmacyTable_03 SqlData; * SqlData = new PharmacyTable_03(); * SqlData.InsertData(item); * });*/ mPharmacy_03.ShowData(mPharmacy_03.QueryData("機構名稱", "和平藥局")); var nPharmacy_03 = new Pharmacy_03(); nPharmacy_03.機構名稱 = "機構名稱"; nPharmacy_03.機構狀態 = "機構狀態"; nPharmacy_03.地址 = "地址"; nPharmacy_03.電話 = "電話"; mPharmacy_03.UpdateData(1, nPharmacy_03); mPharmacy_03.DeleteData("機構名稱", "機構名稱"); Console.ReadKey(); //-------------------------------------------------------------JustSoGreat MGenericsDB <PharmaceuticalFactory> mPF = new PharmaTable(); var nodeList = mPF.Xml_Load(); //nodeList.ForEach(item => //{ // mPF.InsertData(item); //}); //mPF.ShowData(mPF.QueryData("類別", "西藥製劑廠")); var pf = new PharmaceuticalFactory(); pf.type = "test藥廠"; pf.name = "高應藥廠"; mPF.UpdateData(227, pf); Console.WriteLine("UPDATE ID:227,類別:test藥廠,名稱:高應藥廠"); mPF.DeleteData("ID", "1"); Console.WriteLine("Delete ID:1"); Console.ReadKey(); //-------------------------------------------------------------husano896 MGenericsDB <桃園公共自行車即時服務資料> mPark = new ParkingDB(); var nodeList2 = mPark.Xml_Load(); var testitem = new 桃園公共自行車即時服務資料(); testitem.parkName = @"測試停車場"; mPark.InsertData(testitem); Console.ReadKey(); }