protected void btnMutil_Click(object sender, EventArgs e) { string[] arr = this.txtBrandsName.Text.Split('|'); WebSiteData.Brands dal = new WebSiteData.Brands(); int n = 0; for (int i = 0; i < arr.Length; i++) { string BrandsName = arr[i]; int SortIndex = int.Parse(this.txtSortIndex.Text); string Remark = this.txtRemark.Value; WebSiteModel.Brands model = new WebSiteModel.Brands(); model.BrandsName = BrandsName; model.SortIndex = SortIndex; model.Remark = Remark; n = dal.Add(model); if (n < 1) { Response.Write("<span>添加失败了!</span>"); continue; } else { Response.Write("<span>添加成功了!</span>"); } } }
private bool DoAdd() { bool result = true; string BrandsName = this.txtBrandsName.Text; int SortIndex = int.Parse(this.txtSortIndex.Text); string Remark = this.txtRemark.Value; WebSiteModel.Brands model = new WebSiteModel.Brands(); model.BrandsName = BrandsName; model.SortIndex = SortIndex; model.Remark = Remark; WebSiteData.Brands bll = new WebSiteData.Brands(); if (bll.Add(model) < 1) { result = false; } return(result); }