private void Button1_Click(object sender, EventArgs e)
        {
            var baseSql = $"create proc {nameTextBox.Text} (";

            foreach (DataGridViewRow row in procedureParametersDataGrid.Rows)
            {
                if (!row.IsNewRow)
                {
                    baseSql += $"@{row.Cells["ParameterName"].Value} {row.Cells["DataType"].Value},";
                }
            }

            var newSql = baseSql.Remove(baseSql.Length - 1);

            newSql += $") as {procedureDefinitionTextBox.Text}";

            var ddlViewer = new DdlViewer(baseSql);

            ddlViewer.ShowDialog();

            if (ddlViewer.DialogResult != DialogResult.OK)
            {
                return;
            }
            CurrentInformation.ConnectionProperties.Connection.Execute(baseSql);
            TreeViewConnectionBootstrapper.Init(CurrentInformation.ConnectionProperties, TreeView);
        }
Ejemplo n.º 2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            string baseSql = $"create view {nameTextBox.Text} as {sqlTextBox.Text}";


            var ddlViewer = new DdlViewer(baseSql);

            ddlViewer.ShowDialog();

            if (ddlViewer.DialogResult != DialogResult.OK)
            {
                return;
            }
            CurrentInformation.ConnectionProperties.Connection.Execute(baseSql);
            TreeViewConnectionBootstrapper.Init(CurrentInformation.ConnectionProperties, TreeView);
        }
Ejemplo n.º 3
0
        private void DeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sql = "";

            if (CurrentInformation.ObjectType.Equals("Connection"))
            {
                CurrentInformation.Connections.RemoveAll(connection => connection.Name == CurrentInformation.ObjectName);
                return;
            }

            if (CurrentInformation.ObjectType.Equals("Table"))
            {
                sql = $"drop table {CurrentInformation.ObjectName}";
            }
            else if (CurrentInformation.ObjectType.Equals("Trigger"))
            {
                sql = $"drop trigger {CurrentInformation.ObjectName}";
            }
            else if (CurrentInformation.ObjectType.Equals("Function"))
            {
                sql = $"drop function {CurrentInformation.ObjectName}";
            }
            else if (CurrentInformation.ObjectType.Equals("StoredProcedure"))
            {
                sql = $"drop proc {CurrentInformation.ObjectName}";
            }
            else if (CurrentInformation.ObjectType.Equals("View"))
            {
                sql = $"drop view {CurrentInformation.ObjectName}";
            }

            var ddlViewer = new DdlViewer(sql);

            ddlViewer.ShowDialog();

            if (ddlViewer.DialogResult == DialogResult.OK)
            {
                CurrentInformation.ConnectionProperties.Connection.Execute(sql);
                connectionsTreeView.Nodes.Remove(connectionsTreeView.SelectedNode);
            }
        }
Ejemplo n.º 4
0
        private void Button1_Click(object sender, EventArgs e)
        {
            var baseSql = $"create table {nameTextBox.Text} (";

            foreach (DataGridViewRow row in tableDefinitionDataGrid.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }
                baseSql += $"{row.Cells["FieldName"].Value} {row.Cells["DataType"].Value}";
                if (row.Cells["NotNull"].Value != null && (bool)row.Cells["NotNull"].Value)
                {
                    baseSql += " NOT NULL";
                }

                if (row.Cells["PrimaryKey"].Value != null && (bool)row.Cells["PrimaryKey"].Value)
                {
                    baseSql += " PRIMARY KEY";
                }

                baseSql += ",";
            }

            baseSql += ");";

            var ddlViewer = new DdlViewer(baseSql);

            ddlViewer.ShowDialog();

            if (ddlViewer.DialogResult != DialogResult.OK)
            {
                return;
            }
            CurrentInformation.ConnectionProperties.Connection.Execute(baseSql);
            TreeViewConnectionBootstrapper.Init(CurrentInformation.ConnectionProperties, TreeView);
            tableDefinitionDataGrid.DataSource = null;
        }