Ejemplo n.º 1
0
        private void LoadXml()
        {
            //DTimeTable demo = new DTimeTable();
            //DTimeTableItem item = new DTimeTableItem();
            //item.Name = "20190315";
            //DTimeTableColumn d1 = new DTimeTableColumn("work", "textBoxS1", 4);
            //item.Columns.Add(d1);
            //DTimeTableColumn d2 = new DTimeTableColumn("work", "textBoxS2", 4);
            //item.Columns.Add(d2);
            //DTimeTableColumn d3 = new DTimeTableColumn("work", "textBoxS3", 4);
            //item.Columns.Add(d3);
            //DTimeTableColumn d4 = new DTimeTableColumn("work", "textBoxS4", 4);
            //item.Columns.Add(d4);
            //DTimeTableColumn d11 = new DTimeTableColumn("business", "textBoxD11", 1);
            //item.Columns.Add(d11);
            //DTimeTableColumn d12 = new DTimeTableColumn("porject", "textBoxD12", 1);
            //item.Columns.Add(d12);
            //demo.Items.Add(item);
            //Save(demo);

            try
            {
                FileStream fs = new FileStream(xmlPath, FileMode.Open, FileAccess.Read);
                TimeTable = (DTimeTable)XmlSerializer.Deserialize(fs);
                fs.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Load xml error : " + ex.ToString());
            }
        }
Ejemplo n.º 2
0
        public void Save(DTimeTable oData)
        {
            FileStream fs = new FileStream(xmlPath, FileMode.Truncate, FileAccess.ReadWrite);

            XmlSerializer.Serialize(fs, oData);
            fs.Close();
        }