// public DelegateCommand SaveConfigurationCommand { get; set; }

        private void InitCommand()
        {
            //SaveConfigurationCommand = new DelegateCommand((obj) =>
            //{
            //    // 把界面数据同步到模板上
            //    CommonService.LoadIEnumerableToDatabase(DataGridLists, "SJDataGridColumnHeaderTemplate");

            //    // Insert或者Update数据
            //    _service.SaveColumnConfigurationInManagementView(_dataGridName, User.ID);

            //});

            MoveUpCommand = new DelegateCommand((obj) =>
            {
                var cloneData = ObjectDeepCopyHelper <DataGridColumnHeaderUserCustomModel, DataGridColumnHeaderUserCustomModel> .Trans(DataGridSelectedItem);

                int index = DataGridLists.IndexOf(DataGridSelectedItem);
                if (index == 0)
                {
                    return;
                }

                int upOrder           = DataGridLists.ElementAt(index - 1).ColumnOrder;
                int currentOrder      = DataGridSelectedItem.ColumnOrder;
                cloneData.ColumnOrder = upOrder;
                DataGridLists.ElementAt(index - 1).ColumnOrder = currentOrder;

                DataGridLists.RemoveAt(index);
                index--;
                DataGridLists.Insert(index, cloneData);
                DataGridSelectedItem = cloneData;
            });

            MoveDownCommand = new DelegateCommand((obj) =>
            {
                var cloneData = ObjectDeepCopyHelper <DataGridColumnHeaderUserCustomModel, DataGridColumnHeaderUserCustomModel> .Trans(DataGridSelectedItem);
                int index     = DataGridLists.IndexOf(DataGridSelectedItem);
                if (index == DataGridLists.Count - 1)
                {
                    return;
                }

                int downOrder         = DataGridLists.ElementAt(index + 1).ColumnOrder;
                int currentOrder      = DataGridSelectedItem.ColumnOrder;
                cloneData.ColumnOrder = downOrder;
                DataGridLists.ElementAt(index + 1).ColumnOrder = currentOrder;

                DataGridLists.RemoveAt(index);
                index++;
                DataGridLists.Insert(index, cloneData);
                DataGridSelectedItem = cloneData;
            });
        }
        private void InitCommand()
        {
            SaveCommand = new DelegateCommand((obj) =>
            {
                CommonService.LoadIEnumerableToDatabase(DataGridLists, "SJDataGridColumnHeaderTemplate");
                // 修改后台数据
                if (_service.BatchUpdate())
                {
                    QueryCommand.Execute(null);
                }
            });

            NewCommand = new DelegateCommand((obj) =>
            {
                DataGridColumnHeaderModel inputEntity = DataGridSelectedItem == null? new DataGridColumnHeaderModel {
                    MainMenuId = Menu.ID, ColumnOrder = 1000, ColumnWidth = 120
                } : ObjectDeepCopyHelper <DataGridColumnHeaderModel, DataGridColumnHeaderModel> .Trans(DataGridSelectedItem);

                inputEntity.ColumnOrder++;

                DataGridColumnAddWindow view = new DataGridColumnAddWindow();

                (view.DataContext as DataGridColumnAddViewModel).WithParam(inputEntity, (type, outputEntity) =>
                {
                    view.Close();
                    if (type == 1)
                    {
                        if (_service.Insert(outputEntity))
                        {
                            QueryCommand.Execute(null);
                        }
                    }
                });
                view.ShowDialog();
            });

            MoveUpCommand = new DelegateCommand((obj) =>
            {
                var cloneData = ObjectDeepCopyHelper <DataGridColumnHeaderModel, DataGridColumnHeaderModel> .Trans(DataGridSelectedItem);

                int index = DataGridLists.IndexOf(DataGridSelectedItem);
                if (index == 0)
                {
                    return;
                }

                int upOrder           = DataGridLists.ElementAt(index - 1).ColumnOrder;
                int currentOrder      = DataGridSelectedItem.ColumnOrder;
                cloneData.ColumnOrder = upOrder;
                DataGridLists.ElementAt(index - 1).ColumnOrder = currentOrder;

                DataGridLists.RemoveAt(index);
                index--;
                DataGridLists.Insert(index, cloneData);
                DataGridSelectedItem = cloneData;
            });

            MoveDownCommand = new DelegateCommand((obj) =>
            {
                var cloneData = ObjectDeepCopyHelper <DataGridColumnHeaderModel, DataGridColumnHeaderModel> .Trans(DataGridSelectedItem);
                int index     = DataGridLists.IndexOf(DataGridSelectedItem);
                if (index == DataGridLists.Count - 1)
                {
                    return;
                }

                int downOrder         = DataGridLists.ElementAt(index + 1).ColumnOrder;
                int currentOrder      = DataGridSelectedItem.ColumnOrder;
                cloneData.ColumnOrder = downOrder;
                DataGridLists.ElementAt(index + 1).ColumnOrder = currentOrder;

                DataGridLists.RemoveAt(index);
                index++;
                DataGridLists.Insert(index, cloneData);
                DataGridSelectedItem = cloneData;
            });

            QueryCommand = new DelegateCommand((obj) =>
            {
                DataGridLists.Clear();
                _service.GetDataGridLists(CommonService.GetSqlWhereString(QueryParameter)).ForEach(x => DataGridLists.Add(x));
            });
        }