1. Список говнокодов пользователя Baiumka

    Всего: 8

  2. Pascal / Говнокод #28097

    0

    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
    procedure TF_dvij.rg_sortClick(Sender: TObject);
    var k :Integer;
        s,str1,str2 :string;
        fl :boolean;
    begin
    if G.Columns[9].Visible then
    begin
      fl := Q_dvij.Active ;
      with Q_dvij do
      begin
        if fl then k := RecNo;
        if rg_sort.ItemIndex=0 then s:='order by obd,gr,exped,grot'
        else
        if rg_sort.ItemIndex=1 then s:='order by exped,gr,obd,grot'
        else
        if rg_sort.ItemIndex=2 then s:='order by gr,vp,exped,obd,grot'
        else
        if rg_sort.ItemIndex=3 then s:='order by id_korr,exped,obd,gr,grot'
        else
        if rg_sort.ItemIndex=4 then s:='order by grot,gr,exped,obd'
        else
          s:='order by strn,obd,gr,exped,grot';
          
        if rg_sort.ItemIndex=3 then
          begin
            str1 := 'select vp, id_korr,' ;           //100
            str2 := 'group by 1,2,3,4,5,6,7,8'          //192
          end
        else
          begin
            str1 := 'select vp, max(id_korr) as id_korr,' ;
            str2 := 'group by 1,3,4,5,6,7,8'
          end  ;
    
        Active:=false;
        SQL.Delete(100);
        SQL.Insert(100, str1 );
        SQL.Delete(192);
        SQL.Insert(192, str2 );
        SQL.Delete(262);
        SQL.Insert(262, s);
        Active:= fl;
        if fl then RecNo := k;
        G.Refresh;
      end;
    end;

    сортировОЧКА

    Baiumka, 29 Марта 2022

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

    0

    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
    with ZeoDataModule.TmpZQuery do
      begin
        ZeoDataModule.TmpZQuery.Close;
        ZeoDataModule.TmpZQuery.SQL.Clear;
        //ZeoDataModule.TmpZQuery.SQL.Add(ZeoDataModule.zqryOstatki.SQL.Text);
        ZeoDataModule.TmpZQuery.SQL.Add(TZQuery(dbgrdh1.DataSource.DataSet).SQL.Text);
    //    ZeoDataModule.Add ('select  *,''0.00'' as str_cen from material.ostatki_by_skladid(:skladid,:dt) ');
        ZeoDataModule.TmpZQuery.SQL.Add (' and  tovarid in(');
        for i:=0 to OstatkiTovarList.Count-1 do
        begin
          ZeoDataModule.TmpZQuery.SQL.Add(ostatkiTovarList[i]);
          if i< OstatkiTovarList.Count-1 then
            ZeoDataModule.TmpZQuery.SQL.Add(',');
        end;
        ZeoDataModule.TmpZQuery.SQL.Add(')');
        ZeoDataModule.TmpZQuery.SQL.Add('order by nt');
        //-------
        zQ_sv:= DataModulePrint.frxDBDatasetOstatki.DataSet as TZQuery;   // zqryOstatki
        //--------
        ZeoDataModule.zqrySumBySS.Close;
    //    ZeoDataModule.zqrySumBySS.SQL.Add('select :dt,:skladid from material.globalvalues where 1=2'); //  пустой набор
        ZeoDataModule.zqrySumBySS.ParamByName('skladid').Value:=10000;  // несуществующий склад (пустой набор)
        ZeoDataModule.zqrySumBySS.Open;
    
        ZeoDataModule.TmpZQuery.ParamByName('skladid').Value:=zQ_sv.ParamByName('skladid').Value;
        ZeoDataModule.TmpZQuery.ParamByName('dt').AsDate:=zQ_sv.ParamByName('dt').AsDate;
        ZeoDataModule.TmpZQuery.Open;
    
        DataModulePrint.frxDBDatasetOstatki.DataSet := ZeoDataModule.TmpZQuery;
        DataModulePrint.frxDBDatasetSumBySS.DataSet := ZeoDataModule.zqrySumBySS;
        if TypeVed=USUAL_OST then
        begin
          if Material.TypeSkladId = 4 then
            DataModulePrint.ShowReport('ostatki.fr3')
          else
            DataModulePrint.ShowReport('ostatki.fr3')
        end
        else if TypeVed = NO_MOVE_OST then
          DataModulePrint.ShowReport('ostatki_no_move.fr3');
    
        ZeoDataModule.TmpZQuery.Close;
    
        DataModulePrint.frxDBDatasetOstatki.DataSet := zQ_sv;
        ZeoDataModule.zqrySumBySS.Close;
        ZeoDataModule.zqrySumBySS.ParamByName('skladid').Value:=Material.Skladid;
    //    ZeoDataModule.zqrySumBySS.SQL.Clear();
    //    ZeoDataModule.zqrySumBySS.SQL.Add(sqlSum_sv); 
        ZeoDataModule.zqrySumBySS.Open;
      end;

    ZeoDataModule.TmpZQuery.SQL.Add(TZQuery( dbgrdh1.DataSource.DataSet).SQL.Text); - особенно понравилось. Молчу про "with".

    Baiumka, 31 Января 2022

    Комментарии (4)
  4. SQL / Говнокод #27976

    0

    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
    ttt as (
                        select o.tovarid, o.edizmerid, o.cena, 
                               o.vos, o.cena*o.vos as sum_vos,  
                               coalesce(p.sum_kl,0.0)  as _prih_kl, coalesce( p.sum_prih,0.0) as  sum_prih, 
                               coalesce( p.sum_prih_docs,0.0) as  sum_prih_docs,
                               coalesce(r.sum_kl,0.0) as _rash_kl, coalesce(r.sum_rash,0.0)  as  sum_rash ,
                               coalesce(r.sum_rash_docs,0.0)  as  sum_rash_docs ,
                               coalesce(rd.sum_kl,0.0) as _rash_doc_kl, coalesce(rd.sum_rash_doc,0.0) as sum_rash_doc, 
                               coalesce(rd.sum_rash_doc_docs, 0.0) as sum_rash_doc_docs ,
                     --          coalesce(rs.sum_kl,0.0) as _rash_storno_kl, coalesce(rs.sum_rash,0.0) as sum_rash_storno ,
                               o.ostid, o.ss, o.sb 
                        from ost_ o
                        left join prih p on (o.tovarid = p.tovarid 
                                         and o.edizmerid=p.edizmerid
                                         and o.ss = p.ss
                                         and o.sb = p.sb)   
                        left join rash r on (o.tovarid =r.tovarid 
                                         and o.edizmerid=r.edizmerid
                                         and o.ss = r.ss
                                         and o.sb = r.sb) 
                        left join rash_doc rd on (o.tovarid =rd.tovarid 
                                              and o.edizmerid=rd.edizmerid
                                              and o.ss = rd.ss_
                                              and o.sb = rd.sb_) 
                       -- left join rash_old_072018 ro on (o.tovarid =ro.tovarid 
                                          --    and o.edizmerid=ro.edizmerid) 
                  -- 08.2018     left join rash_storno rs on (o.tovarid =rs.tovarid    and o.edizmerid=rs.edizmerid) 
    --                    where   o.vos+p.sum_kl>0  
                      ),
                    tt as (    
                      select *, ttt.vos + ttt._prih_kl - ttt._rash_kl as ost_fact ,
    --                    case when  (ttt.vos+ttt._prih_kl<>0 )  then
    --                        ( ttt.sum_vos+ttt.sum_prih -ttt.sum_rash_storno)/(ttt.vos+ttt._prih_kl-ttt._rash_storno_kl)
    --                      else ttt.cena end   as new_cen from ttt
              --          case when  (ttt.vos+ttt._prih_kl+ttt._rash_storno_kl-ttt._rash_kl-ttt._rash_doc_kl<>0 )  then
              --              ( ttt.sum_vos+ttt.sum_prih +ttt.sum_rash_storno-ttt.sum_rash-ttt.sum_rash_doc)/(ttt.vos+ttt._prih_kl-ttt._rash_storno_kl-ttt._rash_kl-ttt._rash_doc_kl)
                             case when (ttt.vos+ttt._prih_kl-ttt._rash_kl-ttt._rash_doc_kl<>0 ) then
                               ( ttt.sum_vos+ttt.sum_prih -ttt.sum_rash-ttt.sum_rash_doc)/(ttt.vos+ttt._prih_kl-ttt._rash_kl-ttt._rash_doc_kl)
                             else ttt.cena end as new_cen 
                      from ttt
                    )        
          select tt.tovarid,
                 tt.cena,
                 tt.edizmerid,
                 t.kt,
                 t.nt,
                 tt.vos,
                 round(sum_vos,2), 
                 u.name_u,
                 tt._prih_kl as _prih_kl, 
          --       round( tt.sum_prih,2)  as sum_prih ,
                  tt.sum_prih_docs  as sum_prih ,
                 tt._rash_kl as _rash_kl, 
           --      round( tt.sum_rash,2)  as sum_rash ,
                 tt.sum_rash_docs  as sum_rash ,
                 tt.ost_fact,
    --             round(tt.ost_fact* tt.new_cen,5),
                 round(tt.ost_fact* tt.new_cen,2),
                 t.priz,
                 round(tt.new_cen,5),
                 tt.ostid,
                 tt._rash_doc_kl,
    --             tt.sum_rash_doc,
                 tt.sum_rash_doc_docs,
                 t.dk_2010,
                 coalesce( tt.ss, '0'),
                 coalesce( tt.sb, '0')
              from tt
              left join material.tovar t on (t.tovarid=tt.tovarid)
              left join nsi.units u  on (u.id=tt.edizmerid);

    Называется найди разницу между ttt, tt и t

    Baiumka, 31 Января 2022

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

    0

    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
    procedure TOstatkiForm.FormCreate(Sender: TObject);
    begin
      OstatkiTovarList:=TStringList.Create;
    
      btnShowToConvert.Enabled := False;
      grpToConvert.Visible := False;
    
      zqrToConvert.SQL.Text := 'select null::integer ostid,' + #13#10 +
                                      'null::integer tovarid,' + #13#10 +
                                      'null::bigint kt,' + #13#10 +
                                      'null::varchar nt,' + #13#10 +
                                      'null::numeric cen,' + #13#10 +
                                      'null::integer edizmerid,' + #13#10 +
                                      'null::varchar name_u,' + #13#10 +
                                      'null::date income_period,' + #13#10 +
                                      'null::varchar ss,' + #13#10 +
                                      'null::numeric ost_doc,' + #13#10 +
                                      'null::numeric gsum' + #13#10 +
                               'where 1=2';
    end;

    Без комментариев

    Baiumka, 12 Января 2022

    Комментарии (3)
  6. SQL / Говнокод #27940

    0

    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
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    94. 94
    95. 95
    96. 96
    97. 97
    98. 98
    99. 99
    return QUERY
          with a as 
         (    
             with pr as 
             (
               select p.ss, p.sb, 
                 sum(sum_prih)  as sum_prih
               from   material.prihod_by_all_sklads_by_doc_period(dt_ostatki)  p               
               group by 1,2
             ),
              r AS
             (
               select p.ss, p.sb, 
                      sum(p.sum_by_cen)  as sum_rash
               from   material.rashod_by_all_sklads_by_doc_period(dt_ostatki)  p               
               group by 1,2
             ),
             os AS
             (  
                select o.ss, o.sb, 
           --     case  when trim(o.sb)='1150' then 'Запчастини ВКМ,ВПК1,ВПК2,ВПК3,сб. 1150'
          --            when trim(o.sb)='1050' then 'Запчастини ВКМ,ВПК1 сб. 1050' 
       --               when trim(o.sb)='1105' then 'Запчастини ВКМ,ВПК1,ВПК2,ВПК3,сб. 1105'
         --        else  o.name_sklad end as name_skl, 
                sum(o.sum_ost_doc)  as sum_ost_doc--,
               from material.ostatki_by_all_sklads(dt_ostatki) o
               left join material.sklad s  on (s.skladid = o.skladid) 
               group by 1,2
             ),
             topl AS
             (
            select o.ss, o.sb,
                  sum(o.ost_sum)   as sum_ost_doc,
                  sum(o.vos_sum)   as sum_vos,
                  sum(o.prih_sum)   as sum_prih,
                  sum(o.rash_sum)   as sum_rash
                  from material.ostatki_by_all_toplot(dt_ostatki) o 
                  group by 1,2  
             )
            select os.ss, os.sb,
                   os.sum_ost_doc,  
                   coalesce ( pr.sum_prih,0) as  sum_prih,
                    coalesce (r.sum_rash,0) as  sum_rash 
             from os 
             left join pr on (os.ss= pr.ss and os.sb= pr.sb ) 
             left join r on (os.ss= r.ss and os.sb= r.sb )   
            UNION
            select os.ss, os.sb,
                   os.sum_ost_doc,  
    --                os.sum_vos + os.sum_prih - os.sum_rash  as sum_ost_doc ,
                   os.sum_prih,
            --       os.sum_rash
    --               case when period_dt$>='2018.08.01'  then COALESCE( r.sum_rash,0) 
    --                else  os.sum_vos-os.sum_ost_doc + os.sum_prih end    as sum_rash --os.sum_rash END 
      --             r.sum_rash  
              os.sum_vos-os.sum_ost_doc + os.sum_prih
             
            from topl os left join r on (os.ss= r.ss and os.sb= r.sb )   
    /*      
            select o.ss, o.sb,
                  sum(o.ost_sum)   as sum_ost_doc,
                  sum(o.prih_sum)   as sum_prih,
                  sum(o.rash_sum)   as sum_rash
                  from material.ostatki_by_all_toplot(dt_ostatki) o  left JOIN r on (r.ss =o.ss and r.sb=o.sb)
                  group by 1,2  
      */            
       /*    UNION
           select  ob.ss, ob.sus,
                   '112'  as    depart_name,
                   '112',
                   sum(ob.ost_sum),  
                   sum(ob.pr_sum),
                   sum(ob.rm_sum)    
           
                 from  material.oborot_by_ss_112_by_sklads(period_dt, dt_ostatki)   ob           
                 group by 1,2,3,4  */
         ),
         b as
         (
          select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'112')  bb where bb.sb = '0007'
          UNION
          select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'153')  bb
          UNION
      --      select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'152')  bb  
          select bb.ss,bb.sb,bb.sisb_d ,bb.sisb_k, bb.sdob, 0 from cont.bbz_sald_by_sb(y,m,'152')  bb
          UNION
          select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'201')  bb
          UNION
          select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'207')  bb 
          UNION
          select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'209')  bb 
          UNION
          select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'203')  bb 
          UNION
          select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'221')  bb 
         -- UNION
         -- select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'231')  bb 
         -- UNION
         -- select bb.ss,bb.sb,bb.sisb_d,bb.sisb_k, bb.sdob, bb.skob from cont.bbz_sald_by_sb(y,m,'232')  bb

    Весь запрос не влез...

    Baiumka, 10 Января 2022

    Комментарии (1)
  7. Pascal / Говнокод #27939

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if  (  (sd<>5)  )    and  //    (Material.ReadOnlySklad =false)      and
              (
                  (     Material.TypeSkladId <> 4    )  and
                  (
                 //    (Material.UserBuh = true )  or (Material.UserAdmin = true)     or
                         (Material.DisunionByOssSb=true )  or  ( credit_operation = true )
    
                  )
                )
               then

    Baiumka, 10 Января 2022

    Комментарии (11)
  8. Pascal / Говнокод #27926

    0

    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
    procedure TForm9.FormShow(Sender: TObject);
    var i_vx,o_dt,o_kt: real;
    begin
      Form9.Caption:='Èòîãî ïî æóðíàëó';
      r_:='select sum(sma) as ism from '+t_ss;
      with DM.ZQ_all do
      begin
        Close;
        SQL.Clear;
        SQL.Add(r_);
        SQL.Add('where ch=1 and gd*100+ms<:rgd*100+:rms');
        Params.ParamByName('rgd').Value :=t_gd;
        Params.ParamByName('rms').Value :=t_ms;
        Open;
        first;
        if Eof=true then i_vx:=0 else i_vx:=Fieldbyname('ism').asfloat;
    
        Close;
        SQL.Clear;
        SQL.Add(r_);
        SQL.Add('where ch=2 and gd*100+ms<:rgd*100+:rms');
        Params.ParamByName('rgd').Value :=t_gd;
        Params.ParamByName('rms').Value :=t_ms;
        Open;
    
        first;
        if not Eof=true then  i_vx:=i_vx - Fieldbyname('ism').asfloat;
        LEdit1.Text:=Format('%10.2f',[i_vx]);
        Close;
        SQL.Clear;
        SQL.Add(r_);
        SQL.Add('where ch=1 and gd*100+ms=:rgd*100+:rms');
        Params.ParamByName('rgd').Value :=t_gd;
        Params.ParamByName('rms').Value :=t_ms;
        Open;
        first;
        if Eof=true then o_dt:=0 else o_dt:=Fieldbyname('ism').asfloat;
        LEdit2.Text:=Format('%10.2f',[o_dt]);
        Close;
        SQL.Clear;
        SQL.Add(r_);
        SQL.Add('where ch=2 and gd*100+ms=:rgd*100+:rms');
        Params.ParamByName('rgd').Value :=t_gd;
        Params.ParamByName('rms').Value :=t_ms;
        Open;
        first;
        if Eof=true then o_kt:=0 else o_kt:=Fieldbyname('ism').asfloat;
        Close;
        LEdit3.Text:=Format('%10.2f',[o_kt]);
        LEdit4.Text:=Format('%10.2f',[i_vx+o_dt-o_kt]);
      end;
    
    end;

    Baiumka, 06 Января 2022

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

    +2

    1. 1
    select sum(sma) as ism from Jur_7.ss2022_1 where ch=1 and gd*100+ms<2022*100+1

    Нашел БД с ОТДЕЛЬНОЙ таблицей на каждый месяц (начиная с 2008 года). А тут еще и дата определяется....

    Baiumka, 06 Января 2022

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