Delphi Can

Orjinalini görmek için tıklayınız: DBGrid1 de Alta Boşluk Eklemek
Şu anda (Arşiv) modunu görüntülemektesiniz. Orjinal Sürümü Görüntüle internal link
Sayfalar: 1 2 3
Arkadaşlar merhaba; Bir sorunum var yardımcı olursanız sevinirim.
SQL ile DBGrid1 liste alıyorum kolaylık açısından aynı BELGE_NO dan sonra boşluk atmasını nasıl sağlarım?

Bu şekilde Liste;

000000000041407
000000000041407
000000000041407
000000000041407
000000000041408
000000000041408
000000000041408
000000000041409
000000000041410
000000000041410


Bu şekilde Olmasını istiyorum;

000000000041407
000000000041407
000000000041407
000000000041407

000000000041408
000000000041408
000000000041408

000000000041409

000000000041410
000000000041410
(25-04-2022, Saat: 13:17)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]Arkadaşlar merhaba; Bir sorunum var yardımcı olursanız sevinirim.
SQL ile DBGrid1 liste alıyorum kolaylık açısından aynı BELGE_NO dan sonra boşluk atmasını nasıl sağlarım?

Bu şekilde Liste;

000000000041407
000000000041407
000000000041407
000000000041407
000000000041408
000000000041408
000000000041408
000000000041409
000000000041410
000000000041410


Bu şekilde Olmasını istiyorum;

000000000041407
000000000041407
000000000041407
000000000041407

000000000041408
000000000041408
000000000041408

000000000041409

000000000041410
000000000041410

Dbgrid' de böyle bir özellik var mı bilmiyorum ama ben olsam nasıl yapardım  ?




dbgrid onDrawCell özelliğine

eğer grid ilk satırı değilse ve eklenen satır belge no bir önceki satırdaki belge no ile  eşit değilse  grid satır yüksekliği 20 yoksa 15 (default yükseklik neyse o değer) yapardım
veya aynı karşılaştırmada  renkleri değiştirirdim.
Gridde gösterilen sorgu sonucu SQL tarafından düzenlenebilir veya sorgu sonuvu arka planda işlenerek virtual table aktarılır, dbgride de virtual table bağlanır.

Yukarıdaki önerinin mahsuru, grid üzerinden yapılan seçime göre işlem yapıyorsanız, seçilen satırın boş satır olup olmadığını kontol etmeniz gerekecek. Bu durumda @cinarbil önerdiği gibi satırın yüksekliği ile oynamak daha mantıklı yöntem gibi.
(25-04-2022, Saat: 13:17)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]Arkadaşlar merhaba; Bir sorunum var yardımcı olursanız sevinirim.
SQL ile DBGrid1 liste alıyorum kolaylık açısından aynı BELGE_NO dan sonra boşluk atmasını nasıl sağlarım?

Bu şekilde Liste;

000000000041407
000000000041407
000000000041407
000000000041407
000000000041408
000000000041408
000000000041408
000000000041409
000000000041410
000000000041410


Bu şekilde Olmasını istiyorum;

000000000041407
000000000041407
000000000041407
000000000041407

000000000041408
000000000041408
000000000041408

000000000041409

000000000041410
000000000041410

Merhabalar,

Umarım yardımcı olur.

https://www.db-fiddle.com/f/gTA8wWrZ8h278FhkxpWE5N/0

Kolay gelsin.


cREATE TABLE IF NOT EXISTS deneme (
    id INT AUTO_INCREMENT PRIMARY KEY,
   belge_no VARCHAR(255) NOT NULL
)  ENGINE=INNODB;

insert into deneme (belge_no) values ('ABC123'),('ABC123'),('ABC124'),('ABC125'),('ABC125'); 

SELECT 
case id is not null when true then id else null end as id,
case id is not null when true then belge_no else null end as belge_no


FROM deneme 
group by belge_no, id
with rollup
having belge_no is not null
(25-04-2022, Saat: 15:25)cinarbil Adlı Kullanıcıdan Alıntı: [ -> ]
(25-04-2022, Saat: 13:17)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]Arkadaşlar merhaba; Bir sorunum var yardımcı olursanız sevinirim.
SQL ile DBGrid1 liste alıyorum kolaylık açısından aynı BELGE_NO dan sonra boşluk atmasını nasıl sağlarım?

Bu şekilde Liste;

000000000041407
000000000041407
000000000041407
000000000041407
000000000041408
000000000041408
000000000041408
000000000041409
000000000041410
000000000041410


Bu şekilde Olmasını istiyorum;

000000000041407
000000000041407
000000000041407
000000000041407

000000000041408
000000000041408
000000000041408

