Beispiel #1
0
        public override void Execute(ListLogicalView view)
        {
            //创建一个临时的拷贝数据
            var listEntity = view.Current;
            var tmp = Entity.New(view.EntityType);
            tmp.Clone(listEntity);

            var evm = view.Meta;
            var res = PopupEditingDialog(evm, tmp, w =>
            {
                w.Title = this.Meta.Label.Translate() + " " + evm.Label.Translate();
            });

            if (res == WindowButton.Yes)
            {
                //修改按钮如果使用新的 Id,则它下面子对象的父外键都将是错误的值。
                listEntity.Clone(tmp, new CloneOptions(
                    CloneActions.NormalProperties | CloneActions.RefEntities
                    ));

                listEntity.MarkModifiedIfUnchanged();

                view.RefreshControl();
            }
        }
        public override void Execute(ListLogicalView view)
        {
            if (this.RefProperty == null) throw new ArgumentNullException("this.RefProperty");

            var ui = this.GenerateSelectionUI();

            var result = this.PopupSelectionWindow(ui);

            if (result == WindowButton.Yes)
            {
                foreach (var src in ui.MainView.GetSelectedEntities())
                {
                    //如果已经存在,则退出
                    bool eixst = false;
                    foreach (var item in view.Data)
                    {
                        var entity = item.GetRefEntity(this.RefProperty.RefEntityProperty);
                        if (entity.Id == src.Id)
                        {
                            eixst = true;
                            break;
                        }
                    }
                    if (eixst) continue;

                    this.AddSelection(view, src);
                }

                this.Complete(view);
            }
        }
 public override void Execute(ListLogicalView view)
 {
     var fa = view.Current as FileAttachement;
     var tmpFile = Path.Combine(Path.GetTempPath(), fa.FileName);
     File.WriteAllBytes(tmpFile, fa.ContentBytes);
     Process.Start(tmpFile);
 }
Beispiel #4
0
        public override bool CanExecute(ListLogicalView view)
        {
            bool canExecute = false;

            if (view.Data != null)
            {
                foreach (var item in view.Data)
                {
                    if (!this.CanShow(item))
                    {
                        canExecute = true;
                        break;
                    }
                }
            }

            //第一次运行时,执行过滤。
            if (canExecute && !this._initialized)
            {
                this.Execute(view);
                this._initialized = true;
            }

            return canExecute;
        }
