1. C# / Говнокод #3873

    +111

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    /// ----------------------------------------------------------------------------- 
    /// <summary> 
    /// Page_Load runs when the control is loaded 
    /// </summary> 
    /// ----------------------------------------------------------------------------- 
    protected void Page_Load(object sender, System.EventArgs e)
    {
       ...
    }

    да ну!! серьезно что-ли???

    Coffeeholic, 04 Августа 2010

    Комментарии (14)
  2. C# / Говнокод #3871

    +113

    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
    const string newObjectName = "Новый объект";
    
            // формирует имя нового объекта
            string BuildNewObjectName()
            {
                var namesTaken = from node in objectAdapters where node.Name.Contains(newObjectName) select node.Name;
    
                int n = 0;
    
                // ищем максимальное число в конце имени
                if (namesTaken.Any())
                    n = namesTaken.Aggregate(n, (acc, name) =>
                        {
                            int current;
                            return (int.TryParse(name.Split().Last(), out current) && current > acc) ? current : acc;
                        });
    
                // возвращаем следующее
                return newObjectName + " " + (n+1).ToString();
            }

    Получение имени для нового объекта. Смесь различных техник. Не читаемо.

    Lehox, 04 Августа 2010

    Комментарии (1)
  3. C# / Говнокод #3868

    +113

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (((productOrder.DataSet).ProductOrder[0].RowState != DataRowState.Deleted) &&
                    (productOrder.DataSet).ProductOrder[0].IsOrderReferenceNull() &&
                    WebOrderType.IsIngestion() &&
                    (ingestOrder != null) && (ingestOrder.IngestOrder.Count > 0) &&
                    !(ingestOrder).IngestOrder[0].IsOrderReferenceNull()){
                    (productOrder.DataSet).ProductOrder[0].OrderReference =
                        (ingestOrder).IngestOrder[0].OrderReference;
                }

    Eugene, 04 Августа 2010

    Комментарии (2)
  4. C# / Говнокод #3854

    +105

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    str_sql = " select convert(varchar(6),e.id) as  equipment_id,e.name as name,1 as is_check  " +
                              "         ,(select count(t2.id) from equipment t2 where t2.parent_id=e.id) count_child" +
                              " from equipment e " +
                              " where isnull(e.parent_id,0)=" + e.Node.Value +
                              "       and id in (select cod from f_DisplayEqipmentContract_nodes_2(" + str_contract + "))";

    а вот так мы собираем sql запрос

    madnezz, 02 Августа 2010

    Комментарии (31)
  5. C# / Говнокод #3853

    +119

    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
    List<ArestDates> dates = new List<ArestDates>();
       ...
       ...
      #region Sort by ArestDate
            
                for (int i = 1; i < dates.Count; i++)
                {
                    for (int j = i + 1; j <= dates.Count; j++)
                    {
                        if (dates[j - 1].ArestDate < dates[i - 1].ArestDate)
                        {
                            ArestDates ads = dates[j - 1];
    
                            dates[j - 1] = dates[i - 1];
                            dates[i - 1] = ads;
                        }
                    }
                }

    Крутая сортировка :) по заявлению автора :) вместо этого ---
    dates.Sort((x, y) => DateTime.Compare(x.ArestDate, y.ArestDate)); ???

    David_M, 02 Августа 2010

    Комментарии (9)
  6. C# / Говнокод #3851

    +119

    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
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    namespace WF_Map1
    {
        public partial class Form1 : Form
        {
    
            int count = 0;
    
            public Form1()
            {
                Control.CheckForIllegalCrossThreadCalls = false;
                InitializeComponent();
    
                MoveImg X = new MoveImg(LetsMove);
                AsyncCallback cb = new AsyncCallback(End);
                IAsyncResult ar = X.BeginInvoke(5, 5, ref pictureBox1, ref count, cb, new object[] { });
            }
    
            static void LetsMove(int x, int y, ref PictureBox pic1, ref int count)
            {
    
                test:
    
                using (MySqlConnection mysqlConn = new MySqlConnection("Host = localhost; User Id = root; Password = 1234;"))
                {
                    try
                    {
                        mysqlConn.Open();
    
                        using (MySqlCommand mysqlCmd = new MySqlCommand("use move; SELECT * FROM `move`.`test` LIMIT " + count + ", 1;", mysqlConn))
                        {
    
                            MySqlDataReader Dr = mysqlCmd.ExecuteReader();
                        
                            while (Dr.Read())
                            {
                                if (Convert.ToInt32(Dr["x"]) > 25 && Convert.ToInt32(Dr["y"]) > 25) break;
    
                                pic1.Location = new Point(Convert.ToInt32(Dr["x"]), Convert.ToInt32(Dr["y"]));
                                count++;
                            }
    
                            mysqlCmd.Dispose();
                            Thread.Sleep(1000);
                        }
                    }
                    catch
                    {
    
                    }
                    finally
                    {
                        mysqlConn.Clone();
                    }
    
                    goto test;
                }
            }
    
            void End(IAsyncResult ar)
            {
                MoveImg X = (MoveImg)((AsyncResult)ar).AsyncDelegate;
                X.EndInvoke(ref pictureBox1, ref count, ar);
            }
    
            delegate void MoveImg(int x, int y, ref PictureBox pic1, ref int count);
        }
    }

    Вот так вот мы создали перемещение :)))))

    с "goto" - убивает на корню )))))))

    sergylens, 02 Августа 2010

    Комментарии (42)
  7. C# / Говнокод #3844

    +102

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    public static void Attack()
    {
         while (true)
          {
                new Thread(new ThreadStart(Attack)).Start();                
          }
    }

    АтакЭ ))))

    Nigma143, 01 Августа 2010

    Комментарии (10)
  8. C# / Говнокод #3837

    +101

    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
    43. 43
    44. 44
    using (MySqlConnection mysqlConn = new MySqlConnection(connStr))
                {
                    try
                    {
                        mysqlConn.Open();
    
                        Type Dbs = typeof(DbState);
    
                        foreach(string s in Enum.GetNames(Dbs))
                        {
                            Console.WriteLine(s + " : " + Enum.Format(Dbs, Enum.Parse(Dbs, s), "d"));
                        }
    
                        using (MySqlCommand mysqlCmd = new MySqlCommand("use oleg;", mysqlConn))
                        {
                            try
                            {
                                mysqlCmd.ExecuteNonQuery();
    
                                using (fact obj = new fact())
                                {
                                    for (int i = 0; i < 10; i++)
                                    {
                                        using (MySqlCommand _mysqlCmd = new MySqlCommand("use oleg; insert into recursion_data values(null, " + obj.rec(i) + ");", mysqlConn))
                                        {
                                            _mysqlCmd.ExecuteNonQuery();
                                        }
                                    }
                                }
                            }
                            catch (Exception exc)
                            {
                                Console.WriteLine(exc.Message);
                            }
                        }
                    }
                    catch (Exception exc)
                    {
                        Console.WriteLine(exc.Message);
                    }
                    finally
                    {
                        mysqlConn.Close();
                    }

    sergylens, 31 Июля 2010

    Комментарии (9)
  9. C# / Говнокод #3830

    +102

    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
    private static string GetRootedCurrentConfigurationFile(string configurationFile)
    {
    if (string.IsNullOrEmpty(configurationFile))
    {
    throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "configurationFile");
    }
    if (!File.Exists(configurationFile))
    {
    throw new FileNotFoundException(string.Format(CultureInfo.CurrentCulture, Resources.ExceptionConfigurationLoadFileNotFound, new object[] { configurationFile }));
    }
    if (!Path.IsPathRooted(configurationFile))
    {
    return Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configurationFile);
    }
    return configurationFile;
    }

    Собснно Говнокод by Microsoft (Ent Lib 5.0.414.0)

    TrueLauncher, 30 Июля 2010

    Комментарии (12)
  10. C# / Говнокод #3829

    +115

    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
    public static string GetTable(int type, string title, string[][] rows)
    {
        bool flag2;
        int num;
        bool isEmpty = false;
        string str = "";
        switch (type)
        {
            case 1:
                str = str + "\r\n                            <div class='clear'> </div>\r\n\t\t\r\n\t\t                        <div class='down'>\r\n                                \r\n\t\t\t\t\t                <div class='ProperyDetailHeading'>\r\n\t\t\t\t\t\t                <span class='color2'>" + title + "</span>\r\n\t\t\t\t\t                </div>\r\n\t\t\t\t\t                <div class='PropertyDetailContent'>\r\n\t\t\t\t\t\t                <div  class='PropertyDetailInformation content_inner'>\r\n\t\t\t\t\t\t\t                <table summary='Test Table'>\r\n\t\t\t\t\t\t\t\t                <tbody>";
                if ((rows != null) && (rows.Length > 0))
                {
                    flag2 = true;
                    for (num = 0; num < rows.Length; num++)
                    {
                        if ((rows[num] != null) && (rows[num].Length > 0))
                        {
                            str = str + GetTableRow(ref flag2, rows[num][0], rows[num][1], ref isEmpty);
                        }
                    }
                }
                break;
            case 2:
    ......

    ASP.NET, пакистанские кодеры. Вообще весь код с сайта можна поместить на сайте отдельным разделом. В проекте вообще не используются контролы типа DataGrid/FormView.. даже DataSource. У них и тэмплэйты свои :(.. Грустно так все...(

    Coffeeholic, 30 Июля 2010

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