Sayfayı Yazdır | Pencereyi Kapat

FillProducts

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Clomosy ile değişken kullanımı
Forum Tanımlaması: TRObject dili ile değişken tanımlaması ve ekranda gösterme
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=1394
Tarih: 25 Şubat 2026 Saat 15:24
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: FillProducts
Mesajı Yazan: ebrarflz
Konu: FillProducts
Mesaj Tarihi: 25 Şubat 2026 Saat 11:39
var
  UrunForm: TClForm;
  ScrollBox: TClVertScrollBox;
  UrunArama: TclProSearchEdit;
  UrunButon: TClProButton;
  btnBack: TclProButton;
  lblTitle: TclProLabel;
  RestObj: TClRest;
  HamMetin, UrunAdi: String;
  P1, P2: Integer;
  UrunListesi: TclStringList;
  i: Integer;
void GoBack;
{
  UrunForm.clHide;
}
void OnSearchChange;
{
  ShowMessage('Aranıyor: ' + UrunArama.Text);
}
void FillProducts;
{
  RestObj = TClRest.Create;
  try
    RestObj.BaseURL = 'http://localhost:5007/api/Product/GetProductList'; 
    RestObj.Method = rmGet;
    RestObj.Execute;
    ShowMessage(RestObj.response);
    if (RestObj.StatusCode == 200)
    {
      HamMetin = RestObj.Response;
      
      while (Pos('warehouseName":"', HamMetin) > 0)
      {
        P1 = Pos('warehouseName":"', HamMetin) + 16;
        HamMetin = Copy(HamMetin, P1, Length(HamMetin));
        P2 = Pos('"', HamMetin);
        UrunAdi = Copy(HamMetin, 1, P2 - 1);
        ShowMessage(UrunAdi);
        UrunButon = UrunForm.AddNewProButton(ScrollBox, 'btn' + IntToStr(P1), UrunAdi);
        UrunButon.Align = alTop;
        UrunButon.Height = 65;
        UrunButon.Margins.Top = 8;
        UrunButon.Margins.Left = 15;
        UrunButon.Margins.Right = 15;     
        clComponent.SetupComponent(UrunButon, '{"BackgroundColor":"#FFFFFF", "TextColor":"#C71585", "TextSize":15, "RoundHeight":12, "BorderColor":"#C71585", "BorderWidth":1, "TextBold":"yes"}');
        HamMetin = Copy(HamMetin, P2, Length(HamMetin));
      }
    }
  except
    ShowMessage('Ürünler yüklenirken hata oluştu!'+'Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
  }
}
{
  UrunForm = TClForm.Create(Self);
  UrunForm.SetFormColor('#FFF0F5', '', clGNone); 

  lblTitle = UrunForm.AddNewProLabel(UrunForm, 'lblTitle', 'ÜRÜN LİSTESİ');
  lblTitle.Align = alTop;
  lblTitle.Height = 50;
  clComponent.SetupComponent(lblTitle, '{"TextSize":22, "TextColor":"#C71585", "TextHorizontalAlign":"center", "TextBold":"yes"}');

  UrunArama = UrunForm.AddNewProSearchEdit(UrunForm, 'UrunArama', 'Ürün adı ile ara...');
  UrunArama.Align = alTop;
  UrunArama.Height = 45;
  UrunArama.Margins.Left = 15;
  UrunArama.Margins.Right = 15;
  UrunArama.Margins.Bottom = 10;
  clComponent.SetupComponent(UrunArama, '{"RoundHeight":10, "BorderColor":"#C71585", "BorderWidth":1}');

  ScrollBox = UrunForm.AddNewVertScrollBox(UrunForm, 'ScrollBox');
  ScrollBox.Align = alClient;

  btnBack = UrunForm.AddNewProButton(UrunForm, 'btnBack', '<< ANA MENÜYE DÖN');
  btnBack.Align = alBottom;
  btnBack.Height = 55;
  clComponent.SetupComponent(btnBack, '{"BackgroundColor":"#C71585", "TextColor":"#FFFFFF", "RoundHeight":10, "TextBold":"yes"}');
  UrunForm.AddNewEvent(btnBack, tbeOnClick, 'GoBack');
  FillProducts;
  UrunForm.Run;
}
https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">



Cevaplar:
Mesajı Yazan: ebrarflz
Mesaj Tarihi: 25 Şubat 2026 Saat 11:41
Örnek Json[
  {
    "warehouseName": "Fondöten",
    "id": "Sistem Stok: 15",
    "barcode": "868001"
  },
  {
    "warehouseName": "Allık",
    "id": "Sistem Stok: 22",
    "barcode": "868002"
  },
  {
    "warehouseName": "Bronzer",
    "id": "Sistem Stok: 10",
    "barcode": "868003"
  },
  {
    "warehouseName": "Nemlendirici",
    "id": "Sistem Stok: 40",
    "barcode": "868004"
  },
  {
    "warehouseName": "Kapatıcı",
    "id": "Sistem Stok: 18",
    "barcode": "868005"
  },
  {
    "warehouseName": "Maskara",
    "id": "Sistem Stok: 25",
    "barcode": "868006"
  },
  {
    "warehouseName": "Aydınlatıcı",
    "id": "Sistem Stok: 12",
    "barcode": "868007"
  },
  {
    "warehouseName": "Far Paleti",
    "id": "Sistem Stok: 7",
    "barcode": "868008"
  },
  {
    "warehouseName": "Ruj",
    "id": "Sistem Stok: 50",
    "barcode": "868009"
  },
  {
    "warehouseName": "Fırça Seti",
    "id": "Sistem Stok: 5",
    "barcode": "868010"
  }
]
https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">


