1. Список говнокодов пользователя Karasb

    Всего: 3

  2. C# / Говнокод #2853

    +118.4

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    //Находит строку и возвращает строку под ней
    public string FindRowUnder(string str)
    {
         string nextRes = string.Empty;
         var res = _oSheet.get_Range("A1", "Z100").Find(str,...);
         if (!String.IsNullOrEmpty(res))
         {
              int iCol = Convert.ToInt32(_oSheet.get_Range("A1", "Z100").Find(str...).Column);
              int iRow = Convert.ToInt32(_oSheet.get_Range("A1", "Z100").Find(str...).Row);
              iRow++;
              nextRes = _oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2.ToString();
         }
         return nextRes;
    }
    
    //  Находит строку и забирает 2 строки  под ней
    public string FindDoubleRowUnder(string str)
    {
          string res = _oSheet.get_Range("A1", "F100").Find(str...).Value2.ToString();
          if (!String.IsNullOrEmpty(res))
          {
              int iCol = Convert.ToInt32(_oSheet.get_Range("A1", "F100").Find(str...).Column);
              int iRow = Convert.ToInt32(_oSheet.get_Range("A1", "F100").Find(str...).Row);
              iRow = iRow + 1;
              if (_oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2 != null)
              {
                   nextRes = _oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2.ToString();
              }
              iRow++;
              if (_oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2 != null)
              {
                   nextRes += " " + _oSheet.get_Range(Alfabet.Substring(iCol - 1, 1) + iRow, Type.Missing).Value2;
              }
         }
         return nextRes.Trim();
    }
    
    //  Находит строку и забирает 3 строки  под ней
    public string FindTripleRowUnder(string str)
    {
         ... думаю писать не стоит так как там почти то же самое, что и выше
    }

    Интересно, когда надо будет получить 4 или 5 строк товарищ будет писать еще один метод?

    Karasb, 24 Марта 2010

    Комментарии (3)
  3. SQL / Говнокод #2818

    −132.6

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    SELECT [IdPart],
    			[num],
    			NameRus AS PartName,
    			Rests, 
    			Income, 
    			Defect, 
    			Rests +ISNULL([1],0) [1], 
    			Rests +ISNULL([1],0)+ISNULL([2],0) [2], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0) [3], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0) [4], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0) [5], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)[6], 
    			...
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)[11], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)[12], 
                            ...
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)[22], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)[23], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)[24], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)[25], 
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)+ ISNULL([26],0)[26], 
    			...
    			Rests +ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ ISNULL([15],0)+ ISNULL([16],0)+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)+ ISNULL([26],0)+ ISNULL([27],0)+ ISNULL([28],0)+ISNULL([29],0)+ISNULL([30],0)+ISNULL([31],0)[31]
    			, Rests+Income-Defect + ISNULL([1],0)+ ISNULL([2],0)+ ISNULL([3],0)+ ISNULL([4],0)+ ISNULL([5],0)+ ISNULL([6],0)+ ISNULL([7],0)+ ISNULL([8],0)+ ISNULL([9],0)+ ISNULL([10],0)+ ISNULL([11],0)+ ISNULL([12],0)+ ISNULL([13],0)+ ISNULL([14],0)+ [15]+ [16]+ ISNULL([17],0)+ ISNULL([18],0)+ ISNULL([19],0)+ ISNULL([20],0)+ ISNULL([21],0)+ ISNULL([22],0)+ ISNULL([23],0)+ ISNULL([24],0)+ ISNULL([25],0)+ ISNULL([26],0)+ISNULL([27],0)+ISNULL([28],0)+ISNULL([29],0)+ISNULL([30],0)+ISNULL([31],0) AS TotalExpence
    		FROM
    	(
    .....

    Типа нарастающий итог. Ну слов просто нет. ИМХО, это что-то из разряда использовать микроскоп для забивания гвоздей.

    Karasb, 18 Марта 2010

    Комментарии (4)
  4. SQL / Говнокод #2674

    −154.7

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    WITH days(num, aday) AS 
    (
    	SELECT 1 AS num, 1 AS aday
    	UNION ALL 
    	SELECT num, aday+1 AS aday FROM days
    	WHERE days.[aday] < DAY( DATEADD(DAY, -DAY(@date), DATEADD(MONTH, 1 , @date)))
    )
    	SELECT     SUM(day1) AS d1, SUM(day2) AS d2, SUM(day3) AS d3, SUM(day4) AS d4, SUM(day5) AS d5, SUM(day6) AS d6, SUM(day7) AS d7, SUM(day8) AS d8, 
    						  SUM(day9) AS d9, SUM(day10) AS d10, SUM(day11) AS d11, SUM(day12) AS d12, SUM(day13) AS d13, SUM(day14) AS d14, SUM(day15) AS d15, 
    						  SUM(day16) AS d16, SUM(day17) AS d17, SUM(day18) AS d18, SUM(day19) AS d19, SUM(day20) AS d20, SUM(day21) AS d21, SUM(day22) AS d22, 
    						  SUM(day23) AS d23, SUM(day24) AS d24, SUM(day25) AS d25, SUM(day26) AS d26, SUM(day27) AS d27, SUM(day28) AS d28, SUM(day29) AS d29, 
    						  SUM(day30) AS d30, SUM(day31) AS d31
    	FROM         (SELECT     CASE aday WHEN 1 THEN 1 ELSE 0 END AS day1, CASE aday WHEN 2 THEN 2 ELSE 0 END AS day2, 
    												  CASE aday WHEN 3 THEN 3 ELSE 0 END AS day3, CASE aday WHEN 4 THEN 4 ELSE 0 END AS day4, 
    												  CASE aday WHEN 5 THEN 5 ELSE 0 END AS day5, CASE aday WHEN 6 THEN 6 ELSE 0 END AS day6, 
    												  CASE aday WHEN 7 THEN 7 ELSE 0 END AS day7, CASE aday WHEN 8 THEN 8 ELSE 0 END AS day8, 
    												  CASE aday WHEN 9 THEN 9 ELSE 0 END AS day9, CASE aday WHEN 10 THEN 10 ELSE 0 END AS day10, 
    												  CASE aday WHEN 11 THEN 11 ELSE 0 END AS day11, CASE aday WHEN 12 THEN 12 ELSE 0 END AS day12, 
    												  CASE aday WHEN 13 THEN 13 ELSE 0 END AS day13, CASE aday WHEN 14 THEN 14 ELSE 0 END AS day14, 
    												  CASE aday WHEN 15 THEN 15 ELSE 0 END AS day15, CASE aday WHEN 16 THEN 16 ELSE 0 END AS day16, 
    												  CASE aday WHEN 17 THEN 17 ELSE 0 END AS day17, CASE aday WHEN 18 THEN 18 ELSE 0 END AS day18, 
    												  CASE aday WHEN 19 THEN 19 ELSE 0 END AS day19, CASE aday WHEN 20 THEN 20 ELSE 0 END AS day20, 
    												  CASE aday WHEN 21 THEN 21 ELSE 0 END AS day21, CASE aday WHEN 22 THEN 22 ELSE 0 END AS day22, 
    												  CASE aday WHEN 23 THEN 23 ELSE 0 END AS day23, CASE aday WHEN 24 THEN 24 ELSE 0 END AS day24, 
    												  CASE aday WHEN 25 THEN 25 ELSE 0 END AS day25, CASE aday WHEN 26 THEN 26 ELSE 0 END AS day26, 
    												  CASE aday WHEN 27 THEN 27 ELSE 0 END AS day27, CASE aday WHEN 28 THEN 28 ELSE 0 END AS day28, 
    												  CASE aday WHEN 29 THEN 29 ELSE 0 END AS day29, CASE aday WHEN 30 THEN 30 ELSE 0 END AS day30, 
    												  CASE aday WHEN 31 THEN 31 ELSE 0 END AS day31
    						   FROM          days) AS col

    Думаю в комментариях не нуждается T_T.

    Karasb, 26 Февраля 2010

    Комментарии (0)