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

    +133.9

    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
    for (int i = 0; i < gvOrderMain.RowCount - EditIndex; i++)
                                {
                                    float tempQuantity = GetRow(i).Quantity;
                                    int partyLen = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray().Length;
                                    for (int j = 0; j < partyLen; j++)
                                    {
                                        if (DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity > 0)
                                        {
                                            float CurSQuantity = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity.Value;
                                            if (tempQuantity > CurSQuantity)
                                            {
                                                Documents_Product dp = new Documents_Product();
                                                dp.PrimePriceExcVAT = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].PrimePriceExcVAT;
                                                dp.PrimePriceIncVAT = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].PrimePriceIncVAT;
                                                dp.Quantity = -1 * DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity;
                                                dp.OldQuantity = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity;
                                                dp.PartyNumber = DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].PartyNumber;
                                                DB.Documents_Products.InsertOnSubmit(dp);
                                                DB.SubmitChanges();
    
                                                Documents_ProductsOrder dro = new Documents_ProductsOrder();
                                                dro.PriceSum = GetRow(i).RealPrice * DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity;
                                                tempQuantity = tempQuantity - DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity.Value;
                                                DB.PrInStOrderByPartyNum(GetRow(i).ProductId, curStockId).ToArray()[j].Quantity = 0;
                                                DB.Documents_ProductsOrders.InsertOnSubmit(dro);
    
                                                DB.SubmitChanges();
    ..........

    Rudolf_Abel, 11 Августа 2009

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

    +131

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    List<int> arr = new List<int>();
    List<int> tmpArr = new List<int>();
    
    for (int i = 0; i < arr.Count; i++)
    {
    	if (arr[i] > 100)
    	{
    	}
    	else
    		tmpArr.Add(arr[i]);
    }
    arr = tmpArr;

    Удаляем плохие элементы со списка или кто создал дурацкий for???

    62316e, 10 Августа 2009

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

    +137.1

    1. 1
    2. 2
    3. 3
    if (Skin == null || ((Skin != null && Skin.Value == null) || (Skin != null && Skin.Value != null && Skin.Value.Length == 0))) {
    				Skin = new LocalString("...");
    			}

    проверочко.. ^_^

    fade, 10 Августа 2009

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

    +126.2

    1. 1
    2. 2
    3. 3
    if (myBool.ToString() == "true")
    {
    }

    62316e, 10 Августа 2009

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

    +132.5

    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
    public Image ResultImage
            {
                get
                {
                    return GetCut();
                }
            }
    
            private Image GetCut()
            {
                Bitmap b1 = new Bitmap(border.Width, border.Height);
    
                Bitmap b = new Bitmap(pictureBox1.Image.GetThumbnailImage(pictureBox1.Width, pictureBox1.Height, new Image.GetThumbnailImageAbort(fff), IntPtr.Zero));
                int x = border.Location.X;
                int y = border.Location.Y;
    
                int x1 = border.Location.X + border.Width;
                int y1 = border.Location.Y + border.Height;
    
                for (int i = x; i < x1; i++)
                {
                    for (int j = y; j < y1; j++)
                    {
                        b1.SetPixel(i - x, j - y, b.GetPixel(i, j));
                    }
                }
                return b1;
            }
    
            public bool fff()
            {
                return false;
            }

    Вырезка прямоугольника из битмапа.

    guest, 08 Августа 2009

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

    +151

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public virtual Type GetFields() {
        //Must be overridden!!!
        return null;
    }
    
    public virtual Enum[] GetCompareFields() {
        //Must be overridden!!!
        return null;
    }

    Про абстракиные методы нам ещё не рассказывали :-D

    guest, 07 Августа 2009

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

    +142.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
    public enum Month
      {
        Января = 1,
        Февраля = 2,
        Марта = 3,
        Апреля = 4,
        Мая = 5,
        Июня = 6,
        Июля = 7,
        Августа = 8,
        Сентября = 9,
        Октября = 10,
        Ноября = 11,
        Декабря = 12
      } 
    
    // Использование
    m_date.Text = t.Day + " " + ((Month) t.Month) + " " + t.Year;

    Одноразовый енум

    guest, 07 Августа 2009

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

    +148

    1. 1
    catch (Exception) { } // Nothing too bad hapens if we don't show next hint.

    Обработка исключений, на демке точно не скорится)

    guest, 06 Августа 2009

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

    +142.2

    1. 1
    2. 2
    3. 3
    4. 4
    void Session_Start(object sender, EventArgs e) 
     {
         Session["SessionID"] = Session.SessionID; //to avoid session regeneration
     }

    Вот так борются с устареванием сессии

    guest, 05 Августа 2009

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

    +148

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (row[0]["IsAdmin"].ToString() == "True")
    {
        return true;
    }
    else
    {
        return false;
    }

    guest, 17 Июля 2009

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