Exemplo n.º 1
0
        /// <summary>
        /// 批量删除数据
        /// </summary>
        private void OnDelete()
        {
            string itemsAppend = hV.Value.Trim();

            if (string.IsNullOrEmpty(itemsAppend))
            {
                WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "请至少勾选一行进行操作", "操作错误", "error");
                return;
            }

            if (bll == null)
            {
                bll = new BLL.Category();
            }
            string[]      itemsAppendArr = itemsAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <string> list           = new List <string>();

            foreach (string item in itemsAppendArr)
            {
                string[] itemArr = item.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                Dictionary <string, string> dic = bll.GetKeyValueByParentId(itemArr[0]);
                if (dic != null && dic.Count > 0)
                {
                    WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "不能删除,原因:分类名称为“" + itemArr[1] + "”存在子级,请先删除所有子级");
                    return;
                }

                list.Add(itemArr[0]);
            }

            if (list.Count > 0)
            {
                if (bll.DeleteBatch(list))
                {
                    WebHelper.MessageBox.MessagerShow(this.Page, lbtnPostBack, "操作成功");
                    GetSearchItem();
                    Bind();
                }
                else
                {
                    WebHelper.MessageBox.Messager(this.Page, lbtnPostBack, "操作失败,请检查", "系统提示");
                }
            }
        }