Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtId.Text))
            {
                strErr += "Id格式错误!\\n";
            }
            if (this.txtName.Text.Trim().Length == 0)
            {
                strErr += "Name不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    Id   = int.Parse(this.txtId.Text);
            string Name = this.txtName.Text;

            BookShop.Model.Categories model = new BookShop.Model.Categories();
            model.Id   = Id;
            model.Name = Name;

            BookShop.BLL.Categories bll = new BookShop.BLL.Categories();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 根据主键ID更新一条记录
 /// </summary>
 /// <param name="model">更新后的实体</param>
 /// <returns>执行结果受影响行数</returns>
 public int Update(Categories model)
 {
     return(_dao.Update(model));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 向数据库中添加一条记录
 /// </summary>
 /// <param name="model">要添加的实体</param>
 /// <returns>插入数据的ID</returns>
 public int Insert(Categories model)
 {
     return(_dao.Insert(model));
 }