Beispiel #1
0
    /// <summary>
    /// 编辑
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //更新
        string addrpic = Labelpic.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;
        string pic   = addrpic;
        int    fcal  = int.Parse(txt_fcal.Text);
        string memo  = Textarea1.Value;


        SP.Model.food model = new SP.Model.food();
        model.title = title;
        model.pic   = pic;
        model.fcal  = fcal;
        model.memo  = memo;
        model.id    = int.Parse(Request.QueryString["id"]);

        bll.Update(model);

        Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('操作成功,请返回!');location.href='List.aspx';</script>");
    }
Beispiel #2
0
 //初始化
 private void ShowInfo()
 {
     if (Request.QueryString["id"] != null)
     {
         SP.BLL.food   bll   = new SP.BLL.food();
         SP.Model.food model = bll.GetModel(int.Parse(Request.QueryString["id"]));
         this.lblid.Text    = model.id.ToString();
         this.lbltitle.Text = model.title;
         imgpic.ImageUrl    = "../../uploads/" + model.pic;
         this.lblfcal.Text  = model.fcal.ToString();
         this.lblmemo.Text  = model.memo;
         this.lblatime.Text = model.atime.ToString();
     }
 }
Beispiel #3
0
 //初始化
 private void ShowInfo()
 {
     if (Request.QueryString["id"] != null)
     {
         SP.BLL.food bll = new SP.BLL.food();
         //根据编号得到相应的记录
         DataSet       ds    = bll.GetList("  id=" + Request.QueryString["id"]);
         SP.Model.food model = bll.GetModel(int.Parse(Request.QueryString["id"]));
         if (ds.Tables[0].Rows.Count > 0)
         {
             DataRow sdr = ds.Tables[0].Rows[0];
             lbltitle.Text   = sdr["title"].ToString();
             imgpic.ImageUrl = "../../uploads/" + model.pic;
             lblmemo.Text    = sdr["memo"].ToString();
             // lblfcal.Text = sdr["fcal"].ToString()+"卡路里/100g";
             lblatime.Text = sdr["atime"].ToString();
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(SP.Model.food model)
 {
     return(dal.Update(model));
 }
Beispiel #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(SP.Model.food model)
 {
     return(dal.Add(model));
 }