Example #1
0
        static void Main(string[] args)
        {
            OrderService os = new OrderService();

            os.AddOrder("1", "LeoZB", "Leona", 1000);
            os.AddOrder("2", "JohnnyZB", "wotslb", 2000);

            //xml序列化
            XmlSerializer xmlser      = new XmlSerializer(typeof(List <OrderDetails>));
            String        xmlFileName = "s.xml";

            XmlSerialize(xmlser, xmlFileName, os.list);

            //Xml反序列化
            List <OrderDetails> list = XmlDeserialize(xmlser, xmlFileName) as List <OrderDetails>;

            foreach (OrderDetails od in list)
            {
                Console.WriteLine(od);
            }

            os.RemoveOrder("1", "LeoZB", "Leona", 1000);
            os.AmendOrder("1", "LeoZB", "Leona", 1000, "2", "JohnnyZB", "wotslb", 2000);
            os.InquireByCustomer("wotslb");
            os.InquireByNum("2");
            os.InquireByName("JohnnyZB");
        }
Example #2
0
        static void Main(string[] args)
        {
            OrderService os = new OrderService();

            os.AddOrder("20181111001", "LeoZB", "Leona", 1000, "13986262878");
            os.AddOrder("20181010003", "JohnnyZB", "wotslb", 2000, "18765438899");

            //xml序列化
            XmlSerializer xmlser      = new XmlSerializer(typeof(List <OrderDetails>));
            String        xmlFileName = "s.xml";

            XmlSerialize(xmlser, xmlFileName, os.list);

            //Xml反序列化
            List <OrderDetails> list = XmlDeserialize(xmlser, xmlFileName) as List <OrderDetails>;

            foreach (OrderDetails od in list)
            {
                Console.WriteLine(od);
            }

            os.RemoveOrder("20181010003", "JohnnyZB", "wotslb", 2000);
            os.AmendOrder("20181111001", "LeoZB", "Leona", 1000, "20181010003", "JohnnyZB", "wotslb", 2000);
            os.InquireByCustomer("wotslb");
            os.InquireByNum("20181111001");
            os.InquireByName("JohnnyZB");
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(@"..\..\OrderList.xml");

                XPathNavigator nav = doc.CreateNavigator();
                nav.MoveToRoot();

                XslCompiledTransform xt = new XslCompiledTransform();
                xt.Load(@"..\..\OrderList.xslt");

                FileStream    outFileStream = File.OpenWrite(@"..\..\OrderList.html");
                XmlTextWriter writer        =
                    new XmlTextWriter(outFileStream, System.Text.Encoding.UTF8);
                xt.Transform(nav, null, writer);
            }
            catch (XmlException e)
            {
                Console.WriteLine("XML Exception:" + e.ToString());
            }
            catch (XsltException e)
            {
                Console.WriteLine("XSLT Exception:" + e.ToString());
            }
        }