public void btnSave_Click(object sender, EventArgs e) { string strErr=""; if(this.txtName.Text.Trim().Length==0) { strErr+="Name不能为空!\\n"; } if(strErr!="") { MessageBox.Show(this,strErr); return; } int Id=int.Parse(this.lblId.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.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx"); }
private void ShowInfo(int Id) { BookShop.BLL.Categories bll = new BookShop.BLL.Categories(); BookShop.Model.Categories model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblName.Text = model.Name; }
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"); }