Beispiel #1
0
        private DataGridViewComboBoxCell LoadCellVariables(string dataType)
        {
            var comboBoxCell = new DataGridViewComboBoxCell
            {
                ReadOnly = false
            };

            SqlDbType sqlDbType;

            try
            {
                sqlDbType = (SqlDbType)Enum.Parse(typeof(SqlDbType), dataType, true);
            }
            catch
            {
                sqlDbType = SqlDbType.NVarChar;
            }

            foreach (Variable variable in Variables)
            {
                if (variable.DataType.ToString() == SQLGoodies.ConvertFromSqlDbType(sqlDbType).Name)
                {
                    comboBoxCell.Items.Add(string.Format("@[{0}::{1}]", variable.Namespace, variable.Name));
                }
            }

            return(comboBoxCell);
        }
Beispiel #2
0
        private void grdParameters_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            switch (e.ColumnIndex)
            {
            case 3:
            {
                SqlDbType sqlDbType;
                try
                {
                    sqlDbType = (SqlDbType)Enum.Parse(typeof(SqlDbType), grdParameters.Rows[e.RowIndex].Cells[1].Value.ToString(), true);
                }
                catch
                {
                    sqlDbType = SqlDbType.NVarChar;
                }

                using (ExpressionBuilder expressionBuilder = ExpressionBuilder.Instantiate(_taskHost.Variables,
                                                                                           _taskHost.VariableDispenser,
                                                                                           SQLGoodies.ConvertFromSqlDbType(sqlDbType),
                                                                                           grdParameters.Rows[e.RowIndex].Cells[e.ColumnIndex - 1].Value.ToString()))
                {
                    if (expressionBuilder.ShowDialog() == DialogResult.OK)
                    {
                        ((DataGridViewComboBoxCell)grdParameters.Rows[e.RowIndex].Cells[e.ColumnIndex - 1]).Items.Add(expressionBuilder.Expression);
                        grdParameters.Rows[e.RowIndex].Cells[e.ColumnIndex - 1].Value = expressionBuilder.Expression;
                    }
                }
            }

            break;
            }
        }