000000000041409

000000000041410
000000000041410

Dbgrid' de böyle bir özellik var mı bilmiyorum ama ben olsam nasıl yapardım  ?




dbgrid onDrawCell özelliğine

eğer grid ilk satırı değilse ve eklenen satır belge no bir önceki satırdaki belge no ile  eşit değilse  grid satır yüksekliği 20 yoksa 15 (default yükseklik neyse o değer) yapardım
veya aynı karşılaştırmada  renkleri değiştirirdim.

Ben şöyle bir kod buldum uyarladım ama renklendirme yapmadı.
if StokKontrol.FieldByName('FISNO').AsString = DBGrid3.DataSource.DataSet.FieldByName('FISNO').AsString  Then
begin
  DBGrid3.Canvas.Font.Color:=clWhite;
  DBGrid3.Canvas.Brush.Color:=clBlack;
end;
if DataCol = 0 then
 DBGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

(26-04-2022, Saat: 09:14)hi_selamlar Adlı Kullanıcıdan Alıntı: [ -> ]
(25-04-2022, Saat: 13:17)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]Arkadaşlar merhaba; Bir sorunum var yardımcı olursanız sevinirim.
SQL ile DBGrid1 liste alıyorum kolaylık açısından aynı BELGE_NO dan sonra boşluk atmasını nasıl sağlarım?

Bu şekilde Liste;

000000000041407
000000000041407
000000000041407
000000000041407
000000000041408
000000000041408
000000000041408
000000000041409
000000000041410
000000000041410


Bu şekilde Olmasını istiyorum;

000000000041407
000000000041407
000000000041407
000000000041407

000000000041408
000000000041408
000000000041408

000000000041409

000000000041410
000000000041410

Merhabalar,

Umarım yardımcı olur.

https://www.db-fiddle.com/f/gTA8wWrZ8h278FhkxpWE5N/0

Kolay gelsin.


cREATE TABLE IF NOT EXISTS deneme (
    id INT AUTO_INCREMENT PRIMARY KEY,
   belge_no VARCHAR(255) NOT NULL
)  ENGINE=INNODB;

insert into deneme (belge_no) values ('ABC123'),('ABC123'),('ABC124'),('ABC125'),('ABC125'); 

SELECT 
case id is not null when true then id else null end as id,
case id is not null when true then belge_no else null end as belge_no


FROM deneme 
group by belge_no, id
with rollup
having belge_no is not null

Teşekkür ederim. Uyarlayıp kullandım ama hata veriyor


SELECT
case STOK_KODU IS NOT NULL when true then STOK_KODU else null end as STOK_KODU,
case STOK_KODU IS NOT NULL when true then FISNO else null end as FISNO


FROM TBLSTHAR 
group by FISNO, STOK_KODU
with rollup
having FISNO is not null



Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'IS'.
Msg 319, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
Merhaba,

MySQL olarak düzenlenmiş bir SQL cümlesi.
Hangi DB'yi kullandığınızı bilmediğim için.

Kolay gelsin.
(26-04-2022, Saat: 09:56)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]
(25-04-2022, Saat: 15:25)cinarbil Adlı Kullanıcıdan Alıntı: [ -> ]Dbgrid' de böyle bir özellik var mı bilmiyorum ama ben olsam nasıl yapardım  ?




dbgrid onDrawCell özelliğine

eğer grid ilk satırı değilse ve eklenen satır belge no bir önceki satırdaki belge no ile  eşit değilse  grid satır yüksekliği 20 yoksa 15 (default yükseklik neyse o değer) yapardım
veya aynı karşılaştırmada  renkleri değiştirirdim.

Ben şöyle bir kod buldum uyarladım ama renklendirme yapmadı.
if StokKontrol.FieldByName('FISNO').AsString = DBGrid3.DataSource.DataSet.FieldByName('FISNO').AsString  Then
begin
  DBGrid3.Canvas.Font.Color:=clWhite;
  DBGrid3.Canvas.Brush.Color:=clBlack;
end;
if DataCol = 0 then
 DBGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

(26-04-2022, Saat: 09:14)hi_selamlar Adlı Kullanıcıdan Alıntı: [ -> ]Merhabalar,

Umarım yardımcı olur.

https://www.db-fiddle.com/f/gTA8wWrZ8h278FhkxpWE5N/0

Kolay gelsin.


cREATE TABLE IF NOT EXISTS deneme (
    id INT AUTO_INCREMENT PRIMARY KEY,
   belge_no VARCHAR(255) NOT NULL
)  ENGINE=INNODB;

insert into deneme (belge_no) values ('ABC123'),('ABC123'),('ABC124'),('ABC125'),('ABC125'); 

