示例#1
0
        private bool DoAdd()
        {
            bool result = false;

            Model.news model = new Model.news();
            BLL.news   bll   = new BLL.news();

            model.title   = txtTitle.Text.Trim();
            model.is_hide = Convert.ToInt32(rblIsHide.SelectedValue);
            model.is_msg  = Convert.ToInt32(rblIsMsg.SelectedValue);
            model.img     = txtImg.Text;
            model.sort    = Convert.ToInt32(txtSort.Text);
            model.click   = Convert.ToInt32(txtClick.Text);
            if (string.IsNullOrEmpty(txtTime.Text))
            {
                model.time = DateTime.Now;
            }
            else
            {
                model.time = Convert.ToDateTime(txtTime.Text);
            }

            //内容摘要提取内容前255个字符
            if (string.IsNullOrEmpty(txtZhaiyao.Text.Trim()))
            {
                model.zhaiyao = Utils.DropHTML(txtContent.Value, 255);
            }
            else
            {
                model.zhaiyao = Utils.DropHTML(txtZhaiyao.Text, 255);
            }

            //是否将编辑器远程图片保存到本地
            if (siteConfig.fileremote == 1)
            {
                model.cont = AutoRemoteImageSave(txtContent.Value);
            }
            else
            {
                model.cont = txtContent.Value;
            }



            model.id = bll.Add(model);
            if (model.id > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加咨询内容:" + model.title); //记录日志
                result = true;
            }
            return(result);
        }
示例#2
0
 private void ShowInfo(int _id)
 {
     Model.news model = new BLL.news().GetModel(_id);
     txtTitle.Text           = model.title;
     rblIsHide.SelectedValue = model.is_hide.ToString();
     rblIsMsg.SelectedValue  = model.is_msg.ToString();
     txtImg.Text             = model.img;
     txtSort.Text            = model.sort.ToString();
     txtClick.Text           = model.click.ToString();
     txtTime.Text            = model.time.ToString("yyyy-MM-dd HH:mm:ss");
     txtZhaiyao.Text         = model.zhaiyao;
     txtContent.InnerText    = model.cont;
 }
示例#3
0
        private void get_news_list(HttpContext context)
        {
            int    page     = DTRequest.GetInt("page", 1);
            string keywords = DTRequest.GetString("keywords");

            int count    = 0;
            int pageSize = 4;
            int sum      = new BLL.news().GetCount("");

            if ((page - 1) * pageSize > sum)
            {
                //没有更多数据
                context.Response.Write("{\"status\":0,\"msg\":\"没有更多数据\"}");
                return;
            }

            DataSet   ds = new BLL.news().GetList(pageSize, page, "title like '%" + keywords + "%'", "sort,time desc", out count);
            DataTable dt = ds.Tables[0];

            dt.Columns.Add("zan", typeof(int));
            dt.Columns.Add("collect", typeof(int));
            dt.Columns.Add("view", typeof(int));
            string[] arr = new string[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                arr[i] = Convert.ToDateTime(dt.Rows[i]["time"].ToString()).ToString("yyyy-MM-dd HH:mm");
            }
            dt.Columns.Remove("time");
            dt.Columns.Add("time", typeof(string));

            foreach (DataRow dr in dt.Rows)
            {
                dr["view"]    = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=2 and type=1");
                dr["collect"] = new BLL.news_commend().GetCount("news_id=" + dr["id"].ToString());
                dr["zan"]     = new BLL.news_view().GetCount("news_id=" + dr["id"].ToString() + " and isPN=2 and type=2");
                dr["time"]    = arr[dt.Rows.IndexOf(dr)];
            }


            string strJson = DTcms.Common.JsonHelper.DataTableToJSON(ds.Tables[0]);


            context.Response.Write(strJson);
        }
示例#4
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("news_list", DTEnums.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;                                               //成功数量
            int errorCount = 0;                                               //失败数量

            BLL.news bll     = new BLL.news();
            Repeater rptList = new Repeater();

            if (this.rptList1.Visible == true)
            {
                rptList = this.rptList1;
            }
            else
            {
                rptList = this.rptList2;
            }

            //循环删除
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount++;
                    }
                    else
                    {
                        errorCount++;
                    }
                }
            }
            AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "删除资讯成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("news_list.aspx", "keywords={0}",
                                                                                        this.keywords));
        }
示例#5
0
        //收藏列表,点赞列表
        private void get_user_view_list(HttpContext context)
        {
            int       uid  = DTRequest.GetInt("uid", 0);
            int       isPN = DTRequest.GetInt("isPN", 0);
            int       type = DTRequest.GetInt("type", 0);
            DataTable dt   = new BLL.news_view().GetList(0, "type=" + type + " and isPN=" + isPN + " and user_id=" + uid, "time desc").Tables[0];

            dt.Columns.Add("title", typeof(string));
            dt.Columns.Add("cont", typeof(string));
            dt.Columns.Add("day", typeof(string));

            foreach (DataRow dr in dt.Rows)
            {
                string title, cont;
                if (isPN == 1)
                {
                    Model.product model = new BLL.product().GetModel(Convert.ToInt32(dr["news_id"]));
                    title = model.title;
                    if (model.cont.Length > 60)
                    {
                        cont = model.cont.Substring(0, 60) + "...";
                    }
                    else
                    {
                        cont = model.cont;
                    }
                }
                else
                {
                    Model.news model = new BLL.news().GetModel(Convert.ToInt32(dr["news_id"]));
                    title = model.title;
                    if (model.zhaiyao.Length > 60)
                    {
                        cont = model.zhaiyao.Substring(0, 60) + "...";
                    }
                    else
                    {
                        cont = model.zhaiyao;
                    }
                }
                dr["title"] = title;
                dr["cont"]  = cont;
                //时间隔计算
                DateTime t1 = DateTime.Now;
                DateTime t2 = Convert.ToDateTime(dr["time"]);
                TimeSpan ts = t1.Subtract(t2);
                if (ts.Days > 3)
                {
                    dr["day"] = Convert.ToDateTime(dr["time"]).ToString("yyyy-MM-dd");
                }
                else if (ts.Days > 0)
                {
                    dr["day"] = ts.Days + "天前";
                }
                else if (ts.Hours > 0)
                {
                    dr["day"] = ts.Hours + "小时前";
                }
                else if (ts.Minutes > 0)
                {
                    dr["day"] = ts.Minutes + "分钟前";
                }
                else if (ts.Seconds > 0)
                {
                    dr["day"] = ts.Seconds + "秒前";
                }
                else
                {
                    dr["day"] = "未知";
                }
            }
            context.Response.Write(JsonHelper.DataTableToJSON(dt));
        }