//修改活动信息 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 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); } }
//增加活动 public static int add(ActIvit act) { string sql = "insert into ActIvit values(@Act_Title,@Act_Content,@Act_Img,@Act_Time)"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@Act_Title", act.Act_Title1), new SqlParameter("@Act_Content", act.Act_Content1), new SqlParameter("@Act_Img", act.Act_Img1), new SqlParameter("@Act_Time", act.Act_Time1) }; return(DBHelper.GetExcuteNonQuery(sql, sp)); }
//修改活动信息 public static int update(ActIvit act) { string sql = "update ActIvit set Act_Title=@Act_Title,Act_Content=@Act_Content,Act_Img=@Act_Img,Act_Time=@Act_Time where Act_ID=@Act_ID"; SqlParameter[] sp = new SqlParameter[] { new SqlParameter("@Act_ID", act.Act_ID1), new SqlParameter("@Act_Title", act.Act_Title1), new SqlParameter("@Act_Content", act.Act_Content1), new SqlParameter("@Act_Img", act.Act_Img1), new SqlParameter("@Act_Time", act.Act_Time1) }; return(DBHelper.GetExcuteNonQuery(sql, sp)); }
//增加活动 public static int add(ActIvit act) { return(ActDal.add(act)); }
//更改某个活动 public static int update(ActIvit act) { return(ActDal.update(act)); }