SELECT 
case id is not null when true then id else null end as id,
case id is not null when true then belge_no else null end as belge_no


FROM deneme 
group by belge_no, id
with rollup
having belge_no is not null

Teşekkür ederim. Uyarlayıp kullandım ama hata veriyor


SELECT
case STOK_KODU IS NOT NULL when true then STOK_KODU else null end as STOK_KODU,
case STOK_KODU IS NOT NULL when true then FISNO else null end as FISNO


FROM TBLSTHAR 
group by FISNO, STOK_KODU
with rollup
having FISNO is not null



Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'IS'.
Msg 319, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

Çalışan kod burada 1. satırı farkı renk 2. satırı farklı kaydet olarak yaptım
bu değiştirerek kendine göre uyarla
procedure Tmusterifrm.grid_musteriDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
 State: TGridDrawState);
begin
if data_form.musteri_sorgu.RecNo  and 1 = 1 then begin
grid_musteri.Canvas.Brush.Color:=$009BE3FF;
grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end else begin
          grid_musteri.Canvas.Brush.Color:=clwhite;
          grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
         end;
          if gdSelected in State then
   grid_musteri.Canvas.Brush.Color := $00FDC7AA;
  grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
(26-04-2022, Saat: 10:34)hi_selamlar Adlı Kullanıcıdan Alıntı: [ -> ]Merhaba,

MySQL olarak düzenlenmiş bir SQL cümlesi.
Hangi DB'yi kullandığınızı bilmediğim için.

Kolay gelsin.

Bende SQL göre düzenledim çalışıyor ama boşluklara NULL yazıyor onu boşluk nasıl yaparım ?



SELECT CASE WHEN STOK_KODU IS NOT NULL THEN STOK_KODU else null end as STOK_KODU,
case WHEN STOK_KODU IS NOT NULL then FISNO else null end as FISNO
FROM TBLSTHAR
group by FISNO,STOK_KODU
with rollup
having FISNO is not null

(26-04-2022, Saat: 10:44)cinarbil Adlı Kullanıcıdan Alıntı: [ -> ]
(26-04-2022, Saat: 09:56)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]Ben şöyle bir kod buldum uyarladım ama renklendirme yapmadı.
if StokKontrol.FieldByName('FISNO').AsString = DBGrid3.DataSource.DataSet.FieldByName('FISNO').AsString  Then
begin
  DBGrid3.Canvas.Font.Color:=clWhite;
  DBGrid3.Canvas.Brush.Color:=clBlack;
end;
if DataCol = 0 then
 DBGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;


Teşekkür ederim. Uyarlayıp kullandım ama hata veriyor


SELECT
case STOK_KODU IS NOT NULL when true then STOK_KODU else null end as STOK_KODU,
case STOK_KODU IS NOT NULL when true then FISNO else null end as FISNO


FROM TBLSTHAR 
group by FISNO, STOK_KODU
with rollup
having FISNO is not null



Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'IS'.
Msg 319, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.

Çalışan kod burada 1. satırı farkı renk 2. satırı farklı kaydet olarak yaptım
bu değiştirerek kendine göre uyarla
procedure Tmusterifrm.grid_musteriDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
 State: TGridDrawState);
begin
if data_form.musteri_sorgu.RecNo  and 1 = 1 then begin
grid_musteri.Canvas.Brush.Color:=$009BE3FF;
grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end else begin
          grid_musteri.Canvas.Brush.Color:=clwhite;
          grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
         end;
          if gdSelected in State then
   grid_musteri.Canvas.Brush.Color := $00FDC7AA;
  grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

Aynı FISNO aynı olanlar bir renk olsun tek olanlar beyaz nasıl yapabilirim?
(26-04-2022, Saat: 10:53)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]
(26-04-2022, Saat: 10:34)hi_selamlar Adlı Kullanıcıdan Alıntı: [ -> ]Merhaba,

MySQL olarak düzenlenmiş bir SQL cümlesi.
Hangi DB'yi kullandığınızı bilmediğim için.

Kolay gelsin.

Bende SQL göre düzenledim çalışıyor ama boşluklara NULL yazıyor onu boşluk nasıl yaparım ?



SELECT CASE WHEN STOK_KODU IS NOT NULL THEN STOK_KODU else null end as STOK_KODU,
case WHEN STOK_KODU IS NOT NULL then FISNO else null end as FISNO
FROM TBLSTHAR
group by FISNO,STOK_KODU
with rollup
having FISNO is not null

