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

    +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
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    private void button2_Click(object sender, EventArgs e)
            {
     
            int n1 = Convert.ToInt16(textBox1.Text);
            int n2 = Convert.ToInt16(textBox4.Text);
            int n3 = Convert.ToInt16(textBox7.Text);
            int n4 = Convert.ToInt16(textBox10.Text);
            int n5 = Convert.ToInt16(textBox13.Text);
            int n6 = Convert.ToInt16(textBox16.Text);
            int n7 = Convert.ToInt16(textBox19.Text);
            int n8 = Convert.ToInt16(textBox22.Text);
     
            int b1 = Convert.ToInt16(textBox2.Text);
            int b2 = Convert.ToInt16(textBox5.Text);
            int b3 = Convert.ToInt16(textBox8.Text);
            int b4 = Convert.ToInt16(textBox11.Text);
            int b5 = Convert.ToInt16(textBox14.Text);
            int b6 = Convert.ToInt16(textBox17.Text);
            int b7 = Convert.ToInt16(textBox20.Text);
            int b8 = Convert.ToInt16(textBox23.Text);
     
            int c1 = Convert.ToInt16(textBox3.Text);
            int c2 = Convert.ToInt16(textBox6.Text);
            int c3 = Convert.ToInt16(textBox9.Text);
            int c4 = Convert.ToInt16(textBox12.Text);
            int c5 = Convert.ToInt16(textBox15.Text);
            int c6 = Convert.ToInt16(textBox18.Text);
            int c7 = Convert.ToInt16(textBox21.Text);
            int c8 = Convert.ToInt16(textBox24.Text);
     
            int ii, S2, S1, ti, ip, iip, iis, dp, ds, n;
                /*Индекс инфляции ii=S2/S1,
                *Темп инфляции ti=ii-1
                *простых процентов iip=((1+n*ip)*ii-1)/n
                 * для сложных iis=(1+is)nii(1/n)-1
                 * Реальная доходность простые% dp=(n*iip+1-ii)/ii
                 * Реальная доходность сложные% ds=(1+iis)/ii(1/n)-1
                 * сумма всей корзины S1 и S2
                 */
            S1 = n1 * b1 + n2 * b2 + n3 * b3 + n4 * b4 + n5 * b5 + n6 * b6 + n7 * b7 + n8 * b8;// сумма S1
            S2 = n1 * c1 + n2 * c2 + n3 * c3 + n4 * c4 + n5 * c5 + n6 * c6 + n7 * c7 + n8 * c8;// сумма S2
     
            ii = S2 / S1; // индекс инфляции
     
            ti = ii - 1; // темп инфляции
                
                n= n1+n2+n3+n4+n5+n6+n7+n8; // n= общее кол-во товаров и услуг
                iip = ((1 + n * ip) * ii - 1) / n;

    Diman3241, 28 Сентября 2015

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

    +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
    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
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    StringBuilder errorMessage = new StringBuilder();
    int i = 0, j = 0;
    bool outcome = true;
    double value;
    string[] label = new string[] { label1.Text, label2.Text, label4.Text };
    
    textBox1.Text = textBox1.Text.Trim();
    textBox2.Text = textBox2.Text.Trim();
    textBox3.Text = textBox3.Text.Trim();
    
    foreach (string field in (new string[] { textBox1.Text, textBox2.Text, textBox3.Text }))
    {
    	try
    	{
    		if (field.Length == 0)
    			throw new Exception("отсутствует значение.\n");
    
    		if (j == 2)
    			value = int.Parse(field, NumberStyles.Integer);
    		else
    			value = double.Parse(field, NumberStyles.Float);
    
    		if (value <= 0)
    			throw new Exception("значение должно быть строго больше нуля.\n");
    
    		if (j == 2)
    		{
    			try
    			{
    				dateTimePicker1.Value.Date.AddMonths((int)value);
    			}
    			catch (Exception)
    			{
    				throw new Exception("превышено максимальное значение типа System.DateTime, " + DateTime.MaxValue.ToShortDateString() + ".\n" +
    									"Срок вклада не может превышать " + 
    									((DateTime.MaxValue.Year - dateTimePicker1.Value.Date.Year) * 12 +
    									DateTime.MaxValue.Month - dateTimePicker1.Value.Date.Month).ToString() + " мес. " + "от указанной даты оформления, " + dateTimePicker1.Value.Date.ToShortDateString() + ".\n");
    			}
    		}
    	}
    	catch (Exception e)
    	{
    		errorMessage.Append((++i).ToString() + ". " + label[j] + ": ");
    
    		switch (e.GetType().ToString())
    		{
    			case "System.FormatException":
    				errorMessage.AppendLine("неверный формат числа.\n");
    				break;
    
    			case "System.OverflowException":
    				{
    					if (j < 2)
    					{
    						errorMessage.AppendLine("значение не может быть обработано вещественным типом System.Double.");
    						errorMessage.AppendLine("Значение типа должно быть строго больше нуля, в промежутке (0; " + double.MaxValue.ToString() + "].\n");
    					}
    					else
    					{
    						errorMessage.AppendLine("значение не может быть обработано целочисленным типом System.Int32.");
    						errorMessage.AppendLine("Значение типа должно быть строго больше нуля, в промежутке (0; " + int.MaxValue.ToString() + "].\n");
    					}
    					break;
    				}
    
    			default:
    				errorMessage.AppendLine(e.Message);
    				break;
    		}
    
    		outcome = false;
    	}
    
    	j++;
    }

    Мастер исключений 80-го уровня.
    Хорошо, хоть не по мессаджам их разделяет.

    yamamoto, 28 Сентября 2015

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

    −1

    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 interface IApplicationUserManager { }
    
        public class ApplicationUserManager : UserManager<ApplicationUser, long>, IApplicationUserManager
        {
            private static ApplicationUserManager applicationUserManager;
            public static bool IsUserInRole(long userId, string roleName)
            {
                return applicationUserManager.UserInRole(userId, roleName);
            }
    
            public ApplicationUserManager(IAccountService accountService)
                : base(new ApplicationUserStore())
            {
                this.accountService = accountService;
                applicationUserManager = this;
            }
         }

    Проверяй, проверяй мои роли полностью...

    FreedomHex, 24 Сентября 2015

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

    +6

    1. 1
    2. 2
    3. 3
    4. 4
    if (value is Int32)
    {
        Int32 prio = Int32.Parse(value.ToString());
    }

    l1pton17, 20 Сентября 2015

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

    +2

    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
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    string[] array=new string[10];
    array[0] = "?";
    array[1] = "?";
    array[2] = "?";
    array[3] = "?";
    array[4] = "?";
    array[5] = "?";
    array[6] = "?";
    array[7] = "?";
    array[8] = "?";
    
    ....
    
    if (DS.Tables[0].Rows[i][3].ToString() == "1")
    {
    checkBox20.Checked = true;
    }
    if (DS.Tables[0].Rows[i][4].ToString() == "1")
    {
    checkBox23.Checked = true;
    }
    if (DS.Tables[0].Rows[i][5].ToString() == "1")
    {
    checkBox22.Checked = true;
    }
    if (DS.Tables[0].Rows[i][6].ToString() == "1")
    {
    checkBox25.Checked = true;
    }
    if (DS.Tables[0].Rows[i][7].ToString() == "1")
    {
    checkBox24.Checked = true;
    }
    if (DS.Tables[0].Rows[i][8].ToString() == "1")
    {
    checkBox27.Checked = true;
    }
    if (DS.Tables[0].Rows[i][9].ToString() == "1")
    {
    checkBox11.Checked = true;
    }
    
    ...
    
    if (checkBox17.Checked)
    {
    array[0] = "application/";
    }
    if (checkBox18.Checked)
    {
    array[1] = "audio/";
    }
    if (checkBox21.Checked)
    {
    array[2] = "example/";
    }
    if (checkBox20.Checked)
    {
    array[3] = "image/";
    }
    if (checkBox23.Checked)
    {
    array[4] = "message/";
    }
    if (checkBox22.Checked)
    {
    array[5] = "model/";
    }
    if (checkBox25.Checked)
    {
    array[6] = "multipart/";
    }
    if (checkBox24.Checked)
    {
    array[7] = "text/";
    }
    if (checkBox27.Checked)

    Дали на рецензию одну научную работу...

    sgerman, 18 Сентября 2015

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

    +3

    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
    public SomeLongNameSpace.PolicyPremiumReturnType ProcessPremiums(
                        int userID, 
                        int divisionID, 
                        string ObjectCode, 
                        int iPolicyID, 
                        int iBulkEndorsementID, 
                        System.Data.DataTable dtClientPremiums, 
                        System.Data.DataTable dtClientPremiumInterests, 
                        System.Data.DataTable dtRiskCommissions, 
                        System.Data.DataTable dtBrokerages, 
                        System.Data.DataTable dtDiscounts, 
                        System.Data.DataTable dtApportionments, 
                        System.Data.DataTable dtUWGroups, 
                        System.Data.DataTable dtUWGroupSettings, 
                        System.Data.DataTable dtUWGroupPremiums, 
                        System.Data.DataTable dtRiskDeclarations, 
                        System.Data.DataTable dtRiskDeclarationsInterests, 
                        int clientPaymentIntervalDays, 
                        int uwDefaultPaymentIntervalDays, 
                        int uwPaymentIntervalDays, 
                        System.Data.DataTable dtSchedulesLimitDetails, 
                        XII.Integration.GlobalXB.v1_4.PolicyGL.CommissionProcessingFlags commissionProcessingFlags, 
                        bool isOverrideWarranties, 
                        string transactionDescription, 
                        string TechnicalContactName, 
                        bool isCreateDeclarationWithoutInterests, 
                        int clientRPPaymentIntervalDays,
                        System.Data.DataTable deferredPayments)
            {
                return base.Channel.ProcessPremiums(userID, divisionID, ObjectCode, iPolicyID, iBulkEndorsementID, dtClientPremiums, dtClientPremiumInterests, dtRiskCommissions, dtBrokerages, dtDiscounts, dtApportionments, dtUWGroups, dtUWGroupSettings, dtUWGroupPremiums, dtRiskDeclarations, dtRiskDeclarationsInterests, clientPaymentIntervalDays, uwDefaultPaymentIntervalDays, uwPaymentIntervalDays, dtSchedulesLimitDetails, commissionProcessingFlags, isOverrideWarranties, transactionDescription, TechnicalContactName, isCreateDeclarationWithoutInterests, clientRPPaymentIntervalDays, deferredPayments);
            }

    few params

    g10829780, 18 Сентября 2015

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

    +1

    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
    class Program
    {
            static void Main()
            {
                UInt64 num;
                Console.WriteLine(num = F(Convert.ToUInt64(Console.ReadLine())));
                Main();
            }
    
            static UInt64 F(UInt64 number)
            {
                return number <= 0 ? 1 : number * F(number - 1);
            }
    }

    Считывание числа и выдача его факториала while(true).

    alexey_70707, 15 Сентября 2015

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

    +2

    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
    public static string Get(this HttpWebRequest req)
            {
                string res;
                string ErrorCode="";
    
                try
                {
                    ErrorCode = "100";
                    Thread.Sleep(1000);
                    HttpWebResponse response = (HttpWebResponse)req.GetResponse();
                    Thread.Sleep(1000);
                    ErrorCode = "101";
                    Stream dataStream = response.GetResponseStream();
                    ErrorCode = "102";
                    StreamReader sr = new StreamReader(dataStream, Encoding.UTF8);
                    ErrorCode = "103";
                    res = sr.ReadToEnd();
                    ErrorCode = "104";
                }
                catch
                {
                    try
                    {
                        ErrorCode = "105";
                        Thread.Sleep(1000);
                        HttpWebResponse response = (HttpWebResponse) req.GetResponse();
                        Thread.Sleep(1000);
                        ErrorCode = "106";
                        Stream dataStream = response.GetResponseStream();
                        ErrorCode = "107";
                        StreamReader sr = new StreamReader(dataStream, Encoding.UTF8);
                        ErrorCode = "108";
                        res = sr.ReadToEnd();
                        ErrorCode = "109";
                    }
                    catch
                    {
                        try
                        {
                            ErrorCode = "110";
                            Thread.Sleep(1000);
                            HttpWebResponse response = (HttpWebResponse)req.GetResponse();
                            Thread.Sleep(1000);
                            ErrorCode = "111";
                            Stream dataStream = response.GetResponseStream();
                            ErrorCode = "112";
                            StreamReader sr = new StreamReader(dataStream, Encoding.UTF8);
                            ErrorCode = "113";
                            res = sr.ReadToEnd();
                            ErrorCode = "114";
                        }
                        catch
                        {
                            res = "Error doing get to " + req.RequestUri.AbsoluteUri + " ErrorCode: " + ErrorCode;
                        }
                    }
                }
    
                return res;
            }

    Нашел в проекте код до 2010 год, автор неизвестен :(

    kiberg, 04 Сентября 2015

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

    −1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    var inited = Connectivity.Init().Result;
    inited = ServerService.Init().Result && inited;
    inited = AccountInfoService.Init().Result && inited;
    inited = InitMandatoryServices() && inited;
    
    IsInit = inited;

    vldalx, 04 Сентября 2015

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

    +12

    1. 1
    var time = startDate.ToString("MM/dd/yyyy H:mm").Split(' ')[1]; // 07/21/2007 15:07

    Надо было получить только время :D

    Tigran, 17 Августа 2015

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