public static Com.DataPack.DataRsp <string> udel(string id, string stat)
 {
     Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
     if (Com.Session.userid == null)
     {
         rsp.code = "expire";
         rsp.msg  = "页面已经过期,请重新登录";
     }
     else
     {
         try
         {
             bool rel = false;
             SchSystem.BLL.WebSchNews schnewsbll = new SchSystem.BLL.WebSchNews();
             if (stat == "1" || stat == "2" || stat == "0")
             {
                 rel = schnewsbll.Update(int.Parse(id), int.Parse(stat));//软删除
             }
             else
             {
                 if (stat == "5")
                 {
                     stat = "1";
                 }
                 else
                 {
                     stat = "0";
                 }
                 rel = schnewsbll.UpdateIsTop(int.Parse(id), int.Parse(stat));//软删除
             }
             if (!rel)
             {
                 rsp.code = "error";
                 rsp.msg  = "操作失败";
             }
             else
             {
                 rsp.code = "success";
                 rsp.msg  = "操作成功";
             }
         }
         catch (Exception ex)
         {
             rsp.code = "error";
             rsp.msg  = ex.Message;
         }
     }
     return(rsp);
 }
        public static Com.DataPack.DataRsp <string> newsaddsave(string arr)
        {
            SchSystem.Model.WebSchNews    schnewsmodel = new SchSystem.Model.WebSchNews();
            SchSystem.BLL.WebSchNews      schnewsbll   = new SchSystem.BLL.WebSchNews();
            Com.DataPack.DataRsp <string> rsp          = new Com.DataPack.DataRsp <string>();
            if (Com.Session.userid == null)
            {
                rsp.code = "expire";
                rsp.msg  = "页面已经过期,请重新登录";
            }
            else
            {
                try
                {
                    schnews newsresult = JsonConvert.DeserializeObject <schnews>(arr);
                    if (newsresult.range == "0" && newsresult.gradeid == "")
                    {
                        rsp.code = "ExcepError";
                        rsp.msg  = "年级不允许为空";
                        return(rsp);
                    }
                    if (newsresult.range == "0" && newsresult.grdclassid == "")
                    {
                        rsp.code = "ExcepError";
                        rsp.msg  = "班级不允许为空";
                        return(rsp);
                    }
                    if (newsresult.range == "1" && newsresult.gradeid == "")
                    {
                        rsp.code = "ExcepError";
                        rsp.msg  = "年级不允许为空";
                        return(rsp);
                    }
                    schnewsmodel.NewsId = newsresult.newsid;
                    schnewsmodel.Topic  = newsresult.title;             //標題
                    schnewsmodel.ChnId  = int.Parse(newsresult.column); //欄目
                    schnewsmodel.Lv     = int.Parse(newsresult.range);  //範圍
                    if (!string.IsNullOrEmpty(newsresult.gradeid))      //年級ID
                    {
                        schnewsmodel.GradeId = int.Parse(newsresult.gradeid);
                    }
                    else
                    {
                        schnewsmodel.GradeId = 0;
                    }
                    if (!string.IsNullOrEmpty(newsresult.grdclassid))//班級ID
                    {
                        schnewsmodel.ClassId = int.Parse(newsresult.grdclassid);
                    }
                    else
                    {
                        schnewsmodel.ClassId = 0;
                    }

                    StringBuilder sbContent = new StringBuilder();
                    string        contents  = newsresult.content;
                    if (!string.IsNullOrEmpty(contents))
                    {
                        string[] contentarr  = contents.Split('|');
                        int      contentslen = contentarr.Length;
                        for (int i = 0; i < contentslen; i++)
                        {
                            string[] contarr = contentarr[i].Split(',');
                            sbContent.Append("<section><p class=\"paragraph\">" + contarr[0] + "</p><p class=\"picture\"><img src=\"" + contarr[1] + "\" alt=\"\" /></p></section>");
                        }
                        schnewsmodel.Content = sbContent.ToString();//內容
                    }

                    if (newsresult.encs.Count > 0)//附件
                    {
                        schnewsmodel.IsEnc  = 1;
                        schnewsmodel.Imgurl = newsresult.encs[0].imgurl;
                    }

                    if (newsresult.isreference == "True")//是否引用
                    {
                        schnewsmodel.IsQuo  = 1;
                        schnewsmodel.QuoUrl = newsresult.textreference;//引用地址
                    }
                    else
                    {
                        schnewsmodel.IsQuo = 0;
                    }
                    if (newsresult.isreply == "True")//是否回復
                    {
                        schnewsmodel.IsReply = 1;
                    }
                    else
                    {
                        schnewsmodel.IsReply = 0;
                    }
                    schnewsmodel.SchId   = int.Parse(SchId);
                    schnewsmodel.RecTime = DateTime.Now;
                    schnewsmodel.RecIP   = Public.GetLocalIP().RspData;
                    schnewsmodel.Stat    = 1;
                    schnewsmodel.ChkTime = DateTime.Now;

                    bool resid = schnewsbll.Update(schnewsmodel);
                    SchSystem.Model.WebSchNewsEnc schnewencModel = new SchSystem.Model.WebSchNewsEnc();
                    SchSystem.BLL.WebSchNewsEnc   schnewencBll   = new SchSystem.BLL.WebSchNewsEnc();
                    bool delNewsEnc = schnewencBll.DeleteNewsEnc(schnewsmodel.NewsId);
                    if (resid)
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add("NewsId");
                        dt.Columns.Add("OldName");
                        dt.Columns.Add("NewName");
                        dt.Columns.Add("SaveUrl");
                        dt.Columns.Add("Clicked");
                        dt.Columns.Add("RecTime");
                        dt.Columns.Add("RecIP");
                        dt.Columns.Add("FileSize");
                        dt.Columns.Add("ImgUrl");
                        int encCount = newsresult.encs.Count;
                        for (int i = 0; i < encCount; i++)
                        {
                            DataRow dr = dt.NewRow();
                            dr["NewsId"]   = newsresult.newsid;
                            dr["OldName"]  = newsresult.encs[i].oldname;
                            dr["NewName"]  = newsresult.encs[i].newname;
                            dr["SaveUrl"]  = newsresult.encs[i].saveurl;
                            dr["Clicked"]  = 1;
                            dr["RecTime"]  = DateTime.Now;
                            dr["RecIP"]    = Public.GetLocalIP().RspData;
                            dr["FileSize"] = int.Parse(newsresult.encs[i].filesize);
                            dr["ImgUrl"]   = newsresult.encs[i].imgurl;
                            dt.Rows.Add(dr);
                        }
                        rsp.code = "success";
                        rsp.msg  = schnewencBll.ExecuteSqlBulkCopy(dt, "WebSchNewsEnc");//添加附件
                    }
                }
                catch (Exception ex)
                {
                    rsp.code = "ExcepError";
                    rsp.msg  = ex.Message;
                }
            }
            return(rsp);
        }