예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(this.teAuthorityName.Text))
            {
                XtraMessageBox.Show("button text is empty!", "提示", MessageBoxButtons.OK);
                return;
            }
            var source = tlueMenu.Properties.DataSource as List <MenusVM>;

            if (this.tlueMenu.EditValue == null)
            {
                XtraMessageBox.Show("menu is empty!", "提示", MessageBoxButtons.OK);
                return;
            }

            var item = this.tlueMenu.EditValue as MenusVM;//当前选中的实体

            if (item.ParentID == 0)
            {
                if (source.Any(p => p.ParentID == item.ID))//有孩子
                {
                    XtraMessageBox.Show("please select children menu!", "提示", MessageBoxButtons.OK);
                    return;
                }
            }

            AuthoritiesVM vm = new AuthoritiesVM()
            {
                MenuID = item.ID,
                Name   = this.teAuthorityName.Text.Trim()
            };


            var res = _bll.AddAuthorities(vm);

            if (res > 0)
            {
                XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK);
                RequestAuthoritiesData();
            }
            else
            {
                XtraMessageBox.Show("保存失败!", "提示", MessageBoxButtons.OK);
            }
        }