private bool EditQueryChangeCallback(object context)
        {
            SqlDataSource first = (SqlDataSource) ((Pair) context).First;
            DataSourceOperation second = (DataSourceOperation) ((Pair) context).Second;
            IServiceProvider site = first.Site;
            IDesignerHost service = (IDesignerHost) site.GetService(typeof(IDesignerHost));
            SqlDataSourceDesigner sqlDataSourceDesigner = (SqlDataSourceDesigner) service.GetDesigner(first);
            ParameterCollection originalParameters = null;
            string command = string.Empty;
            SqlDataSourceCommandType text = SqlDataSourceCommandType.Text;
            switch (second)
            {
                case DataSourceOperation.Delete:
                    originalParameters = first.DeleteParameters;
                    command = first.DeleteCommand;
                    text = first.DeleteCommandType;
                    break;

                case DataSourceOperation.Insert:
                    originalParameters = first.InsertParameters;
                    command = first.InsertCommand;
                    text = first.InsertCommandType;
                    break;

                case DataSourceOperation.Select:
                    originalParameters = first.SelectParameters;
                    command = first.SelectCommand;
                    text = first.SelectCommandType;
                    break;

                case DataSourceOperation.Update:
                    originalParameters = first.UpdateParameters;
                    command = first.UpdateCommand;
                    text = first.UpdateCommandType;
                    break;
            }
            SqlDataSourceQueryEditorForm form = new SqlDataSourceQueryEditorForm(site, sqlDataSourceDesigner, first.ProviderName, sqlDataSourceDesigner.ConnectionString, second, text, command, originalParameters);
            if (UIServiceHelper.ShowDialog(site, form) != DialogResult.OK)
            {
                return false;
            }
            PropertyDescriptor descriptor = null;
            switch (second)
            {
                case DataSourceOperation.Delete:
                    descriptor = TypeDescriptor.GetProperties(first)["DeleteCommand"];
                    break;

                case DataSourceOperation.Insert:
                    descriptor = TypeDescriptor.GetProperties(first)["InsertCommand"];
                    break;

                case DataSourceOperation.Select:
                    descriptor = TypeDescriptor.GetProperties(first)["SelectCommand"];
                    break;

                case DataSourceOperation.Update:
                    descriptor = TypeDescriptor.GetProperties(first)["UpdateCommand"];
                    break;
            }
            if (descriptor != null)
            {
                descriptor.ResetValue(first);
                descriptor.SetValue(first, form.Command);
            }
            return true;
        }
        private bool EditQueryChangeCallback(object context)
        {
            SqlDataSource         first   = (SqlDataSource)((Pair)context).First;
            DataSourceOperation   second  = (DataSourceOperation)((Pair)context).Second;
            IServiceProvider      site    = first.Site;
            IDesignerHost         service = (IDesignerHost)site.GetService(typeof(IDesignerHost));
            SqlDataSourceDesigner sqlDataSourceDesigner = (SqlDataSourceDesigner)service.GetDesigner(first);
            ParameterCollection   originalParameters    = null;
            string command = string.Empty;
            SqlDataSourceCommandType text = SqlDataSourceCommandType.Text;

            switch (second)
            {
            case DataSourceOperation.Delete:
                originalParameters = first.DeleteParameters;
                command            = first.DeleteCommand;
                text = first.DeleteCommandType;
                break;

            case DataSourceOperation.Insert:
                originalParameters = first.InsertParameters;
                command            = first.InsertCommand;
                text = first.InsertCommandType;
                break;

            case DataSourceOperation.Select:
                originalParameters = first.SelectParameters;
                command            = first.SelectCommand;
                text = first.SelectCommandType;
                break;

            case DataSourceOperation.Update:
                originalParameters = first.UpdateParameters;
                command            = first.UpdateCommand;
                text = first.UpdateCommandType;
                break;
            }
            SqlDataSourceQueryEditorForm form = new SqlDataSourceQueryEditorForm(site, sqlDataSourceDesigner, first.ProviderName, sqlDataSourceDesigner.ConnectionString, second, text, command, originalParameters);

            if (UIServiceHelper.ShowDialog(site, form) != DialogResult.OK)
            {
                return(false);
            }
            PropertyDescriptor descriptor = null;

            switch (second)
            {
            case DataSourceOperation.Delete:
                descriptor = TypeDescriptor.GetProperties(first)["DeleteCommand"];
                break;

            case DataSourceOperation.Insert:
                descriptor = TypeDescriptor.GetProperties(first)["InsertCommand"];
                break;

            case DataSourceOperation.Select:
                descriptor = TypeDescriptor.GetProperties(first)["SelectCommand"];
                break;

            case DataSourceOperation.Update:
                descriptor = TypeDescriptor.GetProperties(first)["UpdateCommand"];
                break;
            }
            if (descriptor != null)
            {
                descriptor.ResetValue(first);
                descriptor.SetValue(first, form.Command);
            }
            return(true);
        }