Beispiel #1
0
    //加载
    public void LoadDataBind()
    {
        int ID = CommonClass.ReturnRequestInt("id", 0);

        if (ID > 0)
        {
            TB_Product_Picture model = ProductService.PictureService.Get(ID);
            if (model.ID.ToInt() > 0)
            {
                TbName.Text     = model.Name;
                Picture.Url     = model.PicUrl;
                TbDate.Text     = model.AddDate.ToString();
                TbOrderBy.Text  = model.OrderBy.ToStr();
                ViewState["id"] = model.ID;
            }
        }
    }
Beispiel #2
0
    //保存
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        TB_Product_Picture model = new TB_Product_Picture();

        if (ViewState["id"] != null)
        {
            model = ProductService.PictureService.Get(ViewState["id"]);
        }
        else
        {
            model.ProID = Request["pid"].ToInt();
        }
        model.Name    = TbName.Text;
        model.PicUrl  = Picture.Url;
        model.OrderBy = TbOrderBy.Text.ToInt();
        model.Creater = AdminUserName;
        model.AddDate = Convert.ToDateTime(TbDate.Text);

        if (ViewState["id"] == null)
        {
            if (ProductService.PictureService.Insert(model) == 1)
            {
                MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功");
            }
            else
            {
                MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败");
            }
        }
        else
        {
            model.ID = ViewState["id"].ToInt();
            if (ProductService.PictureService.Update(model) == 1)
            {
                MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功");
            }
            else
            {
                MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败");
            }
        }
    }