protected void mboor_ItemCommand(object sender, Magic.Web.UI.MagicItemEventArgs args) { if (args.CommandName == "delete") { using (ISession session = new Session()) { session.BeginTransaction(); try { bool deleted = false; foreach (RepeaterItem item in this.rInfo.Items) { HtmlInputCheckBox chk = item.FindControl("chkItem") as HtmlInputCheckBox; if (chk != null && chk.Checked && Cast.Int(chk.Value) > 0) { Magic.Basis.ItemSpec spec = ItemSpec.Retrieve(session, Cast.Int(chk.Value)); ItemMaster master = ItemMaster.Retrieve(session, spec.ItemID); if (master.ItemType == ItemType.AssistantItem) { if (spec != null) { spec.Delete(session); } if (master != null) { master.Delete(session); } deleted = true; } } } session.Commit(); if (deleted) { this.QueryAndBindDate(session, this.mpage.CurrentPageIndex, this.mpage.PageSize, true); } WebUtil.ShowMsg(this, "选择的辅料已经被删除", "操作成功"); } catch (Exception err) { session.Rollback(); WebUtil.ShowError(this, err); } this.QueryAndBindDate(session, this.mpage.CurrentPageIndex, this.mpage.PageSize, true); } } }