Beispiel #5
0
        public override void Execute(ListLogicalView view)
        {
            var barcode = BarcodeTextBoxGenerator.GetTextBoxParameter(this);

            if (!string.IsNullOrEmpty(barcode))
            {
                var list = view.Data;
                var item = list.Cast<ProductRefItem>().FirstOrDefault(i => i.Product.Barcode == barcode);
                if (item != null)
                {
                    item.Amount++;
                }
                else
                {
                    var product = RF.Concrete<ProductRepository>().GetByBarcode(barcode);
                    if (product == null)
                    {
                        App.MessageBox.Show(string.Format("没有找到对应 {0} 的商品".Translate(), barcode), MessageBoxImage.Error);
                        return;
                    }

                    item = view.CreateNewItem().CastTo<ProductRefItem>();
                    item.Product = product;
                    item.Amount = 1;
                    list.Add(item);
                    view.RefreshControl();
                }

                view.Current = item;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 如果存在查询和导航面板,则刷新查询和导航面板的下拉列表框数据
        /// </summary>
        /// <param name="view"></param>
        public override void Execute(ListLogicalView view)
        {
            view.DataLoader.ReloadDataAsync();

            //QueryLogicalView queryView = view.NavigateQueryView;
            //if (queryView == null) { queryView = view.CondtionQueryView; }

            ////刷新查询或导航面板的下拉列表框数据
            //if (queryView != null)
            //{
            //    queryView.TryExecuteQuery(view);

            //    foreach (var item in queryView.PropertyEditors)
            //    {
            //        if (item.PropertyViewInfo.EditorName == WPFEditorNames.LookupDropDown)
            //        {
            //            (item as LookupListPropertyEditor).DataSourse = null;
            //        }
            //    }
            //    queryView.AttachNewQueryObject();
            //}
            //else
            //{
            //    view.DataLoader.LoadDataAsync();
            //}
        }
Beispiel #7
0
        public override void Execute(ListLogicalView view)
        {
            var category = view.Current as TaskOrCategory;
            if (category.IsTaskRO)
            {
                category = category.TreeParent as TaskOrCategory;
            }

            var task = view.CreateNewItem() as TaskOrCategory;

            var weeksCount = task.MonthPlan.WeeksCountRO;
            for (int i = 0; i < weeksCount; i++)
            {
                task.WeekCompletionList.Add(new WeekCompletion
                {
                    Index = i + 1
                });
            }

            task.WeightInCategory = 1;
            task.Score = 0;
            task.ObjectiveNum = 1;//放在添加 WeekCompletionList 之后

            category.TreeChildren.Add(task);

            view.RefreshControl();

            view.Current = task;

            CommandsHelper.EditCurrent(view);
        }
        protected override Entity AddSelection(ListLogicalView view, Entity src)
        {
            var e = base.AddSelection(view, src) as PurchaseOrderItem;

            e.RawPrice = (src as Product).CaiGouDanjia;

            return e;
        }
Beispiel #9
0
 public override void Execute(ListLogicalView view)
 {
     var language = view.Current as Language;
     AsyncAction.Execute(() =>
     {
         TranslateByEngine(language);
     });
 }
Beispiel #10
0
        public override bool CanExecute(ListLogicalView view)
        {
            if (!base.CanExecute(view)) { return false; }

            var bindingList = view.Data as IBindingList;
            if (bindingList == null || !bindingList.AllowNew) { return false; }

            return true;
        }
Beispiel #11
0
 public override bool CanExecute(ListLogicalView view)
 {
     if (base.CanExecute(view))
     {
         var data = this.FindModels(view);
         return(data != null && data.Count > 0);
     }
     return(false);
 }
Beispiel #12
0
        /// <summary>
        /// 通过 Id 来定位到列表视图中具体的一行。
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="id"></param>
        /// <rereturns>返回是否成功找到目标行。</rereturns>
        public static bool SetCurrentById(this ListLogicalView listView, object id)
        {
            var item = listView.Data
                       .FirstOrDefault(entity => entity.Id.Equals(id));

            listView.Current = item;

            return(item != null);
        }
Beispiel #13
0
 public override bool CanExecute(ListLogicalView view)
 {
     if (base.CanExecute(view))
     {
         var data = this.FindModels(view);
         return data != null && data.Count > 0;
     }
     return false;
 }
Beispiel #14
0
        protected override Entity AddSelection(ListLogicalView view, Entity selected)
        {
            var result = base.AddSelection(view, selected);

            this._firstSelection = this._firstSelection ?? result;

            (result as ProductRefItem).Amount = 1;

            return result;
        }
Beispiel #15
0
 public override void Execute(ListLogicalView view)
 {
     //关于是放在 MP VersionLog 中的。
     var resource = Application.GetResourceStream(new Uri("/MonthPlan;component/_Other/MP VersionLog.txt", UriKind.RelativeOrAbsolute));
     using (var reader = new StreamReader(resource.Stream))
     {
         var content = reader.ReadToEnd();
         App.MessageBox.Show(content, "关于", MessageBoxButton.OK, MessageBoxImage.Asterisk);
     }
 }
Beispiel #16
0
        public override void Execute(ListLogicalView view)
        {
            DbTranslator.Instance.AutoSave();

            if (view.Data == null || !view.Data.IsDirty)
            {
                view.DataLoader.LoadDataAsync();
            }

            App.MessageBox.Show("更新完成。".Translate());
        }
Beispiel #17
0
        private void InitListView(ListLogicalView view)
        {
            //如果是选择视图,则应该使用显示模型来创建控件。
            var resultControl = this._uiFactory.CreateTreeGrid(view.Meta, view.ShowInWhere);

            //为 ListLogicalView 初始化 ListEditor
            var listEditor = new TreeGridListEditor(view);

            listEditor.SetControl(resultControl);
            view.InitializeEditor(listEditor);
        }
        /// <summary>
        /// 根据所给列名,扩展指定的视图
        /// </summary>
        /// <param name="view"></param>
        /// <param name="yLabels"></param>
        protected void Refresh(ListLogicalView view, IList <string> yLabels)
        {
            if (yLabels == null || yLabels.Count == 0)
            {
                return;
            }

            this._view = view;
            this._dynamicProperties = new Dictionary <string, Property <TProperty> >();

            this.RefreshDynamicControl(yLabels);
        }
Beispiel #19
0
        public override void Execute(ListLogicalView view)
        {
            using (view.BatchSelection())
            {
                var selection = view.SelectedEntities;

                var toSelect = view.Data.Except(selection).ToArray();

                selection.Clear();
                foreach (var item in toSelect) { selection.Add(item); }
            }
        }
 public override void Execute(ListLogicalView view)
 {
     var dg = new OpenFileDialog();
     if (dg.ShowDialog() == true)
     {
         var fileName = dg.FileName;
         var attachement = view.AddNew(true) as FileAttachement;
         attachement.FileName = Path.GetFileName(fileName);
         attachement.UploadDate = DateTime.Today;
         attachement.ContentBytes = File.ReadAllBytes(fileName);
     }
 }
Beispiel #21
0
 public override void Execute(ListLogicalView view)
 {
     if (view.Filter != null)
     {
         view.Filter = null;
         this.Label = this.Meta.Label;
     }
     else
     {
         view.Filter = this.CanShow;
         this.Label = "显示全部";
     }
 }
Beispiel #22
0
        public override void Execute(ListLogicalView view)
        {
            var list = RF.Find<UserLoginLog>().GetAll()
                .OfType<UserLoginLog>()
                .ToList();

            var control = new LoginLogStatistic(list);
            App.Windows.ShowDialog(control, w =>
            {
                w.Title = "登录时间统计".Translate();
                w.MinHeight = 300;
                w.SizeToContent = SizeToContent.WidthAndHeight;
            });
        }
Beispiel #23
0
        public override void Execute(ListLogicalView view)
        {
            this._view = view;

            var input = TextBoxItemGenerator.GetTextBoxParameter(this);
            if (string.IsNullOrEmpty(input))
            {
                view.Filter = null;
            }
            else
            {
                view.Filter = e => this.CanShow(e, input);
            }
        }
Beispiel #24
0
        public override void Execute(ListLogicalView view)
        {
            //弹出窗体显示详细面板
            this.Template.EntityType = view.EntityType;
            var ui = this.Template.CreateUI();

            var detailView = ui.MainView.CastTo<DetailLogicalView>();
            detailView.Data = view.Current;

            App.Windows.ShowDialog(ui.Control, w =>
            {
                w.Buttons = ViewDialogButtons.Close;
                w.Title = this.Meta.Label.Translate() + " " + view.Meta.Label.Translate();
            });
        }
Beispiel #25
0
        /// <summary>
        /// 为某个实体类型生成逻辑视图。
        /// </summary>
        /// <param name="entityViewInfo">实体类的视图元数据</param>
        /// <returns></returns>
        public ListLogicalView CreateListView(WPFEntityViewMeta entityViewInfo, bool isLookup = false)
        {
            var view = new ListLogicalView(entityViewInfo);

            if (isLookup)
            {
                view.ShowInWhere = ListShowInWhere.DropDown;
            }

            this.InitListView(view);

            this.OnViewCreated(view);

            return(view);
        }
Beispiel #26
0
        public override void Execute(ListLogicalView view)
        {
            //调用服务端查询库中的所有书籍量
            var svc = ServiceFactory.Create<CountServerBookJsonService>();
            svc.Invoke();
            App.MessageBox.Show("库中一共有书籍:" + svc.BookCount + "本。");

            //view.Data = null;//清空列表数据
            //view.DataLoader.ReloadDataAsync();//重新查询列表的数据
            //view.Data = RF.Create<BookCategory>().GetAll();//指定列表的数据
            //view.Current = view.Data[0];//选中第一行。
            //view.Filter = e => (e as BookCategory).Name.Contains("人文");//过滤
            //var newEntity = view.AddNew(true);//添加一行新数据
            ////其它....
        }
Beispiel #27
0
        public override void Execute(ListLogicalView view)
        {
            var category = view.CreateNewItem() as TaskOrCategory;

            category.MonthPercent = 0;
            category.MonthScore = 0;

            view.Data.Add(category);

            view.RefreshControl();

            view.Current = category;

            CommandsHelper.EditCurrent(view);
        }
Beispiel #28
0
        protected override void OnUIGenerated(ControlResult ui)
        {
            base.OnUIGenerated(ui);

            this._planView = ui.MainView as ListLogicalView;
            this._taskView = this._planView.GetChildView(typeof(TaskOrCategory)) as ListLogicalView;
            this._weekCompletionView = this._taskView.GetChildView(typeof(WeekCompletion)) as ListLogicalView;
            var weekNoteView = this._planView.GetChildView(typeof(WeekNote)) as ListLogicalView;

            MPHelper.ModifyRowStyle(this._taskView, "TaskViewRowStyle");
            MPHelper.ModifyRowStyle(this._weekCompletionView, "CurrentWeekRowStyle");
            MPHelper.ModifyRowStyle(weekNoteView, "CurrentWeekRowStyle");

            this.ChangeTaskCompletionVisibility();

            this.AddWeekNotesOnPlan();
        }
Beispiel #29
0
        /// <summary>
        /// 从view中把所有实体对象的数据转换为需要导出Excel的表格数据。
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        protected DataTable FindTableData(ListLogicalView view)
        {
            DataTable table = new DataTable();

            var tableColumns = new Dictionary <string, WPFEntityPropertyViewMeta>();

            //使用定义来定义表的列。
            foreach (var property in this._properties)
            {
                var label = property.Label;

                //使用空格来防止出现空列名及同名。
                if (string.IsNullOrWhiteSpace(label))
                {
                    label = " ";
                }
                while (tableColumns.ContainsKey(label))
                {
                    label += " ";
                }

                tableColumns[label] = property;

                table.Columns.Add(label);
            }

            //导出实体数据。
            var list = this.FindModels(view);

            foreach (var model in list)
            {
                this._currentRow = model;
                var row = table.NewRow();

                foreach (var kv in tableColumns)
                {
                    row[kv.Key] = this.ReadProperty(kv.Value);
                }

                table.Rows.Add(row);
            }

            return(table);
        }
Beispiel #30
0
        public override void Execute(ListLogicalView view)
        {
            //创建一个临时的拷贝数据
            var tmp = view.CreateNewItem();

            var evm = view.Meta;
            var result = PopupEditingDialog(evm, tmp, w =>
            {
                w.Title = this.Meta.Label.Translate() + " " + evm.Label.Translate();
            });

            //如果没有点击确定,则删除刚才添加的记录。
            if (result == WindowButton.Yes)
            {
                //先添加一行记录
                var curEntity = view.AddNew(false);

                var oldTreeCode = string.Empty;
                object oldTreePId = null;
                if (evm.EntityMeta.IsTreeEntity)
                {
                    oldTreeCode = curEntity.TreeIndex;
                    oldTreePId = curEntity.TreePId;
                }

                curEntity.Clone(tmp, new CloneOptions(
                    CloneActions.NormalProperties | CloneActions.RefEntities
                    ));

                //如果用户没有设置树型编码,则把树型编码还原到 Clone 之前系统自动生成的编码
                if (!string.IsNullOrEmpty(oldTreeCode) &&
                    string.IsNullOrEmpty(curEntity.TreeIndex) &&
                    view.Data.AutoTreeIndexEnabled)
                {
                    curEntity.TreeIndex = oldTreeCode;
                    curEntity.TreePId = oldTreePId;
                }

                this.OnDataCloned(curEntity, tmp);

                view.RefreshControl();
                view.Current = curEntity;
            }
        }
Beispiel #31
0
        protected override void Complete(ListLogicalView view)
        {
            if (this._firstSelection != null)
            {
                view.RefreshControl();

                view.Current = this._firstSelection;

                var treeGrid = view.Control.CastTo<RafyTreeGrid>();
                var amountColumn = treeGrid.FindColumnByProperty(ProductRefItem.AmountProperty);

                var row = treeGrid.FindRow(this._firstSelection);
                if (row != null)
                {
                    var cell = row.ScrollToCell(amountColumn);
                    treeGrid.TryEditRow(row, cell);
                }
            }
        }
        public override void Execute(ListLogicalView view)
        {
            var dataList = view.Data;
            var isTree = dataList.SupportTree;
            var selectedItems = view.SelectedEntities.ToArray();
            for (int i = selectedItems.Length - 1; i >= 0; i--)
            {
                var selectedItem = selectedItems[i];

                //如果是树形,则级联删除所有子节点
                if (isTree)
                {
                    var node = selectedItem as ITreeComponent;
                    var parent = node.TreeComponentParent;
                    if (parent.ComponentType == TreeComponentType.NodeList)
                    {
                        dataList.Remove(selectedItem);
                    }
                    else if (parent.ComponentType == TreeComponentType.TreeChildren)
                    {
                        var parentList  = parent as Entity.EntityTreeChildren;
                        parentList.Remove(selectedItem);
                    }
                }
                else
                {
                    dataList.Remove(selectedItem);
                }
            }

            if (dataList.Count > 0)
            {
                view.Current = dataList[0] as Entity;
            }
            else
            {
                view.Current = null;
            }

            view.RefreshControl();
        }
Beispiel #33
0
        public override void Execute(ListLogicalView view)
        {
            //据说这个也不错,有时间的时候可以尝试下:http://npoi.codeplex.com/

            this._properties = new List <WPFEntityPropertyViewMeta>();
            this.DefineTable(this._properties, view.Meta);

            var dialog = new SaveFileDialog
            {
                FileName = view.Meta.Label + ".xls",
                Filter   = "excel files (*.xls)|*.xls"
            };
            var result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    string fileName = dialog.FileName;
                    if (string.Compare(Path.GetExtension(fileName), ".xls", true) != 0)
                    {
                        App.MessageBox.Show("扩展名不对!".Translate());
                        return;
                    }

                    var table = this.FindTableData(view);

                    var saver = ExcelHelper.CreateSaver();
                    saver.SaveToFile(table, fileName);

                    Process.Start(fileName);
                }
                catch (Exception ex)
                {
                    App.MessageBox.Show("保存出错。".Translate() + Environment.NewLine + ex.Message.Translate());
                }
            }
        }
