var
mainform: TCLForm;
AtistirmaliklarPage: TclProPanel;
Button: TClProButton;
ProductID: Integer;
ProductName: string;
ProductPrice: Double;
ProductImageURL: string;
ProductQuery: TclSqlQuery;
procedure SetupDatabaseConnection;
begin
try
Clomosy.DBSQLServerConnect('SQL Server', 'clomosybakkal.database.windows.net', 'nrs', 'n.12345678', 'Bakkal', 1433);
ShowMessage('Veritabanı bağlantısı başarıyla kuruldu!');
except
ShowMessage('Veritabanı bağlantısı kurulamadı: ' );
end;
end;
procedure LoadProductsToPage;
begin
ProductQuery := TclSqlQuery.Create(nil);
try
ProductQuery.Connection := Clomosy.DBSQLServerConnection;
ProductQuery.SQL.Text := 'SELECT ProductID, ProductName, ProductPrice, ProductImageURL FROM Products'; // Category yok, sorguyu düzelttik
try
ProductQuery.Open;
except
ShowMessage('Ürün sorgusu açılamadı: ' );
end;
while not ProductQuery.Eof do
begin
try
ProductID := ProductQuery.FieldByName('ProductID').AsInteger;
ProductName := ProductQuery.FieldByName('ProductName').AsString;
ProductPrice := ProductQuery.FieldByName('ProductPrice').AsFloat;
ProductImageURL := ProductQuery.FieldByName('ProductImageURL').AsString;
// Buton oluştur ve yapılandır
Button := mainform.AddNewProButton(AtistirmaliklarPage, 'Button', '');
// Button := TClProButton.Create(AtistirmaliklarPage);
try
Button.Width := 120;
Button.Height := 120;
// Button.Text := ProductName;
if Assigned(mainform) then
mainform.SetImage(Button, ProductImageURL);
// Diğer buton özelliklerini ayarla
Button.Margins.Bottom := 400;
Button.Margins.Right := 100;
Button.clProSettings.RoundHeight := 10;
Button.clProSettings.RoundWidth := 10;
Button.clProSettings.FontVertAlign := palCenter;
Button.clProSettings.FontHorzAlign := palCenter;
Button.clProSettings.TextSettings.Font.Style := [fsBold];
Button.clProSettings.BorderColor := clAlphaColor.clHexToColor('#d1d1d1');
Button.clProSettings.BorderWidth := 1;
Button.SetclProSettings(Button.clProSettings);
except
ShowMessage('Buton oluşturulurken hata: ' );
end;
ProductQuery.Next;
except
ShowMessage('Ürün bilgileri işlenirken hata: ' );
end;
end;
finally
ProductQuery.Close;
ProductQuery.Free;
end;
end;
procedure AddProductPage;
begin
try
AtistirmaliklarPage := mainform.AddNewProPanel(mainform, 'AtistirmaliklarPage');
if Assigned(AtistirmaliklarPage) then
begin
AtistirmaliklarPage.Align := alClient;
AtistirmaliklarPage.Margins.Left := 10;
AtistirmaliklarPage.Margins.Right := 10;
AtistirmaliklarPage.Margins.Top := 5;
AtistirmaliklarPage.Margins.Bottom := 10;
AtistirmaliklarPage.clProSettings.BackgroundColor := clAlphaColor.clHexToColor('#ffffff');
AtistirmaliklarPage.SetclProSettings(AtistirmaliklarPage.clProSettings);
// Ürünleri sayfaya yükle
try
LoadProductsToPage;
except
ShowMessage('Ürünleri sayfaya yüklerken hata: ' );
end;
end
else
ShowMessage('Atıştırmalıklar sayfası oluşturulamadı');
except
ShowMessage('Panel oluşturulurken hata: ' );
end;
end;
begin
mainform := TCLForm.Create(nil);
try
mainform.SetFormColor('#CBEDD5', '', clGNone);
SetupDatabaseConnection;
try
AddProductPage;
except
ShowMessage('Ana form çalıştırılırken hata: ' );
end;
mainform.Run;
except
ShowMessage('Ana form çalıştırılırken hata: ' );
end;
end.