コード例 #1
0
        public void ComplexTest3()
        {
            _helper.ResourceNamespace = "RefBook";
            PanelViewModel panelViewModel = new PanelViewModel(_rootPanel) { ControlIdView = "clId1", RuDescription = "Комент" };
            _rootPanel.Children.Add(panelViewModel);
            GridViewModel grid = new GridViewModel(panelViewModel);

            panelViewModel.Children.Add(grid);
            grid.Children.Add(new ModalViewModel(grid) { Type = "int", FieldInDb = "field1", RuDescription = "Комент", ControlIdView = "lb1" });
            _helper.Construct(_rootPanel.Children, false);
            string result =
                "<%--Комент--%>\n<gp:CollapsePanel ID=\"clId1\" runat=\"server\" Caption=\"<%$ Resources: RefBook, clId1 %>\" SkinID=\"CollapsePanel\">\n";
            result += "<%----%>\n";
            result += "<gp:GpGridView ID=\"gvObject\" Height=\"100%\" runat=\"server\" PageSize=\"10\" ShowWhenEmpty=\"False\" SkinID=\"gpGridView\" DataKeyNames=\"id\" PagerSettings-Visible=\"true\">\n";
            result += "<Columns>\n";
            result += "<%--Комент--%>\n";
            result += "<asp:TemplateField HeaderText=\"<%$ Resources: RefBook, field1 %>\" SortExpression=\"field1\" AccessibleHeaderText=\"field1\">\n";
            result += "<ItemTemplate>\n";
            result += "<asp:Label ID=\"lb1\" runat=\"server\"><%# Eval(\"field1\")%></asp:Label>\n";
            result += "</ItemTemplate>\n";
            result += "</asp:TemplateField>\n";
            result += "</Columns>\n";
            result += "</gp:GpGridView>\n";
            result += "</gp:CollapsePanel>\n";
            Assert.AreEqual(result, _helper.ToString());
        }
コード例 #2
0
        public void OneGridTest()
        {
            GridViewModel grid = new GridViewModel(_rootPanel);
            grid.TableName = "GridTable";
            _rootPanel.Children.Add(grid);

            ModalViewModel model = new ModalViewModel(_rootPanel);
            model.FieldInDb = "Field1";
            model.Type = "int";
            grid.Children.Add(model);
            model = new ModalViewModel(_rootPanel);
            model.FieldInDb = "Field2";
            model.Type = "varchar";
            grid.Children.Add(model);
            model = new ModalViewModel(_rootPanel);
            model.FieldInDb = "Field3";
            model.Type = ControlTypes.Dictionary;
            model.DictionaryType = DictionaryTypes.FlName;
            grid.Children.Add(model);

            _helper.Construct(_properties, "../..");

            string tableContent = Utils.ReplaceSpaces(File.ReadAllText("../../GridTable.sql"));
            string expectedContent = Utils.ReplaceSpaces("CREATE TABLE [dbo].[GridTable] (\n" +
                                                         "[pkid] INT IDENTITY (1, 1)  NOT NULL,\n" +
                                                         "[fl_del] INT CONSTRAINT [DF_GridTable_del] DEFAULT ((0)) NULL,\n" +
                                                         "[idreq] INT NULL,\n" +
                                                         "[dats] datetime NOT NULL,\n" +
                                                         "[datf] datetime NOT NULL,\n" +
                                                         "[idcp] INT NULL,\n" +
                                                         "[fldchange] varchar(MAX) NULL,\n" +
                                                         "[idRecord] INT NOT NULL,\n" +
                                                         "[externalId] INT NOT NULL,\n" +
                                                         "[Field1] INT,\n" +
                                                         "[Field2] varchar(max),\n" +
                                                         "[Field3] INT,\n" +
                                                         "CONSTRAINT [PK_GridTable] PRIMARY KEY CLUSTERED([pkid] ASC),\n" +
                                                         "CONSTRAINT [FK_GridTable_id] FOREIGN KEY (idRecord) REFERENCES [GridTable_id]([pkid]),\n" +
                                                         "CONSTRAINT [FK_GridTable_Field3_fl] FOREIGN KEY (Field3) REFERENCES [fl]([pkid])\n" +
                                                         ")");
            Assert.AreEqual(expectedContent, tableContent);

            //Ид таблица
            tableContent = Utils.ReplaceSpaces(File.ReadAllText("../../GridTable_id.sql"));
            expectedContent = Utils.ReplaceSpaces("CREATE TABLE [dbo].[GridTable_id] (\n" +
                                                  "[pkid] INT IDENTITY(1, 1) NOT NULL,\n" +
                                                  "[fl_del] INT CONSTRAINT[DF_GridTable_id_del] DEFAULT((0)) NULL,\n" +
                                                  "CONSTRAINT[PK_GridTable_id] PRIMARY KEY CLUSTERED([pkid] ASC)\n" +
                                                  ")\n");
            Assert.AreEqual(expectedContent, tableContent);
        }
コード例 #3
0
ファイル: PanelViewModel.cs プロジェクト: pitchcontrol/Atom
 /// <summary>
 /// —оздать и добавить грид
 /// </summary>
 /// <returns></returns>
 public GridViewModel CreateGrid()
 {
     GridViewModel obj = new GridViewModel(this);
     Children.Add(obj);
     return obj;
 }