(26-04-2022, Saat: 10:44)cinarbil Adlı Kullanıcıdan Alıntı: [ -> ]Çalışan kod burada 1. satırı farkı renk 2. satırı farklı kaydet olarak yaptım
bu değiştirerek kendine göre uyarla
procedure Tmusterifrm.grid_musteriDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
 State: TGridDrawState);
begin
if data_form.musteri_sorgu.RecNo  and 1 = 1 then begin
grid_musteri.Canvas.Brush.Color:=$009BE3FF;
grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end else begin
          grid_musteri.Canvas.Brush.Color:=clwhite;
          grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
         end;
          if gdSelected in State then
   grid_musteri.Canvas.Brush.Color := $00FDC7AA;
  grid_musteri.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;

Aynı FISNO aynı olanlar bir renk olsun tek olanlar beyaz nasıl yapabilirim?

Kabaca yaptım kalanını kendiniz düzenleye bilirsiniz
ince ayarları

 uses data_prg;
procedure TForm1.FormCreate(Sender: TObject);
begin
data_form.siparis_oku('select * from siparis',false);
 test_grid.DataSource := data_form.siparis_kaynak;
 test_grid.Columns[0].Field := data_form.siparis_sorgu.FieldByName('S_IMALAT_NO');
 test_grid.Columns[1].Field := data_form.siparis_sorgu.FieldByName('S_BAYI_ADI');
 test_grid.Columns[2].Field := data_form.siparis_sorgu.FieldByName('S_Grup_kod');
end;

procedure TForm1.test_gridDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
 State: TGridDrawState);
  begin

        if (data_form.siparis_sorgu.RecNo > 0) and (data_form.siparis_sorgu.FieldByName('S_Grup_kod').Text = onceki)  then begin
       test_grid.Canvas.Brush.Color:=Clred;
       test_grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
       end else begin
                 test_grid.Canvas.Brush.Color:=Clyellow;
                 test_grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
                end;


      test_grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      onceki:= data_form.siparis_sorgu.FieldByName('S_Grup_kod').Text
   end;
(26-04-2022, Saat: 11:55)cinarbil Adlı Kullanıcıdan Alıntı: [ -> ]
(26-04-2022, Saat: 10:53)OZCANK Adlı Kullanıcıdan Alıntı: [ -> ]Bende SQL göre düzenledim çalışıyor ama boşluklara NULL yazıyor onu boşluk nasıl yaparım ?



SELECT CASE WHEN STOK_KODU IS NOT NULL THEN STOK_KODU else null end as STOK_KODU,
case WHEN STOK_KODU IS NOT NULL then FISNO else null end as FISNO
FROM TBLSTHAR
group by FISNO,STOK_KODU
with rollup
having FISNO is not null
[quote pid='49245' dateline='1650959599']


Aynı FISNO aynı olanlar bir renk olsun tek olanlar beyaz nasıl yapabilirim?

Kabaca yaptım kalanını kendiniz düzenleye bilirsiniz
ince ayarları

 uses data_prg;
procedure TForm1.FormCreate(Sender: TObject);
begin
data_form.siparis_oku('select * from siparis',false);
 test_grid.DataSource := data_form.siparis_kaynak;
 test_grid.Columns[0].Field := data_form.siparis_sorgu.FieldByName('S_IMALAT_NO');
 test_grid.Columns[1].Field := data_form.siparis_sorgu.FieldByName('S_BAYI_ADI');
 test_grid.Columns[2].Field := data_form.siparis_sorgu.FieldByName('S_Grup_kod');
end;

procedure TForm1.test_gridDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn;
 State: TGridDrawState);
  begin

        if (data_form.siparis_sorgu.RecNo > 0) and (data_form.siparis_sorgu.FieldByName('S_Grup_kod').Text = onceki)  then begin
       test_grid.Canvas.Brush.Color:=Clred;
       test_grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
       end else begin
                 test_grid.Canvas.Brush.Color:=Clyellow;
                 test_grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
                end;


      test_grid.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      onceki:= data_form.siparis_sorgu.FieldByName('S_Grup_kod').Text
   end;
[/quote]

Teşekkür ederim kod için. Bende düzenledim kullandım ama hepsi sarı oldu Smile

procedure TForm29.DBGrid3DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
Var
onceki:String;
begin
  if (StokKontrol.RecNo > 0) and (StokKontrol.FieldByName('FISNO').Text = onceki)  then begin
      DBGrid3.Canvas.Brush.Color:=Clred;
      DBGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
      end else begin
                DBGrid3.Canvas.Brush.Color:=Clyellow;
                DBGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
               end;
     DBGrid3.DefaultDrawColumnCell(Rect, DataCol, Column, State);
     onceki:= StokKontrol.FieldByName('FISNO').Text
  end;
Sayfalar: 1 2 3