protected void addAct_Click(object sender, EventArgs e) { ActIvit act = new ActIvit(); act.Act_Title1 = txtTitle.Text.Trim(); act.Act_Time1 = DateTime.Parse(txtTime.Text.Trim()); act.Act_Img1 = @"~/Img_Act/" + FileUpload1.PostedFile.FileName; act.Act_Content1 = txtContent.Text; try { if (ActBll.add(act) == 1) { txtTitle.Text = ""; txtTime.Text = ""; txtContent.Text = ""; Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('添加成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('添加失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } }
//修改活动信息 protected void updateAct_Click(object sender, EventArgs e) { ActIvit act = new ActIvit(); act.Act_ID1 = int.Parse(Request.QueryString["actid"].ToString().Trim()); act.Act_Title1 = txtTitle.Text.Trim(); act.Act_Content1 = txtContent.Text; act.Act_Time1 = DateTime.Parse(DateTime.Now.ToShortDateString().ToString()); act.Act_Img1 = @"~/Img_Act/" + FileUpload1.PostedFile.FileName; try { if (ActBll.update(act) == 1) { Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('修改成功!');</script>"); } else { Page.ClientScript.RegisterClientScriptBlock(typeof(object), "alert", "<script>alert('修改失败!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { //int i = 0; DataTable dt = ActBll.newact(); Repeater1.DataSource = dt; Repeater1.DataBind(); if (!IsPostBack) { bindLuandou(); bindZatan(); bindBanben(); Bindtiezi(); bindlive(); binglistview(); } }
protected void Page_Load(object sender, EventArgs e) { int id; if (!IsPostBack) { if (Request.QueryString["actid"] != null) { id = int.Parse(Request.QueryString["actid"].ToString().Trim()); SqlDataReader dt = ActBll.select(id); dt.Read(); if (dt != null) { title.Text = dt[1].ToString().Trim(); time.Text = string.Format("{0:yyyy-MM-dd hh:mm}", dt[4]); Image1.ImageUrl = dt[3].ToString().Trim(); txtContent.Text = dt[2].ToString(); } } } }
protected void Page_Load(object sender, EventArgs e) { int actid; Repeater1.DataSource = ActBll.allact(); Repeater1.DataBind(); if (!IsPostBack) { if (Request.QueryString["actid"] != null) { actid = Convert.ToInt32(Request.QueryString["actid"].ToString()); SqlDataReader dt = ActBll.select(actid); dt.Read(); if (dt != null) { txtTitle.Text = dt[1].ToString().Trim(); txtTime.Text = dt[4].ToString().Trim(); txtContent.Text = dt[2].ToString(); } } } }
protected void Page_Load(object sender, EventArgs e) { Bindview(); int id; if (!IsPostBack) { try { if (Request.QueryString["actid"] != null) { id = int.Parse(Request.QueryString["actid"].ToString()); ActBll.delete(id); Bindview(); Page.ClientScript.RegisterClientScriptBlock(typeof(Object), "alert", "<script>alert('删除成功!');</script>"); } } catch (Exception ex) { Response.Write("错误原因:" + ex.Message); } } }
//绑定数据 protected void Bindview() { ListView1.DataSource = ActBll.allact(); ListView1.DataBind(); }