Exemplo n.º 1
0
        public DbToScript(string longservername, string dbname)
        {
            InitializeComponent();
            DbName = dbname;
            dsb    = ObjHelper.CreatDsb(longservername);
            dbobj  = ObjHelper.CreatDbObj(longservername);
            this.lblServer.Text = longservername;

            List <string> dblist = dbobj.GetDBList();

            if (dblist != null)
            {
                if (dblist.Count > 0)
                {
                    foreach (string name in dblist)
                    {
                        this.cmbDB.Items.Add(name);
                    }
                }
            }
            //DataTable dt = dbobj.GetDBList();
            //if (dt != null)
            //{
            //    foreach (DataRow row in dt.Rows)
            //    {
            //        this.cmbDB.Items.Add(row["name"].ToString());
            //    }
            //}
            this.btn_Creat.Enabled = false;
            this.cmbDB.Text        = DbName;
        }
Exemplo n.º 2
0
        //创建存储过程
        private void CreatDBProc()
        {
            string projectname = this.txtProjectName.Text;
            string snamespace  = this.txtNameSpace.Text;
            string snamespace2 = this.txtNameSpace2.Text;
            string classname   = this.txtClassName.Text;
            string procPrefix  = this.txtProcPrefix.Text;
            string procTabname = this.txtTabname.Text;

            bool Maxid    = this.chk_DB_GetMaxID.Checked;
            bool Exists   = this.chk_DB_Exists.Checked;
            bool Add      = this.chk_DB_Add.Checked;
            bool Update   = this.chk_DB_Update.Checked;
            bool Delete   = this.chk_DB_Delete.Checked;
            bool GetModel = this.chk_DB_GetModel.Checked;
            bool List     = this.chk_DB_GetList.Checked;

            LTP.IDBO.IDbScriptBuilder dsb = ObjHelper.CreatDsb(servername);
            dsb.DbName      = dbname;
            dsb.TableName   = procTabname;// tablename;
            dsb.ProjectName = projectname;
            dsb.ProcPrefix  = procPrefix;
            dsb.Keys        = GetKeyFields();
            dsb.Fieldlist   = GetFieldlist();
            string strProc = dsb.GetPROCCode(Maxid, Exists, Add, Update, Delete, GetModel, List);

            SettxtContent("SQL", strProc);
        }
Exemplo n.º 3
0
        public void SetListView(DbView dbviewfrm)
        {
            #region 得到类型对象

            TreeNode selectedNode = dbviewfrm.treeView1.SelectedNode;
            if (selectedNode == null)
            {
                return;
            }
            string key;
            switch (key = selectedNode.Tag.ToString())
            {
            case "serverlist":
            case "server":
                this.servername = selectedNode.Text;
                break;

            case "db":
                this.servername = selectedNode.Parent.Text;
                this.dbname     = selectedNode.Text;
                break;

            case "table":
                this.servername = selectedNode.Parent.Parent.Parent.Text;
                this.dbname     = selectedNode.Parent.Parent.Text;
                this.tablename  = selectedNode.Text;
                this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                this.SetListViewMenu("column");
                this.BindlistViewCol(this.dbname, this.tablename);
                break;

            case "view":
                this.servername = selectedNode.Parent.Parent.Parent.Text;
                this.dbname     = selectedNode.Parent.Parent.Text;
                this.tablename  = selectedNode.Text;
                this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                this.SetListViewMenu("column");
                this.BindlistViewCol(this.dbname, this.tablename);
                break;

            case "column":
                this.servername = selectedNode.Parent.Parent.Parent.Parent.Text;
                this.dbname     = selectedNode.Parent.Parent.Parent.Text;
                this.tablename  = selectedNode.Parent.Text;
                this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                this.SetListViewMenu("column");
                this.BindlistViewCol(this.dbname, this.tablename);
                break;

            default: this.listView1.Items.Clear(); break;
            }

IL_256:
            this.SetCodeBuilders();
            this.SetFormConfig(this.servername);
            #endregion
        }