コード例 #4
0
 /// <summary>
 /// Добавить в дерево
 /// </summary>
 public void Build(ObservableCollection<WebPageBaseViewModel> properties)
 {
     var description = GetGroupNames();
     RootPanel root = (RootPanel)properties.First();
     //Устанавливаем базовою таблицу
     root.TableName = BaseTable;
     var grids = Grids.Where(i => i.IsGrid);
     description.ForEach((i, c) =>
     {
         var grid = grids.FirstOrDefault(j => j.Description == i);
         if (grid != null)
         {
             GridViewModel model = new GridViewModel(root);
             model.FieldInDb = "grid" + c;
             model.RuDescription = i;
             model.TableName = grid.TableName;
             root.Children.Add(model);
         }
         else
         {
             PanelViewModel model = new PanelViewModel(root) { FieldInDb = "panel" + c, RuDescription = i };
             root.Children.Add(model);
         }
     });
     Table table = _tables.ElementAt(CurrentTable);
     //Загрузка полей
     var fields =
         table.Elements<TableRow>()
             .Skip(1)
             .Select(i => new DocProperty(i.Elements<TableCell>().ElementAt(DescriptionField.Key).InnerText, i.Elements<TableCell>().ElementAt(TypeField.Key).InnerText, i.Elements<TableCell>().ElementAt(GroupName.Key).InnerText));
     int count = 0;
     foreach (DocProperty field in fields)
     {
         ModalViewModel model;
         if (string.IsNullOrEmpty(field.Parent))
         {
             model = new ModalViewModel(root);
             root.Children.Add(model);
         }
         else
         {
             //Поиск панели
             var tmp = root.Children.FirstOrDefault(i => i.RuDescription == field.Parent && i.Type == "panel" || i.Type =="grid");
             if (tmp == null)
             {
                 model = new ModalViewModel(root);
                 root.Children.Add(model);
             }
             else
             {
                 model = new ModalViewModel(tmp);
                 tmp.Children.Add(model);
                 //model.TableName = (tmp as GridViewModel)?.TableName;
             }
         }
         model.FieldInDb = "field" + count.ToString();
         model.RuDescription = field.Description;
         model.Type = field.GetRightType();
         //model.TableName = model.TableName??BaseTable;
         count++;
     }
 }
コード例 #5
0
        /// <summary>
        /// Добавить в дерево
        /// </summary>
        public void Build(ObservableCollection <WebPageBaseViewModel> properties)
        {
            var       description = GetGroupNames();
            RootPanel root        = (RootPanel)properties.First();

            //Устанавливаем базовою таблицу
            root.TableName = BaseTable;
            var grids = Grids.Where(i => i.IsGrid);

            description.ForEach((i, c) =>
            {
                var grid = grids.FirstOrDefault(j => j.Description == i);
                if (grid != null)
                {
                    GridViewModel model = new GridViewModel(root);
                    model.FieldInDb     = "grid" + c;
                    model.RuDescription = i;
                    model.TableName     = grid.TableName;
                    root.Children.Add(model);
                }
                else
                {
                    PanelViewModel model = new PanelViewModel(root)
                    {
                        FieldInDb = "panel" + c, RuDescription = i
                    };
                    root.Children.Add(model);
                }
            });
            Table table = _tables.ElementAt(CurrentTable);
            //Загрузка полей
            var fields =
                table.Elements <TableRow>()
                .Skip(1)
                .Select(i => new DocProperty(i.Elements <TableCell>().ElementAt(DescriptionField.Key).InnerText, i.Elements <TableCell>().ElementAt(TypeField.Key).InnerText, i.Elements <TableCell>().ElementAt(GroupName.Key).InnerText));
            int count = 0;

            foreach (DocProperty field in fields)
            {
                ModalViewModel model;
                if (string.IsNullOrEmpty(field.Parent))
                {
                    model = new ModalViewModel(root);
                    root.Children.Add(model);
                }
                else
                {
                    //Поиск панели
                    var tmp = root.Children.FirstOrDefault(i => i.RuDescription == field.Parent && i.Type == "panel" || i.Type == "grid");
                    if (tmp == null)
                    {
                        model = new ModalViewModel(root);
                        root.Children.Add(model);
                    }
                    else
                    {
                        model = new ModalViewModel(tmp);
                        tmp.Children.Add(model);
                        //model.TableName = (tmp as GridViewModel)?.TableName;
                    }
                }
                model.FieldInDb     = "field" + count.ToString();
                model.RuDescription = field.Description;
                model.Type          = field.GetRightType();
                //model.TableName = model.TableName??BaseTable;
                count++;
            }
        }
コード例 #6
0
 public void TurnGrid()
 {
     //Определяем положения в родительской коллекции
     var oldProperty = CurrentProperty;
     var parent = oldProperty.ParentCollection;
     int index = parent.IndexOf(CurrentProperty);
     //Удаляем панель
     parent.RemoveAt(index);
     GridViewModel model = new GridViewModel(oldProperty.Parent)
     {
         FieldInDb = oldProperty.FieldInDb,
         RuDescription = oldProperty.RuDescription,
         EnDescription = oldProperty.EnDescription
     };
     parent.Insert(index, model);
     oldProperty.Children.ForEach(i =>
     {
         //i.ParentCollection = model.Children;
         i.Parent = model;
         model.Children.Add(i);
     });
     oldProperty.Children.Clear();
     CurrentProperty = model;
 }
コード例 #7
0
 /// <summary>
 /// Добавить таблицу
 /// </summary>
 public void AddGrid()
 {
     ModalView window = new ModalView();
     GridViewModel panelViewModel = new GridViewModel(_rootPanel);
     window.DataContext = panelViewModel;
     if (window.ShowDialog() == true)
     {
         _rootPanel.Children.Add(panelViewModel);
     }
 }