protected void Page_Load(object sender, EventArgs e)
        {
            SchId = Com.Session.schid;
            string newsid = Request.Params["newsid"].ToString();

            SchSystem.BLL.WebSchNews   SchNewsBll = new SchSystem.BLL.WebSchNews();
            SchSystem.Model.WebSchNews model      = SchNewsBll.GetModel(int.Parse(newsid));
            if (model != null && model.NewsId > 0)
            {
                newsmodel = Newtonsoft.Json.JsonConvert.SerializeObject(model);
                chndrp    = Com.Public.GetDrp("chn", Com.Session.schid, "1", false, "", model.ChnId.ToString());
                string selt = "";
                //範圍
                NewsCope = Public.NewsCope(model.Lv.ToString(), ref selt);
                string selg = "";
                string selc = "";
                if (selt == "1")//第一个选中的是年级类型,则获取能发的年级
                {
                    //年级
                    NewsCopeDrp = Public.NewsCopeDrp("", 1, selt, model.GradeId.ToString(), ref selg);
                }
                else if (selt == "0")//选中的是班级
                {
                    //年级
                    NewsCopeDrp = Public.NewsCopeDrp("", 1, selt, model.GradeId.ToString(), ref selg);
                    //班级
                    NewsCopeDrpClass = Public.NewsCopeDrp(selg, 0, selt, model.ClassId.ToString(), ref selc);
                }
            }
        }
示例#2
0
        public static Com.DataPack.DataRsp <string> udel(string id)
        {
            Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
            if (Com.Session.userid == null)
            {
                rsp.code = "expire";
                rsp.msg  = "页面已经过期,请重新登录";
            }
            else
            {
                try
                {
                    //看是否已有新闻关联,需要补


                    SchSystem.BLL.WebSchChn   bll   = new SchSystem.BLL.WebSchChn();
                    SchSystem.Model.WebSchChn model = new SchSystem.Model.WebSchChn();
                    model.ChnId = int.Parse(id);
                    model.Stat  = 2;
                    //删除时判断是否有子栏目
                    if (!bll.Exists(int.Parse(id)))
                    {
                        SchSystem.BLL.WebSchNews bllnew = new SchSystem.BLL.WebSchNews();
                        if (!bllnew.ExistsChn(int.Parse(id)))
                        {
                            if (bll.UpdateStat(model))
                            {
                                rsp.code = "success";
                                rsp.msg  = "操作成功";
                            }
                            else
                            {
                                rsp.code = "error";
                                rsp.msg  = "操作失败";
                            }
                        }
                        else
                        {
                            rsp.code = "error";
                            rsp.msg  = "该栏目下还有文章,请删除文章后再删除该栏目!";
                        }
                    }
                    else
                    {
                        rsp.code = "error";
                        rsp.msg  = "请先删除子栏目!";
                    }
                }
                catch (Exception ex)
                {
                    rsp.code = "error";
                    rsp.msg  = ex.Message;
                }
            }
            return(rsp);
        }
 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);
 }
示例#4
0
        public static Com.DataPack.DataRsp <string> page(string PageIndex, string PageSize, string txtname, string ustat, string txtcode)
        {
            Com.DataPack.DataRsp <string> rsp = new Com.DataPack.DataRsp <string>();
            if (Com.Session.userid == null)
            {
                rsp.code = "expire";
                rsp.msg  = "页面已经过期,请重新登录";
            }
            else
            {
                try
                {
                    //Stat:0废弃,1正常,2被删除,正常界面不显示删除,超管界面可以考虑
                    string strwhere = "Stat<2 and SchId='" + Com.Session.schid + "' ";

                    if (!string.IsNullOrEmpty(txtname))
                    {
                        strwhere += " and Topic like '%" + Com.Public.SqlEncStr(txtname) + "%'";
                    }
                    if (!string.IsNullOrEmpty(ustat))
                    {
                        strwhere += " and Stat='" + Com.Public.SqlEncStr(ustat) + "'";
                    }
                    Com.Public.PageModelResp pages = new Com.Public.PageModelResp();
                    pages.PageIndex = int.Parse(PageIndex);
                    pages.PageSize  = int.Parse(PageSize);
                    int rowc = 0;
                    int pc   = 0;
                    SchSystem.BLL.WebSchNews userbll = new SchSystem.BLL.WebSchNews();
                    string    dbcols = "ChnId,Topic,RecTime";
                    DataTable dt     = userbll.GetListCols(dbcols, strwhere, "RecTime", "DESC", pages.PageIndex, pages.PageSize, ref rowc, ref pc).Tables[0];
                    pages.PageCount = pc;
                    pages.RowCount  = rowc;
                    if (dt.Rows.Count > 0)
                    {
                        pages.list = dt;
                    }
                    rsp.data = Newtonsoft.Json.JsonConvert.SerializeObject(pages).Replace("\n\r", "");
                }
                catch (Exception ex)
                {
                    rsp.code = "error";
                    rsp.msg  = ex.Message;
                }
            }
            return(rsp);
        }
