示例#1
0
        public CatalogViewModel GetViewModel()
        {
            return this.InvokeIfRequired(() =>
            {
                if (!this.catalogId.HasValue)
                {
                    return null;
                }

                var viewModel = new CatalogViewModel();

                viewModel.SupplierName = this.textBoxCatalogName.Text;
                viewModel.Id = this.catalogId.Value;
                this.commentUserControl.Validate();
                viewModel.Comment = this.commentUserControl.Rtf;

                return viewModel;
            });
        }
 public void Display(CatalogViewModel viewModel)
 {
 }
示例#3
0
        public void Display(CatalogViewModel viewModel, IList<Task> tasks)
        {
            this.InvokeIfRequired(() =>
            {
                this.textBoxCatalogName.Text = viewModel.SupplierName;
                this.catalogId = viewModel.Id;
                if (viewModel.Comment == null || !(viewModel.Comment.StartsWith("{\\rtf") && viewModel.Comment.EndsWith("}")))
                    viewModel.Comment = "{\\rtf" + viewModel.Comment + "}";
                this.commentUserControl.Rtf = viewModel.Comment;

                foreach (var item in taskColumns)
                {
                    this.dataGridViewHardwares.Columns.Remove(item);
                }

                var orderedTasks = tasks.OrderBy(x => x.OrderId).ToList();

                this.hardwares.CatalogTasks = orderedTasks;
                taskColumns.Clear();
                foreach (var item in orderedTasks)
                {
                    var column = new DataGridViewTextBoxColumn();
                    column.HeaderText = new String(new char[]{ item.Name[0] }).ToUpper()+item.Name.Substring(1);;
                    column.Name = "task_" + item.Id;
                    column.Tag = item.Id;
                    column.ReadOnly = true;
                    column.Visible = true;
                    column.DataPropertyName = "Tasks[" + item.Id + "]";
                    this.dataGridViewHardwares.Columns.Add(column);
                    taskColumns.Add(column);
                }

                this.RefreshCategories();
                this.toolStripTextBoxSupplyFilter.Text = "";
                this.toolStripTextBoxHardwareFilter.Text = "";

                this.ApplyHardwareFilter();
                this.ApplySuppliesFilter();
            });
        }