}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("check"))
{
string id = Convert.ToString(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value);
string sqlstr = "update memberlist set checked='已审核' where id='" + id + "'";
SqlDataSource1.UpdateCommand = sqlstr;
SqlDataSource1.Update();
}
if (e.CommandName.Equals("uncheck"))
{
string id = Convert.ToString(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value);
string sqlstr = "update memberlist set checked='未审核' where id='" + id + "'";
SqlDataSource1.UpdateCommand = sqlstr;
SqlDataSource1.Update();
}
新闻管理
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["model"] = Request["model"];
ViewState["id"] = Request["id"];
if (ViewState["model"].ToString().Equals("edit"))
{
database db = new database();
string sqlstr = "select * from newlise where id=" + Convert.ToInt32(ViewState["id"]);
SqlDataReader dr = db.executeread(sqlstr);
if (dr.Read())
{
TextBox1.Text = dr[1].ToString();
TextBox2.Text = dr[2].ToString();
}
}
}
}
“添加”
protected void Button1_Click(object sender, EventArgs e)
{
string tle = TextBox1.Text;
string cont = TextBox2.Text;
string sql;
database db = new database();
if (ViewState["model"].ToString().Equals("add"))
sql = "insert into newlist(title,content) values('" + tle + "','" + cont + "')";
else
sql = "update newlise set title='" + tle + "',content='" + cont + "' where id =" + Convert.ToInt32(ViewState["id"]);
int num = db.executenon(sql);
if (num0)
Response.Write("script language='javascript' alert ('提交成功!')/script");
else
Response.Write("script language='javascript' alert (提交不成功!')/script");
}
“编辑”
Response.Redirect("newsmanage.aspx?model=edit");
新书添加:
string lb_name = DropDownList1.SelectedValue.ToString();
string bk_name = TextBox2.Text;
string bk_auth = TextBox3.Text;
string bk_cbs = TextBox4.Text;
Double bk_pri = Convert.ToDouble(TextBox6.Text);
string bk_jj = TextBox1.Text;
string bk_ofile = File1.Value.ToString();
string[] tpfile = bk_ofile.Split('.');
string ext = "." + tpfile[tpfile.Length - 1];
Random r = new Random();
string bk_img = DateTime.Now.Year.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Second.ToString() + r.Next(100, 1000).ToString();
bk_img = bk_img + ext;
File1.PostedFile.SaveAs(Server.MapPath("image/") + bk_img);
bk_img = "image" + "/" + bk_img;
string sqlstr = "insert into booklist(bookname,autler,cbs,price,info,img,categary) values('" + bk_name + "','" + bk_auth + "','" + bk_cbs + "'," + bk_pri + ",'" + bk_jj + "','" + bk_img + "','" + lb_name + "')";
database db = new database();
int num = db.executenon(sqlstr);
if (num0)
{
Response.Write("script language='javascript'alter('插入成功')/script");
Response.Redirect("bookmanage.aspx");
}
else
{
Response.Write("script language='javascript'alter('插入失败')/script");
}
购物
public partial class bookshop2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request["name"] != null)
{
ViewState["name"] = Request["name"].ToString();
}
else
{
ViewState["name"] = "%";
}
if (!IsPostBack)
{
ViewState["pageindex"] = "0";
BindData(ViewState["name"].ToString());
}
}
private void BindData(string categoryName)
{
database db = new database();
string sqlstr = "SELECT * From booklist where categary like '%" + categoryName + "%'";
推荐阅读
- gis母线漏气处理,gis母线穿墙封堵装置
- c语言套接字什么意思,c 套接字
- html复制代码,html代码怎么复制
- php存入数据库日期,php添加数据库记录
- 达内java源代码 达内java证书有用吗
- 淘宝购物车html模板,淘宝购物车html代码
- sqlserver2008无法登陆,sql2008sa无法登录
- wps转pdf的做法,wps里面转pdf
- python主函数怎么加 python主函数写法