/// <summary> /// 编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { //更新 string addrpic = Labelbgpic.Text; if (fppic.HasFile) { string name = this.fppic.PostedFile.FileName; int i = name.LastIndexOf('.'); string extname = name.Substring(i); string filename = DateTime.Now.ToString("yyyyMMddhhmmssfff"); string path = filename + extname; string savePath = Server.MapPath(@"..\..\uploads\" + filename + extname); fppic.PostedFile.SaveAs(savePath); addrpic = path; } string title = txt_title.Text; int tid = int.Parse(ddltid.SelectedValue); string bgpic = addrpic; int mark = int.Parse(txt_mark.Text); string memo = Textarea1.Value; string remarks = txt_remarks.Text; DateTime atime = DateTime.Now; SP.Model.plans model = new SP.Model.plans(); model.title = title; model.tid = tid; model.bgpic = bgpic; model.mark = mark; model.memo = memo; model.remarks = remarks; model.atime = atime; model.pid = int.Parse(Request.QueryString["id"]); bll.Update(model); Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('操作成功,请返回!');location.href='List.aspx';</script>"); }
//初始化 private void ShowInfo() { if (Request.QueryString["id"] != null) { SP.BLL.plans bll = new SP.BLL.plans(); //根据编号得到相应的记录 DataSet ds = bll.GetList(" pid=" + Request.QueryString["id"]); SP.Model.plans model = bll.GetModel(int.Parse(Request.QueryString["id"])); if (ds.Tables[0].Rows.Count > 0) { DataRow sdr = ds.Tables[0].Rows[0]; lblpid.Text = sdr["pid"].ToString(); lbltitle.Text = sdr["title"].ToString(); lbltid.Text = sdr["tname"].ToString(); imgbgpic.ImageUrl = "../../uploads/" + model.bgpic; lblmark.Text = sdr["mark"].ToString(); lblmemo.Text = sdr["memo"].ToString(); lblremarks.Text = sdr["remarks"].ToString(); lblatime.Text = sdr["atime"].ToString(); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(SP.Model.plans model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(SP.Model.plans model) { return(dal.Add(model)); }