예제 #1
0
파일: FormMain.cs 프로젝트: sinxiaji/Aoite
        private void RefreshDB()
        {
            treeView1.Nodes.Clear();
            treeView1.BeginUpdate();
            var dbNode = treeView1.Nodes.Add("数据库");

            try
            {
                using (var fw = this.BeginRun("正在获取表内容..."))
                {
                    var tableNode = dbNode.Nodes.Add("表");
                    tableNode.Tag = ObjectType.Table;
                    Db.Engine.Execute("SELECT a.Name,b.Value FROM sysobjects a LEFT JOIN  sys.extended_properties b ON a.ID=b.Major_ID AND b.Minor_ID=0 WHERE a.XType='U' AND a.Name <>'sysdiagrams' ORDER BY a.Name").ToReader(reader =>
                    {
                        while (reader.Read())
                        {
                            ObjectInfo info = new ObjectInfo()
                            {
                                Type     = ObjectType.Table,
                                Name     = reader.GetString(0),
                                Comments = Convert.ToString(reader.GetValue(1))
                            };
                            tableNode.Nodes.Add(info.ToString()).Tag = info;
                        }
                    });

                    fw.Text = "正在获取视图内容...";
                    var viewNode = dbNode.Nodes.Add("视图");
                    viewNode.Tag = ObjectType.View;
                    Db.Engine.Execute("SELECT a.Name FROM sysobjects a WHERE a.XType='V' ORDER BY a.Name").ToReader(reader =>
                    {
                        while (reader.Read())
                        {
                            ObjectInfo info = new ObjectInfo()
                            {
                                Type = ObjectType.View,
                                Name = reader.GetString(0),
                            };
                            info.ClassName = info.Name;
                            if (info.ClassName.StartsWith("v_", StringComparison.CurrentCultureIgnoreCase))
                            {
                                info.ClassName = info.ClassName.Remove(0, 2);
                            }
                            viewNode.Nodes.Add(info.ToString()).Tag = info;
                        }
                    });;
                }
            }
            finally
            {
                treeView1.EndUpdate();
                dbNode.Expand();
            }
        }
예제 #2
0
파일: FormMain.cs 프로젝트: ted-feng/Aoite
        private void RefreshDB()
        {
            treeView1.Nodes.Clear();
            treeView1.BeginUpdate();
            var dbNode = treeView1.Nodes.Add("数据库");
            try
            {
                using(var fw = this.BeginRun("正在获取表内容..."))
                {
                    var tableNode = dbNode.Nodes.Add("表");
                    tableNode.Tag = ObjectType.Table;
                    Db.Engine.Execute("SELECT a.Name,b.Value FROM sysobjects a LEFT JOIN  sys.extended_properties b ON a.ID=b.Major_ID AND b.Minor_ID=0 WHERE a.XType='U' AND a.Name <>'sysdiagrams' ORDER BY a.Name").ToReader(reader =>
                    {
                        while(reader.Read())
                        {
                            ObjectInfo info = new ObjectInfo()
                            {
                                Type = ObjectType.Table,
                                Name = reader.GetString(0),
                                Comments = Convert.ToString(reader.GetValue(1))
                            };
                            tableNode.Nodes.Add(info.ToString()).Tag = info;
                        }
                    });

                    fw.Text = "正在获取视图内容...";
                    var viewNode = dbNode.Nodes.Add("视图");
                    viewNode.Tag = ObjectType.View;
                    Db.Engine.Execute("SELECT a.Name FROM sysobjects a WHERE a.XType='V' ORDER BY a.Name").ToReader(reader =>
                    {
                        while(reader.Read())
                        {
                            ObjectInfo info = new ObjectInfo()
                            {
                                Type = ObjectType.View,
                                Name = reader.GetString(0),
                            };
                            info.ClassName = info.Name;
                            if(info.ClassName.StartsWith("v_", StringComparison.CurrentCultureIgnoreCase))
                            {
                                info.ClassName = info.ClassName.Remove(0, 2);
                            }
                            viewNode.Nodes.Add(info.ToString()).Tag = info;
                        }
                    }); ;

                }
            }
            finally
            {
                treeView1.EndUpdate();
                dbNode.Expand();
            }
        }
예제 #3
0
파일: FormMain.cs 프로젝트: sinxiaji/Aoite
        private void DisplayObjectInfo(ObjectInfo info)
        {
            var code = info.GenerateCode(Db.Engine, Shared.Setting);

            new FormEditor(info.ToString(), code).ShowDialog();
        }
예제 #4
0
파일: FormMain.cs 프로젝트: ted-feng/Aoite
 private void DisplayObjectInfo(ObjectInfo info)
 {
     var code = info.GenerateCode(Db.Engine, Shared.Setting);
     new FormEditor(info.ToString(), code).ShowDialog();
 }