Mesajı Yazan: M-Guney
Mesaj Tarihi: 25 Şubat 2026 Saat 11:53
Fill Products kısmında JsonQuery kullanarak bu şekilde yaptım.
https://www.docs.clomosy.com/index.php?title=JSON_Data_Source" rel="nofollow - https://www.docs.clomosy.com/index.php?title=JSON_Data_Source
Bu linkten inceleyebilirsin

var
  UrunForm: TClForm;
  ScrollBox: TClVertScrollBox;
  UrunArama: TclProSearchEdit;
  UrunButon: TClProButton;
  btnBack: TclProButton;
  lblTitle: TclProLabel;
  RestObj: TClRest;
  ProductData: TclJSONQuery;
  UrunAdi, UrunBarkod: String;

void GoBack;
{
  UrunForm.clHide;
}

void OnSearchChange;
{
  ShowMessage('Aranıyor: ' + UrunArama.Text);
}

void FillProducts;
{
  RestObj = TClRest.Create;
  try
    RestObj.BaseURL = 'http://localhost:5007/api/Product/GetProductList'; 
    RestObj.Method = rmGet;
    RestObj.Execute;
    
    if (RestObj.StatusCode == 200)
    {
      ProductData = Clomosy.ClDataSetFromJSON(RestObj.Response);
      
      while (ProductData.Eof == False)
      {
        UrunAdi = ProductData.FieldByName('warehouseName').AsString;
        UrunBarkod = ProductData.FieldByName('barcode').AsString;
        
        UrunButon = UrunForm.AddNewProButton(ScrollBox, 'btn_' + UrunBarkod, UrunAdi);
        UrunButon.Align = alTop;
        UrunButon.Height = 65;
        UrunButon.Margins.Top = 8;
        UrunButon.Margins.Left = 15;
        UrunButon.Margins.Right = 15;     
        clComponent.SetupComponent(UrunButon, '{"BackgroundColor":"#FFFFFF", "TextColor":"#C71585", "TextSize":15, "RoundHeight":12, "BorderColor":"#C71585", "BorderWidth":1, "TextBold":"yes"}');
        
        ProductData.Next;
      }
    }
    else
    {
      ShowMessage('Sunucu Hatası. Kod: ' + IntToStr(RestObj.StatusCode));
    }
  except
    ShowMessage('Ürünler yüklenirken hata oluştu! Hata Mesajı: ' + LastExceptionMessage);
  }
}

{
  UrunForm = TClForm.Create(Self);
  UrunForm.SetFormColor('#FFF0F5', '', clGNone); 

  lblTitle = UrunForm.AddNewProLabel(UrunForm, 'lblTitle', 'ÜRÜN LİSTESİ');
  lblTitle.Align = alTop;
  lblTitle.Height = 50;
  clComponent.SetupComponent(lblTitle, '{"TextSize":22, "TextColor":"#C71585", "TextHorizontalAlign":"center", "TextBold":"yes"}');

  UrunArama = UrunForm.AddNewProSearchEdit(UrunForm, 'UrunArama', 'Ürün adı ile ara...');
  UrunArama.Align = alTop;
  UrunArama.Height = 45;
  UrunArama.Margins.Left = 15;
  UrunArama.Margins.Right = 15;
  UrunArama.Margins.Bottom = 10;
  clComponent.SetupComponent(UrunArama, '{"RoundHeight":10, "BorderColor":"#C71585", "BorderWidth":1}');

  ScrollBox = UrunForm.AddNewVertScrollBox(UrunForm, 'ScrollBox');
  ScrollBox.Align = alClient;

  btnBack = UrunForm.AddNewProButton(UrunForm, 'btnBack', '<< ANA MENÜYE DÖN');
  btnBack.Align = alBottom;
  btnBack.Height = 55;
  clComponent.SetupComponent(btnBack, '{"BackgroundColor":"#C71585", "TextColor":"#FFFFFF", "RoundHeight":10, "TextBold":"yes"}');
  UrunForm.AddNewEvent(btnBack, tbeOnClick, 'GoBack');
  
  FillProducts;
  UrunForm.Run;
}




.
https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" rel="nofollow - https://static.cloudflareinsights.com/beacon.min.js/vcd15cbe7772f49c399c6a5babf22c1241717689176015" integrity="sha512-ZpsOmlRQV6y907TI0dKBHq9Md29nnaEIPlkf84rnaERnq6zvWvPUqr2ft8M1aS28oN72PdrCzSjY4U6VaAw1EQ==" data-cf-beacon="{"version":"2024.11.0","token":"439455f3e46c40b98dbd42a2f1a954d8","r":1,"server_timing":{"name":{"cfCacheStatus":true,"cfEdge":true,"cfExtPri":true,"cfL4":true,"cfOrigin":true,"cfSpeedBrain":true},"location_startswith":null}}" crossorigin="anonymous">



Sayfayı Yazdır | Pencereyi Kapat

Forum Software by Web Wiz Forums® version 12.07 - https://www.webwizforums.com
Copyright ©2001-2024 Web Wiz Ltd. - https://www.webwiz.net