Exemplo n.º 4
0
        public void SetListView(DbView dbviewfrm)
        {
            #region 得到类型对象

            TreeNode SelNode = dbviewfrm.treeView1.SelectedNode;
            if (SelNode == null)
            {
                return;
            }
            switch (SelNode.Tag.ToString())
            {
            case "table":
            {
                servername = SelNode.Parent.Parent.Parent.Text;
                dbname     = SelNode.Parent.Parent.Text;
                tablename  = SelNode.Text;
                dbobj      = ObjHelper.CreatDbObj(servername);
                SetListViewMenu("column");
                BindlistViewCol(dbname, tablename);
            }
            break;

            case "view":
            {
                servername = SelNode.Parent.Parent.Parent.Text;
                dbname     = SelNode.Parent.Parent.Text;
                tablename  = SelNode.Text;
                dbobj      = ObjHelper.CreatDbObj(servername);
                SetListViewMenu("column");
                BindlistViewCol(dbname, tablename);
            }
            break;

            case "column":
            {
                servername = SelNode.Parent.Parent.Parent.Parent.Text;
                dbname     = SelNode.Parent.Parent.Parent.Text;
                tablename  = SelNode.Parent.Text;
                dbobj      = ObjHelper.CreatDbObj(servername);
                SetListViewMenu("column");
                BindlistViewCol(dbname, tablename);
            }
            break;

            default:
            {
                this.listView1.Items.Clear();
            }
            break;
            }
            if (dbobj != null)
            {
                cb = new CodeBuilders(dbobj);
            }
            #endregion
        }
Exemplo n.º 5
0
        //数据库脚本
        private void CreatDBScript()
        {
            this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
            LTP.IDBO.IDbScriptBuilder dsb = ObjHelper.CreatDsb(servername);
            dsb.Fieldlist = GetFieldlist();
            string strScript = dsb.CreateTabScript(dbname, tablename);

            SettxtContent("SQL", strScript);
            this.Cursor = System.Windows.Forms.Cursors.Default;
        }
Exemplo n.º 6
0
 public CodeMaker(string longServername, string DBName, string tableName)
 {
     this.InitializeComponent();
     this.InitializeForm();
     this.servername = longServername;
     this.dbname     = DBName;
     this.tablename  = tableName;
     this.dbobj      = ObjHelper.CreatDbObj(longServername);
     this.SetListViewMenu("column");
     this.BindlistViewCol(this.dbname, this.tablename);
     this.SetCodeBuilders();
     this.SetFormConfig(this.servername);
 }
Exemplo n.º 7
0
        public void SetListView(DbView dbviewfrm)
        {
            #region 得到类型对象
            TreeNode selectedNode = dbviewfrm.treeView1.SelectedNode;
            if (selectedNode == null)
            {
                return;
            }
            this.objtype = selectedNode.Tag.ToString();
            string a;
            if ((a = selectedNode.Tag.ToString()) != null)
            {
                if (a == "table" || a == "view")
                {
                    this.servername = selectedNode.Parent.Parent.Parent.Text;
                    this.dbname     = selectedNode.Parent.Parent.Text;
                    this.tablename  = selectedNode.Text;
                    this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                    this.BindlistViewCol(this.dbname, this.tablename);
                    goto IL_1B7;
                }
                if (a == "column")
                {
                    this.servername = selectedNode.Parent.Parent.Parent.Parent.Text;
                    this.dbname     = selectedNode.Parent.Parent.Parent.Text;
                    this.tablename  = selectedNode.Parent.Text;
                    this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                    this.BindlistViewCol(this.dbname, this.tablename);
                    goto IL_1B7;
                }
                if (a == "proc")
                {
                    this.servername = selectedNode.Parent.Parent.Parent.Text;
                    this.dbname     = selectedNode.Parent.Parent.Text;
                    this.tablename  = selectedNode.Text;
                    this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                    this.BindlistProcCol(this.dbname, this.tablename);
                    goto IL_1B7;
                }
            }
            this.listView1.Items.Clear();
IL_1B7:
            this.GetTableDesc();
            if (this.servername != null && this.servername.Length > 1)
            {
                this.dbset = DbConfig.GetSetting(this.servername);
            }
            #endregion
        }
