public partial class Admin_Article_List : Util
{
public int pcount; //总条数
public int page; //当前页
public int pagesize = 20; //设置每页显示的大小
public readonly int kindId = (int)ChannelPage.Channel.Article; //类别种类
public int pageall;//总页数
public int classId;
public string keyword = "";
public string property = "";
public string ChannelKeyword = "";
dal_Article dalArticle = new dal_Article();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
databind();
}
}
public void databind()
{
if (!int.TryParse(Request.Params["classId"] as string, out this.classId))
{
this.classId = 0;
}
if (!string.IsNullOrEmpty(Request.Params["keyword"]))
{
this.keyword = Request.Params["keyword"].Trim();
}
if (!string.IsNullOrEmpty(Request.Params["property"]))
{
this.property = Request.Params["property"].Trim();
}
if (!int.TryParse(Request.Params["page"] as string, out this.page))
{
this.page = 0;
}
if (!string.IsNullOrEmpty(Request.QueryString["ChannelKeyword"]))
{
ChannelKeyword = Request.QueryString["ChannelKeyword"];
}
string gjz = Keyword.Text;
string orderby = "AddTime desc";
string strWhere = " (Title like '%" + gjz + "%') and Id>0" + CombSqlTxt(this.kindId, this.classId, this.keyword, this.property);
Util.DropListDataBind(0, "请选择类别", (int)ChannelPage.Channel.Article, ddlClassId);
dal_Article.GetPageList(this.pagesize, this.page, strWhere, orderby, rptList);
pcount = dal_Article.GetCount(strWhere);
}
//droplist类别选择
protected void ddlClassId_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Redirect("List.aspx?classId=" + ddlClassId.SelectedValue);
}
//属性筛选
protected void ddlProperty_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Redirect("List.aspx?" + CombUrlTxt(this.classId, this.keyword, this.ddlProperty.SelectedValue) + "page=0");
}
//属性设置
protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
int id = Convert.ToInt32(((Label)e.Item.FindControl("lb_id")).Text);
//int id = Convert.ToInt32(e.CommandArgument);
if (e.CommandName.ToLower() == "del")
{
if (dal_Article.Delete(id))
{
WebMessageBox.Show(this, "删除成功!");
}
}
model_Article model = dal_Article.GetModel(id);
switch (e.CommandName.ToLower())
{
case "ibtnmsg":
if (model.IsMsg == 1)
dal_Article.UpdateField(id, "IsMsg=0");
else
dal_Article.UpdateField(id, "IsMsg=1");
break;
case "ibtntop":
if (model.IsTop == 1)
dal_Article.UpdateField(id, "IsTop=0");
else
dal_Article.UpdateField(id, "IsTop=1");
break;
case "ibtnred":
if (model.IsRed == 1)
dal_Article.UpdateField(id, "IsRed=0");
else
dal_Article.UpdateField(id, "IsRed=1");
break;
case "ibtnhot":
if (model.IsHot == 1)
dal_Article.UpdateField(id, "IsHot=0");
else
dal_Article.UpdateField(id, "IsHot=1");
break;
case "ibtnslide":
if (model.IsSlide == 1)
dal_Article.UpdateField(id, "IsSlide=0");
else
dal_Article.UpdateField(id, "IsSlide=1");
break;
}
Response.Redirect(Request.Url.ToString());
}
//批量删除
protected void lbtnDel_Click(object sender, EventArgs e)
{
for (int i = 0; i < rptList.Items.Count; i++)
{
CheckBox cb = rptList.Items[i].FindControl("cb_id") as CheckBox;
Label lb = rptList.Items[i].FindControl("lb_id") as Label;
int id = Int32.Parse(lb.Text);
if (cb.Checked)
{
dalArticle.Del(id);
JscriptPrint("新闻添加成功啦!", "List.aspx", "Success");
}
}
Response.Redirect(Request.Url.ToString());
}
//搜索
protected void btnSelect_Click(object sender, EventArgs e)
{
//Response.Redirect("List.aspx?" + CombUrlTxt(this.classId, Keyword.Text.Trim(), this.property) + "page=0");
databind();
}
//protected void Bind()
//{
// //string sql;
// //if (gjz != "")
// //{ sql = "(Title like '%" + gjz + "%')"; }
// //if (!string.IsNullOrEmpty(this.ddlProperty.SelectedValue))
// //{
// // property = this.ddlProperty.SelectedValue;
// // sql += " and Property=" + ddlProperty;
// //}
// strSql = "select * from dt_Article where (Title like '%" + gjz + "%')";
// rptList.DataSource = DbHelperSQL.Query(strSql.ToString());
// //this.rptList.DataSource = dalArticle.GetPageList(this.pagesize, this.page, sql, "AddTime desc", this.rptList);
// this.rptList.DataBind();
//} |