예제 #1
0
        public AddToDoForm(ToDoModel model)
        {
            InitializeComponent();
            init();
            //show detial
            txtContent.Text = model.Content;
            dateTimePicker.Text=model.Deadline.ToString("yyyy-MM-dd");
            txtTime.Text = model.Deadline.ToString("HH:mm");
            this.Text = "查看内容";
            btnSave.Visible = false;

        }
예제 #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if( dateTimePicker.Text=="" || txtContent.Text==""){
         MessageBox.Show("请输入时间和内容");
         return;
     }
     var model  =new ToDoModel() { 
         Content=txtContent.Text,
         Deadline =DateTime.Parse(dateTimePicker.Value.ToString("yyyy-MM-dd ")+txtTime.Text+":00"),
     };
     if (TodoDao.Add(model))
     {
       MessageBox.Show("添加成功");
       this.DialogResult = DialogResult.OK;
       this.Close();
   }  
 }
예제 #3
0
 /// <summary>
 /// 添加待办
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static bool Add(ToDoModel model) {
     try
     {
         var xPath ="/Todos" ;
         var nodeName = "Todo";
         var innerXml = string.Format(@"<deadline>{0}</deadline>" +
                                  "<content><![CDATA[{1}]]> </content>",
                                  model.Deadline.ToString(timeTemp) ,model.Content);
         var attrName ="isdo";
         var attrValue="0";
        return XMLHelper.CreateXmlNodeByXPath(treePath,xPath,nodeName,innerXml,attrName,attrValue);
     }
     catch (Exception ex) {
         return false;
     }
 }