SQL Server 2017, как преобразовать определенные строки в заголовок столбца?

Вы должны вызвать этот метод из обработчика события рисования, а не только в любое удобное для вас время. Таким образом, в вашем конструкторе может быть:

panel1.Paint += new PaintEventHandler(panel1_Paint);

, а затем реализация:

    private void panel1_Paint( object sender, PaintEventArgs e )
    {
        var p = sender as Panel;
        var g = e.Graphics;

        g.FillRectangle( new SolidBrush( Color.FromArgb( 0, Color.Black ) ), p.DisplayRectangle );

        Point[] points = new Point[4];

        points[0] = new Point( 0, 0 );
        points[1] = new Point( 0, p.Height );
        points[2] = new Point( p.Width, p.Height);
        points[3] = new Point( p.Width, 0 );

        Brush brush = new SolidBrush( Color.DarkGreen );

        g.FillPolygon( brush, points );
    }
0
задан Victor_Tlepshev 18 March 2019 в 16:47
поделиться

1 ответ

Благодаря. Я добавил еще один столбец IDENTITY 'x' во временную таблицу, после чего получил следующее:

DECLARE @tempVal varchar(255), @intMin INT, @intMax INT, @tempAlphaVal varchar(15)

-- Assigning the first value in the dataset -- starting the loop
SET @intMin = (SELECT MIN(x) FROM #Temp_CSV_Import)

-- Assigning the last value in the dataset -- stoping the loop
SET @intMax = (SELECT Max(x) FROM #Temp_CSV_Import)

-- adding another column to the table
ALTER TABLE #Temp_CSV_Import ADD alpha varchar(15);

WHILE (@intMin <= @intMax)
BEGIN   
    -- find the value of column a in row @intMin
    SET @tempVal = (SELECT a FROM #Temp_CSV_Import WHERE x = @intMin)   

    -- check to see if the value has alpha  
    IF(@tempVal LIKE '%alpha%') 
        BEGIN           
            -- parse the string to get the number -- until the next alpha use this number
            SET @tempAlphaVal = (SELECT SUBSTRING(@tempVal, CHARINDEX(' ', @tempVal) +1, 20))           
        END
    ELSE
        BEGIN   
            -- update apha with the temp value in @tempAlphaVal     
            UPDATE #Temp_CSV_Import SET alpha = @tempAlphaVal WHERE x = @intMin
        END

    -- increment @intMin
    SET @intMin = @intMin + 1                   
END

-- lastly delete the alpha row since we do not need it anymore.
DELETE FROM #Temp_CSV_Import WHERE alpha is null

SELECT * FROM #Temp_CSV_Import
0
ответ дан Victor_Tlepshev 18 March 2019 в 16:47
поделиться
Другие вопросы по тегам:

Похожие вопросы: