Beispiel #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var title = txtTitle.Text;
            var keyword = txtKeyword.Text;
            var content = txtContent.Text;
            var type = txtType.SelectedValue;
            if (title == "" || keyword == "" || content == "" || txtType.SelectedIndex < 0)
            {
                MessageBox.Show("请填写完整,全部为必填项");
                return;
            }

            var model = new NoteModel()
            {
                Title = title,
                Keywords = keyword,
                Type = int.Parse(type.ToString()),
                Content = content,
                CreateTime = DateTime.Now
            };
            if (NoteDao.Add(model))
            {
                MessageBox.Show("添加成功");
                this.DialogResult = DialogResult.OK;
                this.Close();
            }

        }
Beispiel #2
0
        public AddToReadForm(NoteModel model)
        {
            InitializeComponent();
            initTypes();

            //show detail
            this.Text = "查看内容";
            btnAdd.Visible = false;
            txtTitle.Text = model.Title;
            txtContent.Text = model.Content;
            txtKeyword.Text = model.Keywords;
            txtType.SelectedValue = model.Type;
        }
Beispiel #3
0
 public static bool Add(NoteModel model) {
     try
     {
         var xPath = "/Notes";
         var nodeName = "Note";
         var innerXml = string.Format(@"<type>{0}</type>
                                                 <title> {1}</title>
                                                 <keyword>{2}</keyword>
                                                 <content><![CDATA[{3}]]></content>
                                                 <createtime>{4}</createtime>",
                                              model.Type,model.Title,model.Keywords,model.Content,model.CreateTime.ToString(timeTemp));
         var attrName = "isread";
         var attrValue = "0";
         return XMLHelper.CreateXmlNodeByXPath(treePath, xPath, nodeName, innerXml, attrName, attrValue);
     }
     catch (Exception ex)
     {
         return false;
     }
 } 
Beispiel #4
0
 public NoteForm(NoteModel model)
 {
     InitializeComponent();
     init();
     ShowWeb(model.Content);
 }