Exemple #1
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            RegisterAccess.WriteKey("serverName", this.serverName.Text);
            RegisterAccess.WriteKey("dataBase", this.dataBase.Text);
            RegisterAccess.WriteKey("userID", this.userID.Text);
            RegisterAccess.WriteKey("passWord", this.passWord.Text);
            RegisterAccess.WriteKey("port", this.port.Text);

            if (rdbSql2000.Checked)
            {
                RegisterAccess.WriteKey("DBType", "SQLSERVER2000");
            }
            else if (rdbSQL2005.Checked)
            {
                RegisterAccess.WriteKey("DBType", "SQLSERVER2005");
            }
            else if (rdbMySQL.Checked)
            {
                RegisterAccess.WriteKey("DBType", "MYSQL");
            }
            else if (rdbOracle.Checked)
            {
                RegisterAccess.WriteKey("DBType", "ORACLE11G");
            }
            DataMarket.SetTableDataSetNull();


            this.DialogResult = DialogResult.OK;
        }
Exemple #2
0
        private void btnExecuteNoQuery_Click(object sender, EventArgs e)
        {
            if (this.txtInputArea.Text.Trim() == "")
            {
                return;
            }

            if (this.txtInputArea.Text.Trim().ToLower().StartsWith("select "))
            {
                //this.txtLog.Text = "this is a seatch sql,please using search button!";
                btnGetCode_Click(sender, e);
                return;
            }
            this.btnGetCode.Enabled = false;
            try
            {
                int count = DataMarket.ExecuteNoQuery(this.txtInputArea.Text);
                if (count < 0)
                {
                    return;
                }
                this.txtLog.Text = "execute sql success!";
            }
            catch (Exception ex)
            {
                this.txtLog.Text = string.Format("execute sql failed, reason:{0}", ex.ToString());
            }
            finally
            {
                this.btnGetCode.Enabled = true;
            }
        }
Exemple #3
0
        private void btnGetCode_Click(object sender, EventArgs e)
        {
            if (this.txtInputArea.Text.Trim() == "")
            {
                return;
            }

            if (!this.txtInputArea.Text.Trim().ToLower().StartsWith("select "))
            {
                this.txtLog.Text = "search failed!is not start with \"select\"";
                return;
            }
            this.btnGetCode.Enabled = false;
            try
            {
                DataTable dt = DataMarket.ExecuteDataTable(this.txtInputArea.Text);
                if (dt == null)
                {
                    return;
                }
                this.dgList.DataSource = dt;
                this.txtLog.Text       = string.Format("search success!get {0} rows from table", dt.Rows.Count);
            }
            catch (Exception ex)
            {
                this.txtLog.Text = string.Format("search failed, reason:{0}", ex.ToString());
            }
            finally
            {
                this.btnGetCode.Enabled = true;
            }
        }
Exemple #4
0
        private void GetCode()
        {
            DataRowView tableView = DataMarket.GetTableInfo(this.tableId);

            if (tableView == null)
            {
                return;
            }
            TableExpandDT table = new TableExpandDT(tableView);

            tableName = table.TableName;

            string      sql   = "select top 100 * from [{0}]  {1}";
            List <PKDT> pks   = table.PKs;
            string      order = table.GetOrderStr();

            sql = string.Format(sql, table.TableName, order);

            //CodeObject obj = Template.s_CodeObjects["tableinfo"];
            this.txtInputArea.Text = sql;
            this.dgList.DataSource = null;
            // this.txtDisplayArea.Text += this.txtInputArea.Text;
            //this.txtInputArea.

            ControlUtils.SetSQLColor(this.txtInputArea);
        }
Exemple #5
0
        private void AddProduce2Tree()
        {
            TreeNode childNode = new TreeNode();

            childNode.ImageIndex         = 2;
            childNode.SelectedImageIndex = 2;
            childNode.Tag = "";

            // 添加存储过程
            DataView dv = DataMarket.GetProduce();

            dv.Sort = "script";
            List <TableExpandDT> list3 = new List <TableExpandDT>();

            foreach (DataRowView drv in dv)
            {
                list3.Add(new TableExpandDT(drv));
            }
            childNode.Text = "存储过程(" + list3.Count + ")";
            foreach (TableExpandDT dt in list3)
            {
                TreeNode childNode2 = new TreeNode();
                childNode2.Text               = dt.Script;
                childNode2.Tag                = dt.Id.ToString();
                childNode2.ImageIndex         = 3;
                childNode2.SelectedImageIndex = 4;
                childNode.Nodes.Add(childNode2);
            }
            this.tvTable.Nodes.Add(childNode);
        }
Exemple #6
0
    /// <summary>
    /// 生成TemplateDT对象。
    /// </summary>
    /// <param name="tableId"></param>
    /// <returns></returns>
    public static TemplateDT CreateTemplateDT(int tableId)
    {
        DataRowView   tableView = DataMarket.GetTableInfo(tableId);
        TableExpandDT table     = new TableExpandDT(tableView);

        return(new TemplateDT(table));
    }
