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

    +121

    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
    public class IterateSQL
    {
    	private int _start = 0;
    	private int _end = 0;
    	private int number = 0;
    	private string TOP_100_PERCENT = "100 percent ";
    	private string SELECT_FROM = " SELECT*FROM (";
    	private string SELECT_TOP_I = "SELECT TOP $I * FROM(";
    	private string SELECT_TOP_F = "SELECT TOP $F * FROM(";
    	private string JOINTURE = @" WHERE maTable.id NOT IN (SELECT maTable.id FROM(";
    	private string CLOSE = ") maTable)";
    	private string SELECT_COUNT = "SELECT COUNT(*) FROM ( XYZ ) maTable";
    	private string _sql;
    	private string _where;
    	private string _parameter = string.Empty;
    	private List<string> _tempParameterList = new List<string>();
    	private Dictionary<string, object> _finalParameterList = new Dictionary<string, object>();
    
    	public IterateSQL(string sql, string where, string parameter)
    	{
    		_sql = sql;
    		_where = where;
    		_parameter = parameter;
    	}
    	
    	public string TransformAndReturnSQL(int start, int end)
    	{
    		_start = start;
    		_end = end;
    		if (_parameter == null)
    			_parameter = string.Empty;
    		string[] split = Utils.Splitter(_parameter);
    		number = split.Length;
    		StringBuilder sb = new StringBuilder(" XYZ ");
    		StringBuilder st = new StringBuilder();
    
    		for (int i = 0; i < number; i++)
    		{
    			if (split[i].ToString() != string.Empty)
    				sb.Insert(0, SELECT_FROM);
    		}
    
    		for (int i = 0; i < number; i++)
    		{
    			if (split[i].ToString() != string.Empty)
    			{
    				sb.Insert(sb.Length, _where);
    				sb.Replace("@param", split[i].ToString());
    			}
    		}
    		sb.Replace("XYZ", _sql);
    		st.Append(sb.ToString());
    		sb.Insert(0, SELECT_TOP_I);
    		sb.Append(JOINTURE);
    		sb.Append(SELECT_TOP_F);
    		sb.Append(st.ToString());
    		sb.Append(CLOSE);
    		sb.Replace("$I", _start.ToString());
    		sb.Replace("$F", _end.ToString());
    
    		return sb.ToString();
    	}
    }

    Вот так надо запросы строить!

    _Ru55_, 22 Апреля 2011

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

    +128

    1. 1
    2. 2
    3. 3
    4. 4
    public void Dispose()
            {
                  throw new NotImplementedException();
            }

    Студенты такие студенты

    graph_di5, 20 Апреля 2011

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

    +111

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    // BasePage
    public virtual void Page_Error(object sender, EventArgs e) { }
    
    // Page
    public override void Page_Error(object sender, EventArgs e) { }

    Авторы-индусы были по всей видимости не в курсе о существовании OnError(EventArgs)

    abatishchev, 19 Апреля 2011

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

    +136

    1. 1
    2. 2
    3. 3
    if (demand.TargetDate == new DateTime())
    {
    }

    abatishchev, 18 Апреля 2011

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

    +126

    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
    g.Graphics.DrawLine( p, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( p, this.pb.Width / 2 - 126, this.pb.Height / 2 + 176, this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 - 126 + 8, this.pb.Height / 2 + 176 + 15 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 - 126 + 8, this.pb.Height / 2 + 176 + 25 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126 - 8, this.pb.Height / 2 + 176 + 15 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + 126, this.pb.Height / 2 + 176 + 20, this.pb.Width / 2 + 126 - 8, this.pb.Height / 2 + 176 + 25 );
                        g.Graphics.FillRectangle( Brushes.White, this.pb.Width / 2 - 25, this.pb.Height / 2 + 176 + 10, 50, 20 );
                        g.Graphics.DrawString( this.textBox1.Text + " mm", new Font( "Arial", 8 ), new SolidBrush( Color.Black ), this.pb.Width / 2 - 21, this.pb.Height / 2 + 176 + 12 );
    
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 - (int)paint_nozh_fill / 2 + 8, this.pb.Height / 2 - 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 - (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 - (int)paint_nozh_fill / 2 + 8, this.pb.Height / 2 + 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2 - 8, this.pb.Height / 2 - 5 );
                        g.Graphics.DrawLine( new Pen( Color.Black ), this.pb.Width / 2 + (int)paint_nozh_fill / 2, this.pb.Height / 2, this.pb.Width / 2 + (int)paint_nozh_fill / 2 - 8, this.pb.Height / 2 + 5 );
                        g.Graphics.FillRectangle( Brushes.White, this.pb.Width / 2 - 25, this.pb.Height / 2 - 10, 50, 20 );
                        g.Graphics.DrawString( this.getNozhFill( ).ToString( ) + " mm", new Font( "Arial", 8 ), new SolidBrush( Color.Black ), this.pb.Width / 2 - 21, this.pb.Height / 2 - 8 );

    Человек похоже перепутал визул студию с фотошопом, но закрывать не стал )) Этот код рисует чертеж - примем со стрелочками, с откосами и даже(!) с отбрасывает тень. Понятия не имею как преписывать

    glilya, 16 Апреля 2011

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

    +111

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    for (int i = 0; i < 10; i++)
                      {
                             Console.Write(";x=" + h * i * dn + ",U=" + res[i * dn, j * dm]);
                      }
                      Console.Write(";x=" + h * 10 * dn + ",U=" + res[10 * dn, j * dm]);

    No comments

    mstyura, 15 Апреля 2011

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

    +118

    1. 1
    2. 2
    object res = DataConnection.ExecuteScalar(sql);
    int count = (int)(long)res;

    Чтокуда?

    Vadimyan, 14 Апреля 2011

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

    +117

    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
    WorksheetRow row = new WorksheetRow();
    row.Cells.Add("");
    
    // ispublished
    row.Cells.Add(point.IsPublished ? "+" : "");
    
    // id superregion
    row.Cells.Add(point.Town.Region.SuperRegion.Id.ToString());
    
    // name superregion
    if (cleanupTags)
    	row.Cells.Add(CleanXMLTags(point.Town.Region.SuperRegion.Name));
    else row.Cells.Add(point.Town.Region.SuperRegion.Name);
    
    // id rregion
    row.Cells.Add(point.Town.Region.Id.ToString());
    
    // name region
    if (cleanupTags)
    	row.Cells.Add(CleanXMLTags(point.Town.Region.DefaultText.Name));
    else row.Cells.Add(point.Town.Region.DefaultText.Name);
    
    ...
    
    StringBuilder subwayIDs = new StringBuilder("");
    StringBuilder subwayNames = new StringBuilder("");
    foreach (Subway subway in point.Subways)
    {
    	subwayIDs.Append(subway.Id).Append(", ");
    	subwayNames.Append(subway.DisplayName).Append(", ");
    }
    string sIDs = subwayIDs.ToString();
    if (sIDs.Length > 0) sIDs = sIDs.Substring(0, sIDs.Length - 2);
    
    string sNames = subwayNames.ToString();
    if (sNames.Length > 0) sNames = sNames.Substring(0, sNames.Length - 2);

    Это 10% от метода. Там все в том же духе.

    ShurikEv, 14 Апреля 2011

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

    +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
    public struct RowForReportBookRecordIssue
    	{
    		public string Column1 { get; set; }
    		public string Column2 { get; set; }
    		public string Column3 { get; set; }
    		public string Column4 { get; set; }
    		public string Column5 { get; set; }
    		public string Column6 { get; set; }
    		public string Column7 { get; set; }
    		public string Column8 { get; set; }
    		public string Column9 { get; set; }
    		public string Column10 { get; set; }
    	}

    Использование соответствующее:
    RowForReportBookRecordIssue.Column1 = ...; RowForReportBookRecordIssue.Column2 = ...;
    Даже страшно, если что-то придется править... :(

    fr0mrus, 12 Апреля 2011

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

    +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
    // Установка обработкчиков событий
                tbTitle.TextChanged += (x, y) => _target.Title = tbTitle.Text;
                cbContractorType.SelectedIndexChanged += (x, y) => _target.ContractorType = cbContractorType.SelectedIndex;
                tbFullTitle.TextChanged += (x, y) => _target.Title = tbFullTitle.Text;
                tbINN.TextChanged += (x, y) => _target.INN = tbINN.Text;
                // Для физ. лица
                dtpBirthDate.ValueChanged += (x, y) => _target.birthDate = dtpBirthDate.Value;
                tbPassportSeria.TextChanged += (x, y) => _target.PassportSeria = tbPassportSeria.Text;
                tbPassportNumber.TextChanged += (x, y) => _target.PassportNumber = tbPassportNumber.Text;
                dtpPassportDateRegistred.ValueChanged += (x, y) => _target.PassportDateRegistred = dtpPassportDateRegistred.Value;
                tbPassportOrganizationRegistred.TextChanged += (x, y) => _target.PassportOrganizationRegistred = tbPassportOrganizationRegistred.Text;
                tbRegistredPassportAddress.TextChanged += (x, y) => _target.RegistredPassportAddress = tbRegistredPassportAddress.Text;
                // Для юр лица
                tbOgranizationJuridicalAddress.TextChanged += (x ,y) => _target.OgranizationJuridicalAddress = tbRegistredPassportAddress.Text;
                tbOrganizationMainBankAcouuntNumber.TextChanged += (x, y) => _target.OrganizationMainBankAcouuntNumber = tbOrganizationMainBankAcouuntNumber.Text;
                tbOrganizationKPP.TextChanged += (x, y) => _target.OrganizationKPP = tbOrganizationKPP.Text;
                tbOrganizationOGRNIP.TextChanged += (x, y) => _target.OrganizationOGRNIP = tbOrganizationOGRNIP.Text;
                tbOrganizationIFNS.TextChanged += (x, y) => _target.OrganizationIFNS = tbOrganizationIFNS.Text;
                tbOrganizationOKATO.TextChanged += (x, y) => _target.OrganizationOKATO = tbOrganizationOKATO.Text;
                tbOrganizationOKPO.TextChanged += (x, y) => _target.OrganizationOKPO = tbOrganizationOKPO.Text;

    У меня денюха поэтому решил отмаппить форму по новому

    glilya, 10 Апреля 2011

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