Exemple #1
0
 /// <summary>
 /// 保存一个book信息到book.xml文件
 /// </summary>
 /// <param name="book"></param>
 /// <param name="node"></param>
 public static void SaveBookInfo(Book book,TreeNode node)
 {
     string fileName = CommonUtil.GetRelativeAppDir(node.Parent.FullPath + Constants.FILENAME);
     try
     {
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(fileName);
         XmlNode selectNode = xmlDoc.SelectSingleNode("//book[name=\"" + node.Text + "\"]");
         if (selectNode != null)
         {
             selectNode.RemoveAll();
             XmlElement path = xmlDoc.CreateElement("path");
             path.InnerText = node.FullPath;
             XmlElement nodeName = xmlDoc.CreateElement("name");
             nodeName.InnerText = node.Text;
             XmlElement realpath = xmlDoc.CreateElement("realpath");
             realpath.InnerText = node.Tag.ToString();
             XmlElement author = xmlDoc.CreateElement("author");
             author.InnerText = book.Author;
             XmlElement bookDate = xmlDoc.CreateElement("date");
             bookDate.InnerText = book.Date;
             XmlElement description = xmlDoc.CreateElement("description");
             description.InnerText = book.Description;
             selectNode.AppendChild(path);
             selectNode.AppendChild(nodeName);
             selectNode.AppendChild(realpath);
             selectNode.AppendChild(author);
             selectNode.AppendChild(bookDate);
             selectNode.AppendChild(description);
         }
         xmlDoc.Save(fileName);
     }
     catch (Exception e)
     {
         errLog.WriteError(e);
         MessageBox.Show(Constants.UNKNOWERROR,
              Constants.ERRORTIP, MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Exemple #2
0
 public NodeBookMap(TreeNode node,Book book)
 {
     this.Node = node;
     this.NodeBook = book;
 }
Exemple #3
0
 private Book GetBook()
 {
     Book book = new Book();
        book.Author = this.txtAuthor.Text;
        book.Date = this.dtpPressDate.Text;
        book.Description = this.txtDescription.Text;
        return book;
 }
Exemple #4
0
 private void LoadBookInfo(TreeNode selectNode)
 {
     string fileName = CommonUtil.GetRelativeAppDir(selectNode.Parent.FullPath + Constants.FILENAME);
        try
        {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(fileName);
        XmlNode node = xmlDoc.SelectSingleNode("//book[name=\"" + selectNode.Text + "\"]");
        if (node != null)
        {
            Book book = new Book(node);
            UpdateBookInfoPnl(book);
        }
        }
        catch (Exception e)
        {
        errLog.WriteError(e);
        MessageBox.Show(Constants.UNKNOWERROR,
            Constants.ERRORTIP, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
 }
Exemple #5
0
 private void UpdateBookInfoPnl(Book book)
 {
     this.txtBookName.Text = book.Name;
        this.txtAuthor.Text = book.Author;
        this.txtDescription.Text = book.Description;
        this.dtpPressDate.Value = book.Date == "" ? DateTime.Now : DateTime.Parse(book.Date);
 }