Exemple #7
0
        public void OnShowCode(string key)
        {
            m_ShowKey = key;
            if (this.tableId < 1)
            {
                return;
            }

            if (m_ShowKey == "tableinfo")
            {
                DataRowView   tableView = DataMarket.GetTableInfo(this.tableId);
                TableExpandDT table     = new TableExpandDT(tableView);
                if (table.TableType.Trim().ToLower() == "v" || table.TableType.Trim().ToLower() == "p")
                {
                    DBInfo();
                    return;
                }
            }
            CodeObject obj = Template.s_CodeObjects[key];

            if (obj != null)
            {
                this.SetInputText(obj.GetCode(this.tableId));
            }
        }
Exemple #8
0
        private void AddTable2Tree()
        {
            DataView dv = DataMarket.GetUserTable();

            dv.Sort = "TableName";
            List <TableExpandDT> list = new List <TableExpandDT>();

            foreach (DataRowView drv in dv)
            {
                list.Add(new TableExpandDT(drv));
            }

            TreeNode childNode = new TreeNode();

            childNode.Text               = "用户表(" + list.Count + ")";
            childNode.Tag                = "";
            childNode.ImageIndex         = 1;
            childNode.SelectedImageIndex = 1;
            TreeNode childNode2;

            foreach (TableExpandDT dt in list)
            {
                childNode2                    = new TreeNode();
                childNode2.Text               = dt.TableName + "-" + dt.Script;
                childNode2.Tag                = dt.Id.ToString();
                childNode2.ImageIndex         = 0;
                childNode2.SelectedImageIndex = 5;
                childNode.Nodes.Add(childNode2);
            }
            childNode.ExpandAll();
            this.tvTable.Nodes.Add(childNode);
        }
Exemple #9
0
        private void AddView2Tree()
        {
            TreeNode childNode = new TreeNode();

            childNode.ImageIndex         = 8;
            childNode.SelectedImageIndex = 8;
            childNode.Tag = "";

            // 添加视图
            DataView dv = DataMarket.GetView();

            dv.Sort = "script";
            List <TableExpandDT> list2 = new List <TableExpandDT>();

            foreach (DataRowView drv in dv)
            {
                list2.Add(new TableExpandDT(drv));
            }
            list2.Sort(delegate(TableExpandDT a, TableExpandDT b) { return(a.TableName.CompareTo(b.TableName)); });
            childNode.Text = "视图(" + list2.Count + ")";
            foreach (TableExpandDT dt in list2)
            {
                TreeNode childNode2 = new TreeNode();
                childNode2.Text               = dt.TableName + "-" + dt.Script;
                childNode2.Tag                = dt.Id.ToString();
                childNode2.ImageIndex         = 6;
                childNode2.SelectedImageIndex = 7;
                childNode.Nodes.Add(childNode2);
            }
            this.tvTable.Nodes.Add(childNode);
        }
Exemple #10
0
    /// <summary>
    /// 取得外键描述字段。
    /// </summary>
    /// <param name="fkColumn"></param>
    /// <returns></returns>
    public ColumnDT GetFKTEXTColumnInfo(string fkColumn)
    {
        string      name = this.GetFKTextColumn(fkColumn);
        DataRowView drv  = DataMarket.GetColumn(this.TableName, name);

        return(new ColumnDT(drv));
    }
Exemple #11
0
    public static List <ColumnDT> GetAllColumns()
    {
        DataView        dv   = DataMarket.GetUserTable();
        List <ColumnDT> list = new List <ColumnDT>();

        foreach (DataRowView drv in dv)
        {
            list.AddRange((new TableExpandDT(drv)).Columns);
        }
        return(list);
    }
Exemple #12
0
        public void DBInfo()
        {
            if (this.tableId < 1)
            {
                this.SetInputText("");
                return;
            }
            string content = this.GetTableInfo(this.tableId);

            content += "\r\n\r\n\r\n" + DataMarket.GetPVAFContent(this.tableId);
            this.SetInputText(content);
        }
Exemple #13
0
    public void PrintAll()
    {
        DataView          dv   = DataMarket.GetUserTable();
        List <TemplateDT> list = new List <TemplateDT>();

        foreach (DataRowView drv in dv)
        {
            list.Add(TemplateDT.CreateTemplateDT(drv));
        }

        foreach (TemplateDT detail in list)
        {
            PrintCode(detail);
        }
    }
