Ejemplo n.º 1
0
        private string _3_Essay = "随笔";       //3对应【随笔】


        /// <summary>
        /// 通过ID查询
        /// </summary>
        /// <param name="id"></param>
        /// <returns>没有数据的返回null</returns>
        public Article GetById(string id)
        {
            Article model = new Article();
            DataTable dt = _DataBase.GetOnlyById4MySql<Article>(id, model).Tables[0];
            if (dt != null && dt.Rows.Count > 0)
            {
                return FillData.FillDataToEntity(model, dt);
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Insert(Article model)
 {
     if (model != null)
     {
         string sql = FillData.AppendSqlToInsert(model);
         MySqlCommand cmd = new MySqlCommand(sql, DataBase.GetOpenConn4MySql());
         MySqlParameter[] para = FillData.AppendParas<Article>(model);
         cmd.Parameters.AddRange(para);
         int result = cmd.ExecuteNonQuery();
         if (result > 0)
         {
             return true;
         }
         return false;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 3
0
 public ActionResult Update(Article article)
 {
     if (article.Id != null)
     {
         var model = _IArticleService.GetById(article.Id);
         model.TypeId = article.TypeId;
         model.Title = article.Title;
         model.Abstract = article.Abstract;
         model.Pics = article.Pics;
         model.Content = article.Content;
         model.Tag = article.Tag;
         model.ModifyTime = DateTime.Now;
         model.ModifyUser = CUR_USER.UserName;
         var result = _IArticleService.Update(model);
         return AlertMsgAndJs("修改成功!", "history.go(-1);");
     }
     return AlertMsgAndJs("修改失败!", "history.go(-1);");
 }
Ejemplo n.º 4
0
 public ActionResult Insert(Article model)
 {
     model.Id = Guid.NewGuid().ToString("N");
     model.UserId = CUR_USER.Id;  //用户ID
     model.CreateTime = DateTime.Now;
     model.CreateUser = CUR_USER.UserName;
     model.ModifyTime = DateTime.Now;
     model.ModifyUser = CUR_USER.UserName;
     var list = _IArticleService.Insert(model);
     return AlertMsgAndJs("添加成功!", "history.go(-1);");
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 编辑文章
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(Article model)
 {
     return _DataBase.UpdateModel<Article>(model);
 }