nasıl düzeltebilirim
Kod: Tümünü seç
procedure TCARI_KART_EKSTRE_PENCERE.Button7Click(Sender: TObject);
begin
BAKIYELER_RAPOR_DB.Close;
BAKIYELER_RAPOR_DB.SQL.Clear;
BAKIYELER_RAPOR_DB.SQL.Add
(' declare @bakiyeler table(ID bigint,KOD nvarchar(150),CCFI nvarchar(150),UNVAN nvarchar(255),BORC numeric(18,2),ALACAK numeric(18,2),BAKIYE numeric(18,2),DURUM nvarchar(255))'
+' insert into @bakiyeler select ct.Cari_ID,ct.Genel_Cari_Kodu,ct.Calisilan_Firma_ID,ct.Genel_Cari_Unvan,'
+' sum(ch.Fis_Genel_Toplami_Borc) as BORC,sum(ch.Fis_Genel_Toplami_Alacak) as'
+' ALACAK ,(sum(ch.Fis_Genel_Toplami_Borc) - sum(ch.Fis_Genel_Toplami_Alacak))'
+' as BAKIYE, ct.Genel_Cari_Unvan from HESAP_HAREKETLERI as ch, CARI_KART_LISTE as ct where ch.Cari_Kart_ID = ct.Cari_ID'
+' AND Durumu <> '+#39+'Ödendi'+#39+''
+' and ct.Calisilan_Firma_ID = '''+Ana_Pencere.DBEdit6.Text+''' '
+' and ct.Cari_ID ='''+CARI_KOD_TEXT.Text+''''
+' and (Islem_Tarihi BETWEEN :Tar1 and :Tar2)'
+' group by ct.Cari_ID , ct.Genel_Cari_Kodu,ct.Calisilan_Firma_ID,ct.Genel_Cari_Unvan Order By Cari_ID ASC'
+' declare @borclular table (id bigint)'
+' insert into @borclular select ID from @bakiyeler where BAKIYE>0'
+' declare @alacaklilar table (id bigint)'
+' insert into @alacaklilar select ID from @bakiyeler where BAKIYE<0'
+' declare @temizler table (id bigint)'
+' insert into @temizler select ID from @bakiyeler where BAKIYE = 0 or BAKIYE = null'
+' update @bakiyeler set durum = '+#39+'Borçlu'+#39+' where ID in (select id from @borclular)'
+' update @bakiyeler set durum = '+#39+'Alacaklı'+#39+' where ID in (select id from @alacaklilar)'
+' update @bakiyeler set durum = '+#39+'-'+#39+' where ID in (select id from @temizler)'
+' select * from @bakiyeler');
BAKIYELER_RAPOR_DB.Parameters.ParamByName('Tar1').Value := FormatDateTime('DD/MM/YYYY',DateTimePicker1.date);
BAKIYELER_RAPOR_DB.Parameters.ParamByName('Tar2').Value := FormatDateTime('DD/MM/YYYY',DateTimePicker2.date+1);
BAKIYELER_RAPOR_DB.Open;
end;