{
MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex - 1; }
getArticle(); } else {
myLabel.Text = \审核错误!\; conn.Close();
MyDataGrid.EditItemIndex = -1; getArticle(); } }
public string show(object a, object b, object c) {
string
dr
=
\
src=../images/canedit.gif
align=absMiddle>
href=admin_articleEdit.aspx?articleid=\ + b + \ + a + \;
string de = \ + a; string g = (string)Session[\]; string d = (string)Session[\]; string f = (string)c;
if (g.Trim() == \系统管理员\) {
return dr; } else {
if ((int)Session[\] == 1 && d.Trim() == f.Trim()) return dr; else return de; } }
protected void searchTitle() { try {
string
con
=
ConfigurationManager.ConnectionStrings[\].ConnectionString; SqlConnection conn = new SqlConnection(con);//连接字符串 conn.Open();
SqlDataAdapter myCommand = new SqlDataAdapter(); //创建SqlDataAdapter 类 myCommand.SelectCommand = new SqlCommand(\, conn); myCommand.SelectCommand.CommandType = CommandType.StoredProcedure; SqlParameter
title
=
myCommand.SelectCommand.Parameters.Add(\,
//搜索标题
//设置权限
SqlDbType.NVarChar, 500);
title.Value = Request[\];
DataSet ds = new DataSet(); //建立并填充数据集 myCommand.Fill(ds, \); MyDataGrid.DataSource = ds; MyDataGrid.DataBind(); conn.Close(); }
catch (SqlException e) {
Console.WriteLine(\ + e.Message); //出错处理 } }
protected void searchContent() { try {
string
con
=
ConfigurationManager.ConnectionStrings[\].ConnectionString; SqlConnection conn = new SqlConnection(con);//连接字符串 conn.Open();
SqlDataAdapter myCommand = new SqlDataAdapter(); //创建SqlDataAdapter 类 myCommand.SelectCommand = new SqlCommand(\, conn);
myCommand.SelectCommand.CommandType = CommandType.StoredProcedure;
SqlParameter content = myCommand.SelectCommand.Parameters.Add(\, SqlDbType.NText);
content.Value = Request[\].Trim(); DataSet ds = new DataSet(); //建立并填充数据集 myCommand.Fill(ds, \); MyDataGrid.DataSource = ds; MyDataGrid.DataBind(); conn.Close(); }
catch (SqlException e) {
Console.WriteLine(\ + e.Message); //出错处理 } }
protected void delarticle(object a) {
string con = ConfigurationManager.ConnectionStrings[\].ConnectionString; SqlConnection conn = new SqlConnection(con); conn.Open();
//建立连接
//删除审核新闻
//绑定
//搜索内容
//绑定
SqlCommand delAdmin = new SqlCommand(\, conn); 命令
delAdmin.CommandType = CommandType.StoredProcedure;
//建立
SqlParameter id = delAdmin.Parameters.Add(\, SqlDbType.BigInt); id.Value = a; if (r > 0) {
myLabel.Text = \删除成功!\; conn.Close(); //
MyDataGrid.EditItemIndex = -1;
int d = MyDataGrid.PageCount % MyDataGrid.PageSize; if (MyDataGrid.CurrentPageIndex > 0) {
MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex - 1; }
getArticle(); } else {
myLabel.Text = \删除错误!\; conn.Close();
MyDataGrid.EditItemIndex = -1; getArticle(); } }
protected void addnum(string dr) {
string username = (string)Session[\];
string conn = ConfigurationManager.ConnectionStrings[\].ConnectionString;
//取得DSN字符
SqlConnection con = new SqlConnection(conn);//连接字符串 con.Open();
SqlCommand cmd = new SqlCommand(\, con); cmd.CommandType = CommandType.StoredProcedure;
SqlParameter name = cmd.Parameters.Add(\, SqlDbType.Char, 200); //调用并设置存储过程参数
name.Value = dr.Trim();
int r = cmd.ExecuteNonQuery(); }
public void PagerButtonClick(Object sender, EventArgs e) {
//获得LinkButton的参数值
//执行命令
//建立命令
//增加发表文章数
//获得参数的值
int r = delAdmin.ExecuteNonQuery(); //删除
string arg = ((LinkButton)sender).CommandArgument;
switch (arg) {
case (\):
if (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1)) MyDataGrid.CurrentPageIndex++; break; case (\):
if (MyDataGrid.CurrentPageIndex > 0) MyDataGrid.CurrentPageIndex--; break; case (\):
MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1); break; case (\):
MyDataGrid.CurrentPageIndex = 0; break; }
getArticle(); }
protected void addClassNum(string d) {
string username = (string)Session[\];
string conn = ConfigurationManager.ConnectionStrings[\].ConnectionString;
//取得DSN字符
SqlConnection con = new SqlConnection(conn);//连接字符串 con.Open();
SqlCommand cmd = new SqlCommand(\, con); cmd.CommandType = CommandType.StoredProcedure;
SqlParameter name = cmd.Parameters.Add(\, SqlDbType.Char, 200); //调用并设置存储过程参数
name.Value = d.Trim();
int r = cmd.ExecuteNonQuery(); }
#region Web Form Designer generated code override protected void OnInit(EventArgs e) {
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。 InitializeComponent(); base.OnInit(e); }
protected void InitializeComponent() {
//建立命令
//增加分类文章数
this.LinkButton1.Click += new System.EventHandler(this.LinkButton1_Click1); this.Load += new System.EventHandler(this.Page_Load); }
#endregion
public void MyDataGrid_SelectedIndexChanged(object sender, System.EventArgs e) {
getArticle(); } public {
string sd = (string)e.Item.Cells[3].Text; if (e.CommandName == \) {
string a = (string)Session[\];
if (a.Trim() == \系统管理员\ || (int)Session[\] == 1) {
object d = this.MyDataGrid.DataKeys[(Int32)e.Item.ItemIndex]; passArticle(d);
//通过审核
addnum(sd); //增加管理员发表文章数 addClassNum(clum.Trim()); }
else myLabel.Text = \你无权操作\; } } Public {
object b = this.MyDataGrid.DataKeys[e.Item.ItemIndex]; string c = (string)Session[\]; string d = (string)Session[\]; string g = (string)e.Item.Cells[1].Text; string f = (string)Session[\]; if (c.Trim() == \系统管理员\) {
delarticle(b); } else {
if ((int)Session[\] == 1 && g.Trim() == f.Trim()) {
delarticle(b }
void
MyDataGrid_DeleteCommand(object
source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
//取得管理员名
string clum = (string)e.Item.Cells[1].Text; //取得分类名
void
MyDataGrid_ItemCommand(object
source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)