//新增按钮  或 修改按钮
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //在点击保存的时候,怎么样去判断这个操作是新增还是修改呢
            Model.eb_category model = new Model.eb_category();
            model.cname   = this.cname.Text.Trim();
            model.summary = this.summary.Text.Trim();

            if (!string.IsNullOrEmpty(this.hiddenCid.Value))
            {
                //修改
                model.cid = int.Parse(this.hiddenCid.Value);
                bool flag = new BLL.eb_category().Update(model);
                if (flag)
                {
                    //修改成功
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "修改成功", "CategoryList.aspx");
                }
                else
                {
                    //修改失败
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "修改失败,请重试或联系管理员", "CategoryList.aspx");
                }
            }
            else
            {
                //新增
                int cid = new BLL.eb_category().Add(model);
                if (cid > 0)
                {
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this.Page, "添加成功", "CategoryList.aspx");
                }
                else
                {
                    Maticsoft.Common.MessageBox.Show(this.Page, "添加失败,请重试或联系管理员");
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MyEasyBuy.Model.eb_category model)
 {
     return(dal.Update(model));
 }
Exemple #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(MyEasyBuy.Model.eb_category model)
 {
     return(dal.Add(model));
 }