15 Ocak 2011 Cumartesi

Aero Style Forms

        #region ----- Aero Form

 

        [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]

        public struct MARGINS

        {

            public int Left;

            public int Right;

            public int Top;

            public int Bottom;

        }

 

        private MARGINS margins;

        [System.Runtime.InteropServices.DllImport("dwmapi.dll", PreserveSig = false)]

        public static extern void DwmExtendFrameIntoClientArea

                        (IntPtr hwnd, ref MARGINS margins);

 

        [System.Runtime.InteropServices.DllImport("dwmapi.dll", PreserveSig = false)]

        public static extern bool DwmIsCompositionEnabled();

 

        protected override void OnLoad(EventArgs e)

        {

            base.OnLoad(e);

            if (DwmIsCompositionEnabled())

            {

                // Paint the glass effect.

                margins = new MARGINS();

                margins.Top = 50;

                DwmExtendFrameIntoClientArea(this.Handle, ref margins);

            }

        }

 

        protected override void OnPaintBackground(PaintEventArgs e)

        {

            base.OnPaint(e);

            if (DwmIsCompositionEnabled())

            {

                // paint background black to enable include glass regions

 

                e.Graphics.Clear(Color.Black);

                // revert the non-glass rectangle back to it's original colour

 

                Rectangle clientArea = new Rectangle(

                        margins.Left,

                        margins.Top,

                        this.ClientRectangle.Width - margins.Left - margins.Right,

                        this.ClientRectangle.Height - margins.Top - margins.Bottom

                    );

                Brush b = new SolidBrush(this.BackColor);

                e.Graphics.FillRectangle(b, clientArea);

            }

        }

 

        #endregion

 

13 Ocak 2011 Perşembe

RowNumber ve Sayfalama

SELECT ROW_NUMBER() OVER(ORDER BY Name) as 'Row Number', Name,[Type] FROM @test

 

Row Number     Name    Type

1              Film        normal

2              Film        normal

3              Film        Korku

4              Film        Savas

5              Film        Savas

6              Film        Savas

7              Film        Savas

8              Film        Komedi

9              Film        Komedi

10           Film        Komedi

11           Müzik    Pop

12           Müzik    Pop

13           Müzik    Rock

14           Müzik    Hard Rock

15           Müzik    Hard Rock

16           Müzik    Hard Rock

17           Müzik    Metal

18           Müzik    Metal

 

;WITH test as

(

      SELECT      ROW_NUMBER() OVER(ORDER BY Name) as 'Rows',

                  Name,

                  [Type]

                  FROM @test

)

 

SELECT * FROM test WHERE [Rows] BETWEEN 3 AND 7

 

Rows     Name    Type

3              Film        Korku

4              Film        Savas

5              Film        Savas

6              Film        Savas

7              Film        Savas

 

SELECT RowNumber= identity(int,1,1), Name,[Type] INTO #tmp

                  FROM @test

 

SELECT * FROM #tmp WHERE RowNumber BETWEEN 10 AND 15

DROP TABLE #tmp

 

RowNumber      Name    Type

10           Film        Komedi

11           Müzik    Pop

12           Müzik    Pop

13           Müzik    Rock

14           Müzik    Hard Rock

15           Müzik    Hard Rock

cube ve rollup ile Toplam hesaplamak

 

DECLARE @test TABLE

(

      ID    int identity(1,1),

      [Type] nvarchar(100),

      Name nvarchar(100)

)

 

INSERT INTO @test VALUES( 'normal','Film' )

INSERT INTO @test VALUES( 'normal','Film' )

INSERT INTO @test VALUES( 'Korku','Film' )

INSERT INTO @test VALUES( 'Savaş','Film' )

INSERT INTO @test VALUES( 'Savaş','Film' )

INSERT INTO @test VALUES( 'Savaş','Film' )

INSERT INTO @test VALUES( 'Savaş','Film' )

INSERT INTO @test VALUES( 'Komedi','Film' )

INSERT INTO @test VALUES( 'Komedi','Film' )

INSERT INTO @test VALUES( 'Komedi','Film' )

INSERT INTO @test VALUES( 'Pop','Müzik' )

INSERT INTO @test VALUES( 'Pop','Müzik' )

INSERT INTO @test VALUES( 'Rock','Müzik' )

INSERT INTO @test VALUES( 'Hard Rock','Müzik' )

INSERT INTO @test VALUES( 'Hard Rock','Müzik' )

INSERT INTO @test VALUES( 'Hard Rock','Müzik' )

INSERT INTO @test VALUES( 'Metal','Müzik' )

INSERT INTO @test VALUES( 'Metal','Müzik' )

 

 

 

 

SELECT COUNT(ID) as Count, Name FROM @test GROUP BY Name

 

Count Name

10    Film

8     Müzik

 

SELECT COUNT(ID), COALESCE(Name,'Toplam') FROM @test GROUP BY Name with cube

Count Name

10    Film

8     Müzik

18    Toplam

 

 

SELECT COUNT(ID) as Count,Type, Name FROM @test GROUP BY [Type],Name with cube

Count    Type      Name

3              Komedi                Film

1              Korku    Film

2              normal  Film

4              Savas     Film

10           NULL     Film

3              Hard Rock            Müzik

2              Metal    Müzik

2              Pop        Müzik

1              Rock      Müzik

8              NULL     Müzik

18           NULL     NULL

3              Hard Rock            NULL

3              Komedi                NULL

1              Korku    NULL

2              Metal    NULL

2              normal  NULL

2              Pop        NULL

1              Rock      NULL

4              Savas     NULL

 

SELECT COUNT(ID) as Count, Name FROM @test GROUP BY Name with rollup

Count    Name

10           Film

8              Müzik

18           NULL

 

SELECT COUNT(ID) as Count,Type, Name FROM @test GROUP BY [Type],Name with rollup

 

Count    Type      Name

3              Hard Rock            Müzik

3              Hard Rock            NULL

3              Komedi                Film

3              Komedi                NULL

1              Korku    Film

1              Korku    NULL

2              Metal    Müzik

2              Metal    NULL

2              normal  Film

2              normal  NULL

2              Pop        Müzik

2              Pop        NULL

1              Rock      Müzik

1              Rock      NULL

4              Savas     Film

4              Savas     NULL

18           NULL     NULL

 

SELECT COUNT(ID) as Count,[Type], Name FROM @test GROUP BY rollup([Type],Name)

SELECT COUNT(ID) as Count,[Type], Name FROM @test GROUP BY cube([Type],Name)