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

public partial class admin_Jobs_Jobs :BasePage
{
    EasyAccess AccessHelp = new EasyAccess();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            JobList();
        }
    }
    public void JobList()
    {
        StringBuilder str = new StringBuilder();
        if (!TextBox1.Text.IsNull() && DropDownList1.SelectedValue != "0")
        {
            str.Append(" where n_title like '%" + TextBox1.Text + "%' and tid='" + DropDownList1.SelectedValue + "' ");
        }
        else
        {
            if (!TextBox1.Text.IsNull())
            {
                str.Append(" where n_title like '%" + TextBox1.Text + "%' ");
            }
            if (DropDownList1.SelectedValue != "0")
            {
                str.Append(" where tid='" + DropDownList1.SelectedValue + "'");
            }
        }

        string sql = "select * from news "
                        + str.ToString() + "order by id desc ";
        GridView1.DataSource = AccessHelp.ExecuteDataSet(sql);
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        JobList();
    }

    protected void lbtnFirst_Click(object sender, EventArgs e)
    {
        GridView1.PageIndex = 0;
        JobList();

    }
    protected void lbtnUp_Click(object sender, EventArgs e)
    {
        if (GridView1.PageIndex == 0)
        {
            return;
        }
        GridView1.PageIndex = GridView1.PageIndex - 1;

        JobList();

    }
    protected void lbtnDown_Click(object sender, EventArgs e)
    {
        GridView1.PageIndex = GridView1.PageIndex + 1;

        JobList();

    }
    protected void lbtnLast_Click(object sender, EventArgs e)
    {
        GridView1.PageIndex = GridView1.PageCount;
        JobList();
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string lid = GridView1.DataKeys[e.RowIndex].Value.ToString();
        string sql = "delete from news where id=" + lid.ToInt32() + "";
        bool IsOK = AccessHelp.ExecuteNonQuery(sql);
        if (IsOK)
        {
            JWindow.ShowDialog("删除成功！");
            JobList();
        }
        else
        {
            JWindow.ShowDialog("删除失败！");
        }
    }
    public string getTypeName(string id)
    {
        return AccessHelp.ExecuteScalar("select news_typename from newstype where news_typeid='" + id + "'");
    }

    protected void btnGo_Click(object sender, EventArgs e)
    {

        JobList();
    }
}
