Example #1
0
 //编辑事件
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         if (Label2.Text.Trim() == "")
         {
             Response.Write("<script>alert('照片不能为空!')</script>");
         }
         else
         {
             NT_Models.Action action = new NT_Models.Action();
             action.Act_Title   = txtTitle.Text.Trim();
             action.Act_Img     = Label2.Text;
             action.Act_Content = CKEditorControl1.Text.Trim();
             action.Act_Time    = DateTime.Now;
             int result = ActionServer.insert(action);
             if (result >= 1)
             {
                 Response.Write("<script>alert('发布成功!')</script>");
                 Label2.Text = "Img\\ActionImg\\";
             }
         }
     }
     catch (Exception ex)
     {
         Response.Write("<script>alert('上传失败');</script> 原因是:" + ex);
     }
 }
        //后台增加
        public int insert(NT_Models.Action action)
        {
            string sql = "insert into Action values(@Act_Title,@Act_Content,@Act_Img,@Act_Time)";

            SqlParameter[] sp = new SqlParameter[] {
                new SqlParameter("@Act_Title", action.Act_Title),
                new SqlParameter("@Act_Content", action.Act_Content),
                new SqlParameter("@Act_Img", action.Act_Img),
                new SqlParameter("@Act_Time", action.Act_Time)
            };
            return(DBHelper.GetExcuteNonQuery(sql, sp));
        }
 //后台增加
 public static int insert(NT_Models.Action action)
 {
     return(iaction.insert(action));
 }