Exemplo n.º 1
0
        private void Save(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbxTitle.Text) || string.IsNullOrEmpty(tbxTitle.Text))
            {
                tbxTitle.Focus();
                CMessageBox.Show(Owner, "项目名称或命名空间必须填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            this.Visible = false;
            TreeFrm treeFrm = new TreeFrm(_Owner, this);

            //treeFrm.TopMost = true;
            treeFrm.TopLevel = false;   //这个必须有不然会提示:"不能向tabControl中添加顶级控件"
            //treeFrm.Dock = DockStyle.Fill;
            treeFrm.UpdateProjectNode(Project);
            Helpler.ChangeTitle(false, treeFrm);
            _Owner.mainTab.TabPages.Add(treeFrm.Text);
            //treeFrm.FormBorderStyle = FormBorderStyle.None;
            foreach (Control con in treeFrm.Controls)
            {
                con.Dock = DockStyle.None;
                _Owner.mainTab.TabPages[_Owner.mainTab.TabPages.Count - 1].Controls.Add(con);
                _Owner.mainTab.SelectedIndex = _Owner.mainTab.TabPages.Count - 1;
            }
            // treeFrm.Show();
            // treeFrm.mod
            //tabControl1.TabPages[0].Controls.Add(form);
            this.Close();
        }
Exemplo n.º 2
0
        public void PasteNode()
        {
            _Modified = true;
            Helpler.ChangeTitle(false, this);

            if (_CurrentNode == Nodes.Project && (_ClipboardTable != null)) //table 直接加入,因为带有下面的列数据
            {
                operation = ChangeTypes.None;
                Table table = _ClipboardTable;
                table.Name = table.Name;
                TreeNode tviTable = new TreeNode();
                _CurrentTreeViewItem.Nodes.Add(tviTable);
                tviTable.Tag  = table;
                tviTable.Text = table.Title + "[" + table.Name + "]";

                foreach (Col col in table.Cols)
                {
                    TreeNode tviCol = new TreeNode();
                    tviTable.Nodes.Add(tviCol);
                    tviTable.Expand();
                    tviCol.Tag  = col;
                    tviCol.Text = col.Title + "[" + col.Name + "]";
                }

                _Project.Tables.Add(table);
            }
            else if (_CurrentNode == Nodes.Table && (_ClipboardCol != null))  //列加入的时候,确认一下
            {
                operation = ChangeTypes.AddCol;
                Col col = _ClipboardCol;
                col.Name       = col.Name;
                _uiCol.Project = _Project;
                _uiCol.Col     = col;
            }
        }
Exemplo n.º 3
0
        public void DeleteNode()
        {
            if (CMessageBox.Show(_Owner, "是否删除当前节点", "请确认", MessageBoxButtons.OKCancel,
                                 MessageBoxIcon.Question) == DialogResult.Cancel)
            {
                return;
            }
            _Modified = true;
            Helpler.ChangeTitle(false, this);
            if (_CurrentNode == Nodes.Table)
            {
                Table table = _CurrentTreeViewItem.Tag as Table;

                operation = ChangeTypes.DropTable;
                WriteSqlLog(null, null); //没有col,但有当前 table,通过 ChangeTypes.DropTable 删除表

                TreeNode parentTV = _CurrentTreeViewItem.Parent as TreeNode;
                parentTV.Nodes.Remove(_CurrentTreeViewItem);
                _Project.Tables.Remove(table);
                CMessageBox.Show(_Owner, "删除成功!", "提示");
            }
            else if (_CurrentNode == Nodes.Col)
            {
                Col col = _CurrentTreeViewItem.Tag as Col;

                operation = ChangeTypes.DropCol;
                WriteSqlLog(col, null);  //删除列

                TreeNode parentTV = _CurrentTreeViewItem.Parent as TreeNode;
                parentTV.Nodes.Remove(_CurrentTreeViewItem);
                Table table = parentTV.Tag as Table;
                table.Cols.Remove(col);
                CMessageBox.Show(_Owner, "删除成功!", "提示");
            }
        }
Exemplo n.º 4
0
        public void UpdateColNode(Col col)
        {
            _Modified = true;
            Helpler.ChangeTitle(false, this);
            if (_CurrentTreeViewItem.Tag is Col)
            {
                _CurrentTreeViewItem.Tag  = col;
                _CurrentTreeViewItem.Text = col.Title + "[" + col.Name + "]";
            }
            else if (_CurrentTreeViewItem.Tag is Table)
            {
                Table table  = _CurrentTreeViewItem.Tag as Table;
                int   insPos = table.Cols.Count;
                if (insPos >= 9)   //懒人列
                {
                    insPos = insPos - 8;
                }
                table.Cols.Insert(insPos, col);

                TreeNode tviCol = new TreeNode();
                _CurrentTreeViewItem.Nodes.Insert(insPos, tviCol);

                _CurrentTreeViewItem.Expand();//IsExpanded = true;
                tviCol.Tag  = col;
                tviCol.Text = col.Title + "[" + col.Name + "]";
            }
        }
Exemplo n.º 5
0
 private void btn_save_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(tbxNamespace.Text))
     {
         tbxNamespace.Focus();
         CMessageBox.Show(_Owner, "命名空间不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     this.Visible = false;
     treeFrm      = new treeFrm(_Owner, this);
     treeFrm.Show();
     treeFrm.UpdateProjectNode(Project);
     Helpler.ChangeTitle(false, treeFrm);
     this.Close();
 }
Exemplo n.º 6
0
        public void SaveProject()
        {
            //_Project = treeProject.Tag as Project;
            if (Project == null)
            {
                //MessageBox.Show("", "错误");
                CMessageBox.Show(this, "没有项目文件,请新建或者载入");
                return;
            }

            if (string.IsNullOrEmpty(projectPath))
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName = Project.Namespace + ".xml";
                dlg.Filter   = "Xml文件|*.xml";

                Nullable <bool> result = dlg.ShowDialog();

                if (result == true)
                {
                    projectPath = dlg.FileName;
                }
                else
                {
                    return;
                }
            }

            try
            {
                Project.SaveProject(projectPath);
                _treeFrm._Modified = false;
                Helpler.ChangeTitle(true, _treeFrm);
                _treeFrm.projectPath = projectPath;
                CMessageBox.Show(this, "项目保存成功");
            }
            catch (Exception ex)
            {
                CMessageBox.Show(this, "文件保存失败:\r\n\r\n\t" + ex.Message);
            }
        }
Exemplo n.º 7
0
        public void UpdateTableNode(Table table)
        {
            _Modified = true;
            Helpler.ChangeTitle(false, this);
            if (_CurrentTreeViewItem.Tag is Table) //表示修改
            {
                _CurrentTreeViewItem.Tag  = table;
                _CurrentTreeViewItem.Text = table.Title + "[" + table.Name + "]";
            }
            else //新建的时候加入默认列
            {
                _Project.Tables.Add(table);

                TreeNode tviTable = new TreeNode();
                _CurrentTreeViewItem.Nodes.Add(tviTable);
                //_CurrentTreeViewItem.IsExpanded = true;
                _CurrentTreeViewItem.Expand();
                tviTable.Tag  = table;
                tviTable.Text = table.Title + "[" + table.Name + "]";

                //CreateDefaultCol(tviTable, table);
            }
        }