BrowseForm 功能加权限控制

一、增加Command定义 (在Smart.App.Public.Commands.cs 中)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Media;
using Smart.Controls;
using System.Collections;

namespace Smart.App.Public
{
    public class Commands
    {
        /*----------*/
        /* TK新加 */
        /*----------*/
        private static SmartCommand finish = new SmartCommand(9000, "標記完成", "Finish", new KeyGesture(Key.None, ModifierKeys.None, ""));
        public static SmartCommand Finish { get { return finish; } }
    }
}

二、Browse Form XAML 代码

    <s:BrowserPage.CommandBindings>
        <!--有权限可用-->
        <CommandBinding Command="local:Commands.Finish" CanExecute="CanExecuted" Executed="OnFinish" />  
    </s:BrowserPage.CommandBindings>

    <s:BrowserPage.CommandBindings>
        <!--有权限且有记录才可用-->
        <CommandBinding Command="local:Commands.Finish" CanExecute="CanExecutedWithCurrentItem" Executed="OnFinish" />
    </s:BrowserPage.CommandBindings>

三、BrowseForm  额外附加条件  (非必要)     

        public override void CanExecutedWithCurrentItem(object sender, CanExecuteRoutedEventArgs e)
        {
            base.CanExecutedWithCurrentItem(sender, e);
            if (e.Command == Smart.App.Public.Commands.Finish)
            {
                e.CanExecute = e.CanExecute && (1 == 2);   //1==2 为额外条件
            }
        }
        public override void CanExecuted(object sender, CanExecuteRoutedEventArgs e)
        {
            base.CanExecuted(sender, e);

            if (e.Command == Smart.App.Public.Commands.Finish)
            {
                e.CanExecute = e.CanExecute && (1==2);   //1==2 为额外条件
            }
        }

四、BrowseForm 执行方法
        private void OnFinish(object sender, ExecutedRoutedEventArgs e)
        {
            if (dm.CurrentItem == null)
            {
                MessageBox.Show("请先选中要標記的行記錄。");
                return;
            }
            if (string.IsNullOrEmpty(dm.CurrentItem.Row.Field<string>("OrderResult")))
            {
                MessageBox.Show("未處理的記錄不能做標記完成。");
                return;
            }

            var editor = new PubOrderEditor();
            editor.State = DataState.Edit;
            editor.IsMarkFinish = true;
            editor.IsDisableInput = true;
            editor.DataModel = dm;
            AppManager.ShowWindowInTab("標記完成", editor);
        }

详见: TK的订单
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值