Exemplo n.º 8
0
        public DbToScript(string longservername)
        {
            InitializeComponent();
            dsb   = ObjHelper.CreatDsb(longservername);
            dbobj = ObjHelper.CreatDbObj(longservername);

            int    s      = longservername.IndexOf("(");
            string server = longservername.Substring(0, s);

            this.lblServer.Text = server;

            List <string> dblist = dbobj.GetDBList();

            if (dblist != null)
            {
                if (dblist.Count > 0)
                {
                    foreach (string dbname in dblist)
                    {
                        this.cmbDB.Items.Add(dbname);
                    }
                }
            }

            //DataTable dt = dbobj.GetDBList();
            //if (dt != null)
            //{
            //    foreach (DataRow row in dt.Rows)
            //    {
            //        string dbname = row["name"].ToString();
            //        this.cmbDB.Items.Add(dbname);
            //    }
            //}
            this.btn_Creat.Enabled = false;
            if (cmbDB.Items.Count > 0)
            {
                this.cmbDB.SelectedIndex = 0;
            }
        }
Exemplo n.º 9
0
 public static CodeBuilders CreatCB(string longservername)
 {
     return(new CodeBuilders(ObjHelper.CreatDbObj(longservername)));
 }
Exemplo n.º 10
0
        public void SetListView(DbView dbviewfrm)
        {
            TreeNode selectedNode = dbviewfrm.treeView1.SelectedNode;

            if (selectedNode == null)
            {
                return;
            }
            string a;

            if ((a = selectedNode.Tag.ToString()) != null)
            {
                if (a == "server")
                {
                    this.servername = selectedNode.Text;
                    goto IL_1E6;
                }
                if (a == "table")
                {
                    this.servername = selectedNode.Parent.Parent.Parent.Text;
                    this.dbname     = selectedNode.Parent.Parent.Text;
                    this.tablename  = selectedNode.Text;
                    this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                    this.BindTablist(this.dbname);
                    goto IL_1E6;
                }
                if (a == "view")
                {
                    this.servername = selectedNode.Parent.Parent.Parent.Text;
                    this.dbname     = selectedNode.Parent.Parent.Text;
                    this.tablename  = selectedNode.Text;
                    this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                    this.BindTablist(this.dbname);
                    goto IL_1E6;
                }
                if (a == "column")
                {
                    this.servername = selectedNode.Parent.Parent.Parent.Parent.Text;
                    this.dbname     = selectedNode.Parent.Parent.Parent.Text;
                    this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                    this.BindTablist(this.dbname);
                    goto IL_1E6;
                }
                if (a == "db")
                {
                    this.servername = selectedNode.Parent.Text;
                    this.dbname     = selectedNode.Text;
                    this.dbobj      = ObjHelper.CreatDbObj(this.servername);
                    this.BindTablist(this.dbname);
                    goto IL_1E6;
                }
            }
            this.listView1.Items.Clear();
IL_1E6:
            if (this.dbobj != null)
            {
                this.cb = new CodeBuilders(this.dbobj);
                DataTable tablesExProperty = this.dbobj.GetTablesExProperty(this.dbname);
                if (tablesExProperty != null)
                {
                    try
                    {
                        DataRow[] array = tablesExProperty.Select("objname='" + this.tablename + "'");
                        if (array.Length > 0 && array[0]["value"] != null)
                        {
                            this.cb.TableDescription = array[0]["value"].ToString();
                        }
                    }
                    catch
                    {
                    }
                }
            }
            this.SetFormConfig(this.servername);
        }