Exemplo n.º 1
0
        private void DateTimeNode()
        {
            //判断是否存在同名的节点
            SameDateTime();
            //判断是否是根节点
            if (_xmlWriter.CurrentNode.Name != ROOTNODE)
            {
                _xmlWriter.Save(xmlpath);
                _xmlReader.Load(xmlpath);
                var nodelList = _xmlReader.GetXmlNodeList(@"/Weekly");
                if (nodelList.Count <= 0)
                {
                    return;
                }
                _xmlWriter.MoveToNode(@"/Weekly", nodelList.Count - 1);
            }
            _xmlWriter.AddSubXmlNode(DATETIME);
            _xmlWriter.AddXmlAtrribute(CURRENTDATE, SelectedDate.ToShortDateString());

            foreach (DailyContent dc in Daily)
            {
                if (_xmlWriter.CurrentNode.Name != DATETIME)
                {
                    _xmlWriter.AddSibXmlNode(CONTENT, dc.Content);
                }
                else
                {
                    _xmlWriter.AddSubXmlNode(CONTENT, dc.Content);
                }
                _xmlWriter.AddXmlAtrribute(NUMBER, dc.Number.ToString());
                _xmlWriter.AddXmlAtrribute(COSTTIME, dc.Hour.ToString());
                _xmlWriter.AddXmlAtrribute(CATEGORY, dc.Category.ToString());
                _xmlWriter.AddXmlAtrribute(STATE, dc.State ? "是" : "否");
            }
        }