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

    +125

    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
    /// <summary>
    		/// Конвертирование String - Decimal
    		/// </summary>
    		/// <param name="text"></param>
    		/// <param name="value"></param>
    		/// <returns></returns>
    		public static decimal GetDecimal(this string text)
    		{
    			decimal number;
    			CultureInfo culture = null;
    
    			if (String.IsNullOrEmpty(text))
    				throw new ArgumentNullException("The input string is invalid.");
    
    			try
    			{
    				culture = CultureInfo.CurrentCulture;
    				number = decimal.Parse(text, culture);
    				return number;
    			}
    			catch
    			{
    			}
    
    			try
    			{
    				culture = culture.Parent;
    				number = decimal.Parse(text, culture);
    				return number;
    			}
    			catch
    			{
    			}
    
    			culture = CultureInfo.InvariantCulture;
    			try
    			{
    				number = decimal.Parse(text, culture);
    				return number;
    			}
    
    			catch (FormatException e)
    			{
    				throw new FormatException(String.Format("Unable to parse '{0}'.", text), e);
    			}
    		}

    Это финиш.

    fr0mrus, 02 Ноября 2011

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

    +130

    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
    68. 68
    public void ExportOrderDetails()
            {
                char comma = ',';
                StringBuilder sb = new StringBuilder();
                string line = "";
    
                line += "Order No" + comma;
                line += "Customer" + comma;
                line += "Order Date" + comma;
                line += "Order Status" + comma;
                line += "Subtotal" + comma;
                line += "Tax Total" + comma;
                line += "Shipping Cost" + comma;
                line += "Shipping Method" + comma;
                line += "Order Total" + comma;
                line += "Payment Method" + comma;
                line += "Total Quantity" + comma;
                line += "Date Shipped" + comma;
                line += "Tracking No" + comma;
                line += "Order Currency Code" + comma;
                line += "Exchange Rate" + comma;
                line += "Billing First Name" + comma;
                line += "Billing Last Name" + comma;
                line += "Billing Company" + comma;
                line += "Billing Address" + comma;
                line += "Billing Address 2" + comma;
                line += "Billing City" + comma;
                line += "Billing Zip" + comma;
                line += "Billing State Code" + comma;
                line += "Billing Country ISO2" + comma;
                line += "Billing Phone" + comma;
                line += "Billing Phone 2" + comma;
                line += "Billing Email" + comma;
                line += "Shipping First Name" + comma;
                line += "Shipping Last Name" + comma;
                line += "Shipping Company" + comma;
                line += "Shipping Address" + comma;
                line += "Shipping Address 2" + comma;
                line += "Shipping City" + comma;
                line += "Shipping Zip" + comma;
                line += "Shipping State Code" + comma;
                line += "Shipping Country ISO2" + comma;
                line += "Shipping Phone" + comma;
                line += "Shipping Phone 2" + comma;
                line += "Shipping Email" + comma;
    
                line += "Combined Product Weight" + comma;
                line += "Product Qty" + comma;
                line += "Product SKU" + comma;
                line += "Product Name" + comma;
                line += "Product Variation Details" + comma;
                line += "Product Unit Price" + comma;
                line += "Product Unit Cost" + comma;
                line += "Product Weight" + comma;
                line += "Product Total Price" + comma;
                line += "Product Total Cost" + comma;
    
    
    
                sb.AppendLine(line.Remove(line.Length - 1));
     
                Response.ContentType = "application/vnd.ms-excel";
                Response.AddHeader("Content-Disposition", "attachment; filename=orders-details-" + DateTime.Now.ToString("yyyy-MM-dd") + ".csv");
                Response.ContentEncoding = Encoding.Default;
                Response.Write(sb.ToString());
                Response.End();
    
            }

    Норм так)

    sergfreest, 01 Ноября 2011

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

    +139

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (sdk.Name.ToLower().Contains("Windows Phone"))
                    {
                        WP7SDK = sdk;
                        break;
                    }

    Быстро написал, потом когда пересматривал обнаружил

    BelorusBY, 28 Октября 2011

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

    +145

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    <?xml version="1.0"?>
    -<DocumentElement> 
    	<o2p time="27.10.2011 8:00:38"/>
    	<o2p timecreate="26.10.2011 22:43:17"/> 
    	<o2p di="0.0000" g="" d="" dv="0.0000" i="8751" q="4.0000" c="C3212"/> 
    	<o2p di="0.0000" g="" d="" dv="0.0000" i="8751" q="2.0000" c="C3213"/>
    ...

    после обновления ПО в файлах выгрузки добавились строки 3-4

    nk112, 27 Октября 2011

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

    +135

    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
    static void Main(string[] args)
    {
        string[] indiaCityVisit = {
            "Delhi", "Jodhpur", "Mumbai", "Pune",  "Agra",
            "Shimla", "Bengaluru", "Mysore", "Ooty",
            "Jaipur", "Nagpur", "Amritsar", "Hyderabad",
            "Goa", "Ahmedabad" };
    
        string cities = String.Join(",", indiaCityVisit
                              .Select(s => s.ToString())
                              .ToArray());
        Console.WriteLine(cities);      
       
        Console.ReadLine();
    }

    http://www.devcurry.com/2010/12/convert-string-array-into-string-c-linq.html
    Индусы такие индусы

    roman-kashitsyn, 27 Октября 2011

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

    +124

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    private bool IsDigit(char c)
            {
                if (digitInIndicatorList.Contains(c))
                {
                    return true;
                }
                return false;
            }
    
    readonly static List<char> digitInIndicatorList = new List<char>() { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

    Неустаревающая классика...

    fr0mrus, 27 Октября 2011

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

    +118

    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
    if (true)
                {
    
                    full_result_list = this.FullTextSearch(list_without_uss, this.CountOfDocs);
                    foreach (SearchResultItem add_item in full_result_list)
                    {
                        SearchResultItem find_item = (SearchResultItem)result_list.Find(it => ((it.DocId == add_item.DocId) && (it.ModId == add_item.ModId)));
                        if (find_item != null)
                        {
                            //                                                    find_item.Relev += add_item.Relev;
                        }
                        else
                        {
                            result_list.Add(add_item);
                        }
                    }
                }

    Просто фейерично!

    f5f3e9, 26 Октября 2011

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

    +128

    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
    public class BusinessUnitDetail
    {
        public string Description { get; set; }
    }
    
    ...
    
    [TestMethod]
    public void DescriptionTest()
    {
        BusinessUnitDetail target = new BusinessUnitDetail(); 
        string expected = "test test test\n test"; 
        string actual;
        target.Description = expected;
        actual = target.Description;
        Assert.AreEqual(expected, actual);
    }

    беспощадная проверка всего и вся

    Eugene, 25 Октября 2011

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

    +116

    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
    <Grid Grid.Row="2" Margin="5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <ContentPresenter Grid.Row="0" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[0]}"/>
                <ContentPresenter Grid.Row="0" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[1]}"/>
                <ContentPresenter Grid.Row="0" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[2]}"/>
                <ContentPresenter Grid.Row="1" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[3]}"/>
                <ContentPresenter Grid.Row="1" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[4]}"/>
                <ContentPresenter Grid.Row="1" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[5]}"/>
                <ContentPresenter Grid.Row="2" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[6]}"/>
                <ContentPresenter Grid.Row="2" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[7]}"/>
                <ContentPresenter Grid.Row="2" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[8]}"/>
                <ContentPresenter Grid.Row="3" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[9]}"/>
                <ContentPresenter Grid.Row="3" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[10]}"/>
                <ContentPresenter Grid.Row="3" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[11]}"/>
                <ContentPresenter Grid.Row="4" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[12]}"/>
                <ContentPresenter Grid.Row="4" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[13]}"/>
                <ContentPresenter Grid.Row="4" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[14]}"/>
                <ContentPresenter Grid.Row="5" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[15]}"/>
                <ContentPresenter Grid.Row="5" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[16]}"/>
                <ContentPresenter Grid.Row="5" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[17]}"/>
                <ContentPresenter Grid.Row="6" Grid.Column="0" Content="{Binding ElementName=root,Path=Items[18]}"/>
                <ContentPresenter Grid.Row="6" Grid.Column="1" Content="{Binding ElementName=root,Path=Items[19]}"/>
                <ContentPresenter Grid.Row="6" Grid.Column="2" Content="{Binding ElementName=root,Path=Items[20]}"/>            
            </Grid>

    legat, 22 Октября 2011

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

    +118

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if (mainWareHouseId.HasValue && mainWareHouseId.Value.ToString() == this._locationList.SelectedValue)
    {
        return false;
    }
    else
    {
        return location == null ? true : !location.RegionalFulfillment;
    }

    abatishchev, 21 Октября 2011

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