示例#1
0
        /// <summary>
        /// 字段显示模板窗体
        /// </summary>
        /// <param name="Grid">数据容器</param>
        /// <param name="Edit">是否为编辑模式</param>
        public frmModule(ComponentDataGrid Grid, bool Edit = false)
        {
            InitializeComponent();

            this.ShowInTaskbar = false;
            this.MaximizeBox   = false;
            this.MinimizeBox   = false;
            this.StartPosition = FormStartPosition.CenterScreen;

            _mbEdit = Edit;
            _mGrid  = Grid;

            //数据选择行
            _mDataRow = Grid.SelectedRows.Count > 0
                ? Grid.SelectedRows[0]
                : null;

            //控件排列方式
            flowLayout.FlowDirection = FlowDirection.TopDown;

            this.btnOK.Click     += BtnOK_Click;
            this.btnCancel.Click += BtnCancel_Click;

            if (_mbEdit)
            {
                this.Text = Grid.Page.Text + "---编辑";
            }
            else
            {
                this.Text = Grid.Page.Text + "---浏览";
            }
        }
示例#2
0
 public void BindingDataGrid(ComponentDataGrid grid)
 {
     DataGrid = grid;
 }
示例#3
0
        /// <summary>
        /// 初始化一个新Page
        /// </summary>
        /// <param name="Title">标题</param>
        /// <param name="Name">key名称</param>
        /// <param name="Grid">加载的数据</param>
        public ComponentDataGrid InitializeNewTabPage(string Title, string Name, DataTable Grid)
        {
            //如果存在相同名称Page
            if (TabCtrl.TabPages.ContainsKey(Name))
            {
                ComponentDataGrid finGrid = TabCtrl.TabPages[Name].Controls.OfType <ComponentDataGrid>().FirstOrDefault();
                finGrid.DataSource = Grid;
                return(finGrid);
            }

            TabPage page = ControlsHelper.NewPage(Title, Name);

            TabCtrl.TabPages.Add(page);

            ComponentToolbar toolstrip = ControlsHelper.NewToolStrip(Name);

            page.Controls.Add(toolstrip);
            toolstrip.BringToFront();

            DataTable dtColInfo = DBHelper.GetDataTable($@"select * from T_InterfaceColums where fInterfacename='{Name}'");

            bool bgenTree = false;

            if (!_mbMain)
            {
                goto NoTreeGeneral;
            }

            if (dtColInfo != null && dtColInfo.Rows.Count > 0)
            {
                DataRow[] rows = dtColInfo.Select("fInterFaceColIsTree = 1", "fnum");

                bgenTree = rows.Count() > 0
                  ? true
                  : false;

                if (bgenTree)
                {
                    Tree      = new ComponentTree();
                    Tree.Dock = DockStyle.Left;
                    page.Controls.Add(Tree);

                    ControlsHelper.CreateTree(Tree, rows, Grid);

                    EventHelper helper = new EventHelper();
                    helper.BindingTreeNodeOnClick(Tree);

                    Tree.ExpandAll();

                    Tree.BringToFront();

                    Splitter splitter = new Splitter();
                    page.Controls.Add(splitter);
                    splitter.BringToFront();
                    splitter.Dock = DockStyle.Left;
                }
            }

            //没有树结构
NoTreeGeneral:


            ComponentDataGrid dgv = ControlsHelper.NewDataGrid(Grid, dtColInfo);

            dgv.Name = Name;
            page.Controls.Add(dgv);
            dgv.Dock = DockStyle.Fill;
            dgv.BringToFront();

            dgv.BindingToolBar(toolstrip);
            dgv.BindingTabPage(page);

            toolstrip.BindingDataGrid(dgv);
            toolstrip.BindingTabPage(page);


            if (bgenTree)
            {
                Tree.BindingDataGrid(dgv);
                Tree.BindingTabPage(page);

                dgv.BindingTree(Tree);

                _mbMain = false;
            }

            return(dgv);
        }