Exemple #14
0
        private void btnCSV_Click(object sender, EventArgs e)
        {
            if (this.txtInputArea.Text.Trim() == "")
            {
                return;
            }

            if (!this.txtInputArea.Text.Trim().ToLower().StartsWith("select "))
            {
                this.txtLog.Text = "export failed!is not start with \"select\"";
                return;
            }
            this.btnGetCode.Enabled = false;
            try
            {
                DataTable dt = DataMarket.ExecuteDataTable(this.txtInputArea.Text);
                if (dt == null)
                {
                    return;
                }

                //this.directoryEntry1..sho.show
                this.sfCSV.Filter           = "CSV文件|*.CSV";
                this.sfCSV.InitialDirectory = folder;
                this.sfCSV.FileName         = tableName + DateTime.Now.ToString("_yyyyMMddHHmmSS");
                if (this.sfCSV.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    folder = this.sfCSV.InitialDirectory;
                    string fileName = this.sfCSV.FileName;
                    SaveCSV(dt, fileName);
                }
                this.txtLog.Text = string.Format("save success!get {0} rows from table", dt.Rows.Count);
            }
            catch (Exception ex)
            {
                this.txtLog.Text = string.Format("save failed, reason:{0}", ex.ToString());
            }
            finally
            {
                this.btnGetCode.Enabled = true;
            }
        }
Exemple #15
0
    public static string GetSQLConfigText()
    {
        DataView             dv   = DataMarket.GetUserTable();
        List <TableExpandDT> list = new List <TableExpandDT>();

        foreach (DataRowView drv in dv)
        {
            list.Add(new TableExpandDT(drv));
        }

        StringBuilder sb = new StringBuilder();

        sb.Append("<?xml version=\"1.0\"?>" + "\r\n");
        sb.Append("<SQL-List>" + "\r\n");
        sb.Append(GetAllCode("SQLXML"));
        sb.Append("</SQL-List>" + "\r\n");
        return(sb.ToString());
    }
Exemple #16
0
        public void SetTableID(int id)
        {
            this.tableId = id;

            if (this.tableId > 0)
            {
                // 设置数据库表列显示信息
                DataRowView tableView = DataMarket.GetTableInfo(this.tableId);
                if (tableView == null)
                {
                    return;
                }
                TableExpandDT table = new TableExpandDT(tableView);
                this.dgvColumns.AutoGenerateColumns = false;
                this.dgvColumns.DataSource          = table.Columns;
            }
            else
            {
                this.dgvColumns.DataSource = null;
            }
        }
Exemple #17
0
    /// <summary>
    /// 导出所有的类。
    /// </summary>
    public static string PrinterAllClass()
    {
        DataView          dv   = DataMarket.GetUserTable();
        List <TemplateDT> list = new List <TemplateDT>();

        foreach (DataRowView drv in dv)
        {
            list.Add(TemplateDT.CreateTemplateDT(drv));
            //Template.PrinterClassForTable(drv);
        }

        foreach (TemplateDT detail in list)
        {
            //Template.PrinterClassForTable(detail);
            foreach (CodeObject obj in s_CodeObjects.Values)
            {
                obj.PrintCode(detail);
            }
        }
        return("../../Code/Tables");
    }
Exemple #18
0
    private static string GetAllCode(string key)
    {
        DataView             dv   = DataMarket.GetUserTable();
        List <TableExpandDT> list = new List <TableExpandDT>();

        foreach (DataRowView drv in dv)
        {
            list.Add(new TableExpandDT(drv));
        }

        StringBuilder sb  = new StringBuilder();
        CodeObject    obj = s_CodeObjects[key];

        if (obj == null)
        {
            return("");
        }
        foreach (TableExpandDT detail in list)
        {
            sb.Append(obj.GetCode(detail.Id));
        }
        return(sb.ToString());
    }
Exemple #19
0
    public static DataTable GetPKTable()
    {
        DataView             dv   = DataMarket.GetUserTable();
        List <TableExpandDT> list = new List <TableExpandDT>();

        foreach (DataRowView drv in dv)
        {
            list.Add(new TableExpandDT(drv));
        }

        DataTable dt = new DataTable();
        DataTable dt2;

        foreach (TableExpandDT detail in list)
        {
            dt2 = detail.PKDataTable;
            if (dt2 != null)
            {
                dt.Merge(dt2);
            }
        }

        return(dt);
    }
Exemple #20
0
 public FKDT(DataRow dr)
 {
     DataMarket.ReadFKDT(this, dr);
 }
Exemple #21
0
 public TableExpandDT(DataRowView dv)
 {
     DataMarket.ReadTableDT(this, dv.Row);
 }
Exemple #22
0
 public void Bind()
 {
     this.dgTable.AutoGenerateColumns = false;
     this.dgTable.DataSource          = null;
     this.dgTable.DataSource          = DataMarket.GetAllTable();
 }
Exemple #23
0
 public ColumnDT(DataRowView dv)
 {
     DataMarket.ReadColumnDT(this, dv.Row);
 }
Exemple #24
0
 public ColumnDT(DataRowView dv, string tableCName)
 {
     this._TableCName = tableCName;
     DataMarket.ReadColumnDT(this, dv.Row);
 }
Exemple #25
0
 public PKDT(DataRowView drv)
 {
     DataMarket.ReadPKDT(this, drv.Row);
 }
Exemple #26
0
 public PKDT(DataRow dr)
 {
     DataMarket.ReadPKDT(this, dr);
 }