protected void btDelete_Click(object sender, EventArgs e) { ArrayList pkArray = null; WarehouseBLL bll = null; List <string> msgList = new List <string>(); try { bll = BLLFactory.CreateBLL <WarehouseBLL>(); pkArray = GvHelper.GetPKValueByChk(this.GvList, 0, "cbxSelect", 0); if (pkArray.Count == 0) { ClientScript.RegisterStartupScript(this.GetType(), "myjs", "MSI('提示','请选择要删除的记录');", true); return; } for (int i = 0; i < this.GvList.Rows.Count; i++) { CheckBox cbxSelect = this.GvList.Rows[i].Cells[0].FindControl("cbxSelect") as CheckBox; if (cbxSelect.Checked == false) { continue; } Warehouse site = new Warehouse(); site.ID = this.GvList.DataKeys[i]["ID"].ToString(); site.Description = this.GvList.Rows[i].Cells[1].Text; //判断是否已使用 bool r = bll.IsUse(site); if (r == true) { msgList.Add(site.Description); continue; } //删除 bll.Delete(site); } string msg = string.Join(",", msgList.ToArray()); if (msg != "") { ClientScript.RegisterStartupScript(this.GetType(), "myjs", "MSI('提示','" + msg + "仓库已使用,无法删除');", true); } this.BindData(); } catch (Exception ex) { throw ex; } }