Beispiel #34
0
        public override void Execute(ListLogicalView view)
        {
            //据说这个也不错,有时间的时候可以尝试下:http://npoi.codeplex.com/

            this._properties = new List<WPFEntityPropertyViewMeta>();
            this.DefineTable(this._properties, view.Meta);

            var dialog = new SaveFileDialog
            {
                FileName = view.Meta.Label + ".xls",
                Filter = "excel files (*.xls)|*.xls"
            };
            var result = dialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                try
                {
                    string fileName = dialog.FileName;
                    if (string.Compare(Path.GetExtension(fileName), ".xls", true) != 0)
                    {
                        App.MessageBox.Show("扩展名不对!".Translate());
                        return;
                    }

                    var table = this.FindTableData(view);

                    var saver = ExcelHelper.CreateSaver();
                    saver.SaveToFile(table, fileName);

                    Process.Start(fileName);
                }
                catch (Exception ex)
                {
                    App.MessageBox.Show("保存出错。".Translate() + Environment.NewLine + ex.Message.Translate());
                }
            }
        }
Beispiel #35
0
        /// <summary>
        /// 验证所有的数据。返回是否成功。
        /// </summary>
        /// <param name="listView"></param>
        /// <returns></returns>
        protected virtual bool ValidateData(ListLogicalView listView)
        {
            var list = listView.Data;

            if (listView.IsShowingTree)
            {
                var error = list.EachNode(item =>
                {
                    var brokenRules = item.Validate();
                    if (brokenRules.Count > 0)
                    {
                        var msg = string.Format("节点索引为 {0} 的数据验证不通过:\r\n{1}".Translate(), item.TreeIndex, brokenRules.ToString());
                        App.MessageBox.Show(msg, "保存出错".Translate());
                        return true;
                    }
                    return false;
                });
                return error == null;
            }
            else
            {
                for (int i = 0, c = list.Count; i < c; i++)
                {
                    var item = list[i];
                    var brokenRules = item.Validate();
                    if (brokenRules.Count > 0)
                    {
                        var msg = string.Format("第 {0} 行数据验证不通过:\r\n{1}".Translate(), i + 1, brokenRules.ToString());
                        App.MessageBox.Show(msg, "保存出错".Translate());
                        return false;
                    }
                }
            }

            return true;
        }
 public override bool CanExecute(ListLogicalView view)
 {
     return view.Current != null;
 }
Beispiel #37
0
 /// <summary>
 /// 从view中找出所有的模型。
 /// </summary>
 /// <param name="view"></param>
 /// <returns></returns>
 protected virtual IList <Entity> FindModels(ListLogicalView view)
 {
     return(view.Data);
 }
Beispiel #38
0
        public override void Execute(ListLogicalView view)
        {
            this._view = view;

            base.Execute(view);
        }