示例#5
0
        public static Com.DataPack.DataRsp <string> newsaddsave(List <string> arr)
        {
            SchSystem.Model.WebSchNews    shcnewsmodel = 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
                {
                    foreach (string str in arr)
                    {
                        string[] strarr = str.Split('#');
                        if (strarr[0] == "title")
                        {
                            shcnewsmodel.Topic = strarr[1];
                        }
                        if (strarr[0] == "column")
                        {
                            shcnewsmodel.ChnId = int.Parse(strarr[1]);
                        }
                        if (strarr[0] == "range")
                        {
                            shcnewsmodel.Lv = int.Parse(strarr[1]);
                        }
                        if (strarr[0] == "grdclass")
                        {
                            shcnewsmodel.LvId = int.Parse(strarr[1]);
                        }
                        if (strarr[0] == "content")
                        {
                            shcnewsmodel.Content = strarr[1];
                        }
                        //if (strarr[0] == "annex") { shcnewsmodel.Topic = strarr[1]; }
                    }

                    shcnewsmodel.SchId   = SchId;
                    shcnewsmodel.RecTime = DateTime.Now;
                    shcnewsmodel.RecIP   = GetLocalIP().data;
                    shcnewsmodel.Stat    = 1;
                    shcnewsmodel.Clicked = 1;
                    shcnewsmodel.IsQuo   = 1;
                    shcnewsmodel.IsReply = 1;
                    shcnewsmodel.IsTop   = 1;
                    shcnewsmodel.IsEnc   = 1;
                    shcnewsmodel.ChkTime = DateTime.Now;
                    //int res = schnewsbll.Add(shcnewsmodel);
                    //if (res > 0)
                    //{
                    //    rsp.code = "success";
                    //    rsp.msg = "操作成功";
                    //}
                }
                catch (Exception ex)
                {
                    rsp.code = "ExcepError";
                    rsp.msg  = ex.Message;
                }
            }
            return(rsp);
        }
示例#6
0
        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);
                    }
                    string sss = newsresult.title;
                    schnewsmodel.Topic = newsresult.title;                                                                 //標題
                    schnewsmodel.ChnId = int.Parse(newsresult.column);                                                     //欄目
                    schnewsmodel.Lv    = int.Parse(newsresult.range);                                                      //範圍
                    if ((newsresult.range == "1" || newsresult.range == "0") && !string.IsNullOrEmpty(newsresult.gradeid)) //年級ID
                    {
                        schnewsmodel.GradeId = int.Parse(newsresult.gradeid);
                    }
                    if (newsresult.range == "0" && !string.IsNullOrEmpty(newsresult.grdclassid))//班級ID
                    {
                        schnewsmodel.ClassId = int.Parse(newsresult.grdclassid);
                    }
                    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.Clicked = 0;
                    schnewsmodel.ChkTime = DateTime.Now;

                    int resid = schnewsbll.Add(schnewsmodel);//添加新闻
                    if (resid > 0)
                    {
                        SchSystem.Model.WebSchNewsEnc schnewencModel = new SchSystem.Model.WebSchNewsEnc();
                        SchSystem.BLL.WebSchNewsEnc   schnewencBll   = new SchSystem.BLL.WebSchNewsEnc();
                        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"]   = resid;
                            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);
        }