• 新闻管理cs页面


    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    namespace zj123.UI.images.News
    {
        public partial class NewsManage:zj123.BLL.AdminPage
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                this.BtShanChu.Attributes.Add("onclick","return confirm('确定要删除么?')");
                if (!Page.IsPostBack)
                {
                    DoAjax();
                    this.LoadType(this.DdlType, this.Db.GetTable("select * from NewsSort where Column_Depth=1"));
                    BindData();
                }
            }
            public void LoadType(DropDownList ddl, DataTable dt)
            {
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            ddl.Items.Add(new ListItem(GetSpace(Convert.ToInt32(dt.Rows[i]["Column_Depth"]) - 1) + Convert.ToString(dt.Rows[i]["Column_Name"]), Convert.ToString(dt.Rows[i]["Column_ID"])));
                            DataTable dtTemp = this.Db.GetTable("select * from NewsSort where Parent_ID=@Parent_ID", new System.Data.SqlClient.SqlParameter("@Parent_ID", Convert.ToString(dt.Rows[i]["Column_ID"])));
                            if (dtTemp != null)
                            {
                                if (dtTemp.Rows.Count > 0)
                                {
                                    LoadType(DdlType, dtTemp);
                                }
                            }
                        }

                    }
                }
            }
            public string GetSpace(int tempint)
            {
                string s = "";
                for (int i = 0; i < tempint; i++)
                {
                    s += "";
                }
                return s;
            }
            public void DoAjax()
            {

                string state = "0";
                string isAjax = this.GetRequest("isAjax").ToLower();

                if (isAjax == "true")
                {
                    string action = this.GetRequest("action").ToString();
                    string values = this.GetRequest("values").ToString();
                    switch (action)
                    {
                        case "tuijian":
                            state = this.Db.GetState("update News set IsCommand=case IsCommand when 1 then 0 else 1 end,CommandTime=getdate() where Gid=@Gid", new System.Data.SqlClient.SqlParameter("@Gid", values)) ? ("1") : ("0");
                            break;
                        case "zhiding":
                            state = this.Db.GetState("update News set IsTop=case IsTop when 1 then 0 else 1 end,TopTime=getdate() where Gid=@Gid", new System.Data.SqlClient.SqlParameter("@Gid", values)) ? ("1") : ("0");
                            break;
                        case "toutiao":
                            state = this.Db.GetState("update News set IsHead=case IsHead when 1 then 0 else 1 end,HeadTime=getdate() where Gid=@Gid", new System.Data.SqlClient.SqlParameter("@Gid", values)) ? ("1") : ("0");
                            break;
                        default:
                            break;
                    }
                    Response.Clear();
                    Response.Write(state);
                    Response.End();
         
            }
            }
            public void BindData()
            {
                string Key_Word = this.GetRequest("idKeyWord");
                this.TbKeyword.Text = Key_Word;
                string typeid = this.GetRequest("typeid");
                if (typeid.Length > 0)
                {
                    this.DdlType.SelectedValue = typeid;
                }
                string isCommand = this.GetRequest("isCommand");
                string isTop = this.GetRequest("isTop");
                Key_Word = Key_Word.Length > 0 ? (" and Title like '%" + Key_Word + "%'") : ("");
                isCommand = isCommand.Length > 0 ? (" and isCommand=" + isCommand) : ("");
                typeid = typeid.Length > 0 ? (" and typeid='" + typeid+"'") : ("");
                isTop = isTop.Length > 0 ? (" and isTop=" + isTop) : ("");
                this.TableName = "News";
                this.Pid = "Gid";
                this.Columns = "Gid,(select Column_Name from NewsSort where Column_id=News.Typeid) TypeName,Title,IsCommand,IsTop,AddTime,isHead";
                this.PageSize = 20;
                this.Where = string.Format(" 1=1{0}{1}{2}{3}", Key_Word, isCommand, isTop, typeid);//, C_ID);
                this.Order = "AddTime desc";
                this.gvList.DataSource = this.PageData;
                this.gvList.DataBind();
                this.Pages1.NumCount = Convert.ToInt32(this.Db.GetOne(string.Format("select count(1) from {0} where{1}", TableName, Where)));
                this.Pages1.PageSize = this.PageSize;
                this.Pages1.CurrentPage = this.CurrentPage;
            }

            protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowIndex != -1)
                {
                    DataRowView drv = e.Row.DataItem as DataRowView;
                    string isCommand = Convert.ToString(drv["IsCommand"]);
                    string isTop     = Convert.ToString(drv["IsTop"]);
                    string isHead = Convert.ToString(drv["isHead"]);               
                    //string.Format("<a href='NewsEdit.aspx?gid={0}'>修改</a>", Convert.ToString(drv["Gid"])) +
                    e.Row.Cells[0].Text = string.Format(this.CheckBoxString, Convert.ToString(drv["Gid"])) ;
                    //"string.Format(<a href='NewsEdit.aspx?gid={0}'>修改</a>", Convert.ToString(drv["Gid"]))+
                    // + "<a href=\"#\" onclick=\"new Ajax().getData('"+Request.Path.ToString()+"','isAjax=true&action=tuijian&values=" + Convert.ToString(drv["Gid"]) + "',function(obj){if(obj.responseText=='1'){alert('操作成功!');document.location=document.location;}else{alert('操作失败!请重试!');}})\">"+isCommand=="1"?("推荐"):("取消推荐")+"</a>"+
                    string editString = string.Format("<a href='NewsEdit.aspx?gid={0}'>修改</a>", Convert.ToString(drv["Gid"])) + "&nbsp;&nbsp;" + "<a  onclick=\"new Ajax().getData('" + Request.Path.ToString() + "','isAjax=true&action=tuijian&values=" + Convert.ToString(drv["Gid"]) + "',function(obj){if(obj.responseText=='1'){alert('操作成功!');document.location=document.location;}else{alert('操作失败!请重试!');}}) \" href=\"void(0)\">" + (isCommand == "1" ? ("取消推荐") : ("推荐")) + "</a>" + "&nbsp;&nbsp;" + ("<a href=\"void(0)\"  onclick=\"new Ajax().getData('" + Request.Path.ToString() + "','isAjax=true&action=zhiding&values=" + Convert.ToString(drv["Gid"]) + "',function(obj){if(obj.responseText=='1'){alert('操作成功!');document.location=document.location;}else{alert('操作失败!请重试!');}})\">" + (isTop == "1" ? ("取消置顶 ") : ("置顶")) + "</a>") + "&nbsp;&nbsp;" + ("<a href=\"void(0)\"  onclick=\"new Ajax().getData('" + Request.Path.ToString() + "','isAjax=true&action=toutiao&values=" + Convert.ToString(drv["Gid"]) + "',function(obj){if(obj.responseText=='1'){alert('操作成功!');document.location=document.location;}else{alert('操作失败!请重试!');}})\">" + (isHead == "1" ? ("取消头条 ") : ("头条")) + "</a>");
                    e.Row.Cells[4].Text = editString;
                }
            }

            protected void BtShanChu_Click(object sender, EventArgs e)
            {
                ActionDo("delete from news where Gid={0}");
            }
            public void ActionDo(string sql)
            {
                ArrayList al = this.GetSqls(sql);
                if (this.Db.GetTranState(al))
                {
                    this.ShowMessage("操作成功!", "document.location=document.location");
                }
                else
                {
                    this.ShowMessage("操作失败!", "history.go(-1)");
                }
            }

            protected void BtSearch_Click(object sender, EventArgs e)
            {
                Response.Redirect(Request.Path.ToString() + "?idKeyWord="+this.TbKeyword.Text.Trim()+"&typeid="+this.DdlType.SelectedValue.Trim());
            }
        }
    }

  • 相关阅读:
    在ubuntu下安装phpmyadmin 出现404错误
    Jquery插件收藏
    PHP 时区设置
    Jquery动态进行图片缩略
    CSS设置图片垂直居中的方法
    解决CI框架的Disallowed Key Characters错误提示
    @Component默认是单例还是多例?
    ehcache的heap、off-heap、desk浅谈
    nginx负载均衡分配策略有哪些?
    HashSet的实现原理,简单易懂
  • 原文地址:https://www.cnblogs.com/bestsaler/p/1835599.html
Copyright © 2020-2023  润新知