Clomosy | Forum Ana Sayfa
Forum Anasayfa Forum Anasayfa > Genel Programlama > Genel İşlemler
  Aktif Konular Aktif Konular RSS - SQL ekleme
  SSS SSS  Forumu Ara   Etkinlikler   Kayıt Ol Kayıt Ol  Giriş Giriş

Clomosy Resmi Forum Sitesidir. Amacımız kullanıcılarımıza, iş ortaklarımıza, danışmanlara, yazılımcılara programlarımız hakkında destek ve bilgi vermektir.

SQL ekleme

 Yanıt Yaz Yanıt Yaz
Yazar
Mesaj
  Konu Arama Konu Arama  Topic Seçenekleri Topic Seçenekleri
dilarayaprak Açılır Kutu İzle
Yeni Üye
Yeni Üye


Kayıt Tarihi: 07 Temmuz 2025
Konum: konya
Durum: Aktif Değil
Puanlar: 24
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı dilarayaprak Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Konu: SQL ekleme
    Gönderim Zamanı: 21 Temmuz 2025 Saat 14:57
SQLlite ile veritabanı eklemeye çalısıyorum ancak aktif kullanıcı özelliğini eklediğimde çalışmamaya başladı


var
  kelimeForm: TclForm;
  kartPanel: TclProPanel;
  frontFace, backFace: TclProPanel;
  lblEnglish, lblTurkish: TclProLabel;
  kartImageFront, kartImageBack: TclProImage;
  txtInput: TclProEdit;
  btnSorgula: TclProButton;
  restAI: TclRest;
  aktifKullaniciAdi, prompt, veri, cevap: String;

void BtnSorgulaClick;
{
  if (txtInput.Text == '') {
    ShowMessage('Lütfen bir kelime girin!');
  } else {
    lblEnglish.Caption = txtInput.Text;
    lblTurkish.Caption = '';
    backFace.Visible = False;
    frontFace.Visible = True;

    prompt = txtInput.Text;

    restAI.Method = rmPost;
    restAI.ContentType = 'application/json';
    restAI.Body =
      '{' +
      '  "contents": [' +
      '    {' +
      '      "parts": [' +
      '        {' +
      '          "text": "Girilen kelimeyi Türkçeye çevir. Sadece çeviriyi yaz: ' + prompt + '"' +
      '        }' +
      '      ]' +
      '    }' +
      '  ]' +
      '}';

    restAI.ExecuteAsync;

    txtInput.Text = '';
  }
}

void GetAIResponse;
{
  veri = restAI.Response;
  cevap = Clomosy.CLParseJson(veri, 'candidates.0.content.parts.0.text');
  lblTurkish.Text = cevap;
  frontFace.Visible = False;
  backFace.Visible = True;

  ShowMessage('Çeviri: ' + cevap);

  if (aktifKullaniciAdi == '') {
    ShowMessage('HATA: Kullanıcı adı alınamadı. Önce giriş yapın.');
  } else {
    
    
    Clomosy.DBSQLiteQuery.Close;
    Clomosy.DBSQLiteQuery.SQL.Text =
      'CREATE TABLE IF NOT EXISTS kartlar (id INTEGER PRIMARY KEY AUTOINCREMENT, kullanici_adi TEXT, english TEXT, turkish TEXT)';
    Clomosy.DBSQLiteQuery.OpenOrExecute;


    Clomosy.DBSQLiteQuery.Close;
    Clomosy.DBSQLiteQuery.SQL.Text =
      'INSERT INTO kartlar (kullanici_adi, english, turkish) VALUES (' +
      QuotedStr(aktifKullaniciAdi) + ',' +
      QuotedStr(lblEnglish.Caption) + ',' +
      QuotedStr(cevap) + ')';
    Clomosy.DBSQLiteQuery.OpenOrExecute;

    ShowMessage('kart kaydedildi.');
  }
}


void FlipCard;
{
  if (frontFace.Visible == True) {
    frontFace.Visible = False;
    backFace.Visible = True;
  } else {
    frontFace.Visible = True;
    backFace.Visible = False;
  }
}

{
  kelimeForm = TclForm.Create(Self);
  kelimeForm.clSetCaption('İngilizce → Türkçe Kart');
  kelimeForm.SetFormBGImage('https://i.imgur.com/fPwWs0H.jpeg');

  restAI = TclRest.Create;
  restAI.OnCompleted = 'GetAIResponse';

  txtInput = kelimeForm.AddNewProEdit(kelimeForm, 'txtInput', '');
  txtInput.Align = alTop;
  txtInput.Margins.Top = 20;
  txtInput.Height = 40;

  btnSorgula = kelimeForm.AddNewProButton(kelimeForm, 'btnSorgula', 'ÇEVİR');
  btnSorgula.Align = alTop;
  btnSorgula.Height = 40;
  kelimeForm.AddNewEvent(btnSorgula, tbeOnClick, 'BtnSorgulaClick');

  kartPanel = kelimeForm.AddNewProPanel(kelimeForm, 'kartPanel');
  kartPanel.Width = 300;
  kartPanel.Height = 200;
  kartPanel.Position.X = (kelimeForm.clWidth - kartPanel.Width) / 2;
  kartPanel.Position.Y = (kelimeForm.clHeight - kartPanel.Height) / 2;
  kartPanel.ClProSettings.RoundWidth = 20;
  kartPanel.ClProSettings.RoundHeight = 20;
  kartPanel.SetclProSettings(kartPanel.ClProSettings);

  frontFace = kelimeForm.AddNewProPanel(kartPanel, 'frontFace');
  frontFace.Align = alClient;
  frontFace.Visible = True;

  kartImageFront = kelimeForm.AddNewProImage(frontFace, 'kartImageFront');
  kartImageFront.Align = alClient;
  kartImageFront.ClProSettings.PictureSource = 'https://i.imgur.com/wLCaAxp.png';
  kartImageFront.SetclProSettings(kartImageFront.ClProSettings);

  lblEnglish = kelimeForm.AddNewProLabel(frontFace, 'lblEnglish', '');
  lblEnglish.Align = alCenter;
  lblEnglish.ClProSettings.FontSize = 26;
  lblEnglish.ClProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff');
  lblEnglish.SetclProSettings(lblEnglish.ClProSettings);

  backFace = kelimeForm.AddNewProPanel(kartPanel, 'backFace');
  backFace.Align = alClient;
  backFace.Visible = False;

  kartImageBack = kelimeForm.AddNewProImage(backFace, 'kartImageBack');
  kartImageBack.Align = alClient;
  kartImageBack.ClProSettings.PictureSource = 'https://i.imgur.com/wLCaAxp.png';
  kartImageBack.SetclProSettings(kartImageBack.ClProSettings);

  lblTurkish = kelimeForm.AddNewProLabel(backFace, 'lblTurkish', '');
  lblTurkish.Align = alCenter;
  lblTurkish.ClProSettings.FontSize = 26;
  lblTurkish.ClProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff');
  lblTurkish.SetclProSettings(lblTurkish.ClProSettings);

  kelimeForm.AddNewEvent(kartPanel, tbeOnClick, 'FlipCard');

  kelimeForm.Run;
}
Yukarı Dön
Emr.Erkmn Açılır Kutu İzle
Moderatör
Moderatör


Kayıt Tarihi: 28 Şubat 2025
Durum: Aktif Değil
Puanlar: 146
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı Emr.Erkmn Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Gönderim Zamanı: 18 Saat 26 Dakika Önce Saat 16:26
var
  kelimeForm: TclForm;
  kartPanel: TclProPanel;
  frontFace, backFace: TclProPanel;
  lblEnglish, lblTurkish: TclProLabel;
  kartImageFront, kartImageBack: TclProImage;
  txtInput: TclProEdit;
  btnSorgula: TclProButton;
  restAI: TclRest;
  aktifKullaniciAdi, prompt, veri, cevap: String;

void BtnSorgulaClick;
{
  if (txtInput.Text == '') {
    ShowMessage('Lütfen bir kelime girin!');
  } else {
    lblEnglish.Caption = txtInput.Text;
    lblTurkish.Caption = '';
    backFace.Visible = False;
    frontFace.Visible = True;

    prompt = txtInput.Text;

    restAI.Method = rmPost;
    restAI.ContentType = 'application/json';
    restAI.Body =
      '{' +
      '  "contents": [' +
      '    {' +
      '      "parts": [' +
      '        {' +
      '          "text": "Girilen kelimeyi Türkçeye çevir. Sadece çeviriyi yaz: ' + prompt + '"' +
      '        }' +
      '      ]' +
      '    }' +
      '  ]' +
      '}';

    restAI.ExecuteAsync;

    txtInput.Text = '';
  }
}

void GetAIResponse;
{
  veri = restAI.Response;
  cevap = Clomosy.CLParseJson(veri, 'candidates.0.content.parts.0.text');
  lblTurkish.Text = cevap;
  frontFace.Visible = False;
  backFace.Visible = True;

  ShowMessage('Çeviri: ' + cevap);

  if (aktifKullaniciAdi == '') {
    aktifKullaniciAdi = 'Misafir'; // Varsayılan kullanıcı
    ShowMessage('Kullanıcı adı bulunamadı, "Misafir" olarak kaydediliyor.');
  }
  
  try {
    // Veritabanı bağlantısı
    Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'kelime_kartlari.db3', '');
    
    // Tablo oluştur
    Clomosy.DBSQLiteQuery.Close;
    Clomosy.DBSQLiteQuery.SQL.Text =
      'CREATE TABLE IF NOT EXISTS kartlar (' +
      'id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
      'kullanici_adi TEXT, ' +
      'english TEXT, ' +
      'turkish TEXT, ' +
      'tarih DATETIME DEFAULT CURRENT_TIMESTAMP' +
      ')';
    Clomosy.DBSQLiteQuery.OpenOrExecute;

    // Kartı kaydet
    Clomosy.DBSQLiteQuery.Close;
    Clomosy.DBSQLiteQuery.SQL.Text =
      'INSERT INTO kartlar (kullanici_adi, english, turkish) VALUES (' +
      QuotedStr(aktifKullaniciAdi) + ',' +
      QuotedStr(lblEnglish.Caption) + ',' +
      QuotedStr(cevap) + ')';
    Clomosy.DBSQLiteQuery.OpenOrExecute;

    ShowMessage('Kart başarıyla kaydedildi!');
  }
  except {
    ShowMessage('Veritabanı hatası: ' + LastExceptionMessage);
  }
}
}
void FlipCard;
{
  if (frontFace.Visible == True) {
    frontFace.Visible = False;
    backFace.Visible = True;
  } else {
    frontFace.Visible = True;
    backFace.Visible = False;
  }
}

void SetAktifKullanici(kullaniciAdi: String);
{
  aktifKullaniciAdi = kullaniciAdi;
  ShowMessage('Aktif kullanıcı: ' + aktifKullaniciAdi);
}

void VeritabaniBaslat;
{
  try {
    Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'kelime_kartlari.db3', '');
    
    // Tablo oluştur
    Clomosy.DBSQLiteQuery.Close;
    Clomosy.DBSQLiteQuery.SQL.Text =
      'CREATE TABLE IF NOT EXISTS kartlar (' +
      'id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
      'kullanici_adi TEXT, ' +
      'english TEXT, ' +
      'turkish TEXT, ' +
      'tarih DATETIME DEFAULT CURRENT_TIMESTAMP' +
      ')';
    Clomosy.DBSQLiteQuery.OpenOrExecute;
    
    ShowMessage('Veritabanı başarıyla başlatıldı!');
  }
  except {
    ShowMessage('Veritabanı başlatma hatası: ' + LastExceptionMessage);
  }
}
}
{
  kelimeForm = TclForm.Create(Self);
  kelimeForm.clSetCaption('İngilizce → Türkçe Kart');
  kelimeForm.SetFormBGImage('https://i.imgur.com/fPwWs0H.jpeg');

  aktifKullaniciAdi = 'Misafir';

  VeritabaniBaslat;

  restAI = TclRest.Create;
  restAI.OnCompleted = 'GetAIResponse';

  txtInput = kelimeForm.AddNewProEdit(kelimeForm, 'txtInput', '');
  txtInput.Align = alTop;
  txtInput.Margins.Top = 20;
  txtInput.Height = 40;

  btnSorgula = kelimeForm.AddNewProButton(kelimeForm, 'btnSorgula', 'ÇEVİR');
  btnSorgula.Align = alTop;
  btnSorgula.Height = 40;
  kelimeForm.AddNewEvent(btnSorgula, tbeOnClick, 'BtnSorgulaClick');

  kartPanel = kelimeForm.AddNewProPanel(kelimeForm, 'kartPanel');
  kartPanel.Width = 300;
  kartPanel.Height = 200;
  kartPanel.Position.X = (kelimeForm.clWidth - kartPanel.Width) / 2;
  kartPanel.Position.Y = (kelimeForm.clHeight - kartPanel.Height) / 2;
  kartPanel.ClProSettings.RoundWidth = 20;
  kartPanel.ClProSettings.RoundHeight = 20;
  kartPanel.SetclProSettings(kartPanel.ClProSettings);

  frontFace = kelimeForm.AddNewProPanel(kartPanel, 'frontFace');
  frontFace.Align = alClient;
  frontFace.Visible = True;

  kartImageFront = kelimeForm.AddNewProImage(frontFace, 'kartImageFront');
  kartImageFront.Align = alClient;
  kartImageFront.ClProSettings.PictureSource = 'https://i.imgur.com/wLCaAxp.png';
  kartImageFront.SetclProSettings(kartImageFront.ClProSettings);

  lblEnglish = kelimeForm.AddNewProLabel(frontFace, 'lblEnglish', '');
  lblEnglish.Align = alCenter;
  lblEnglish.ClProSettings.FontSize = 26;
  lblEnglish.ClProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff');
  lblEnglish.SetclProSettings(lblEnglish.ClProSettings);

  backFace = kelimeForm.AddNewProPanel(kartPanel, 'backFace');
  backFace.Align = alClient;
  backFace.Visible = False;

  kartImageBack = kelimeForm.AddNewProImage(backFace, 'kartImageBack');
  kartImageBack.Align = alClient;
  kartImageBack.ClProSettings.PictureSource = 'https://i.imgur.com/wLCaAxp.png';
  kartImageBack.SetclProSettings(kartImageBack.ClProSettings);

  lblTurkish = kelimeForm.AddNewProLabel(backFace, 'lblTurkish', '');
  lblTurkish.Align = alCenter;
  lblTurkish.ClProSettings.FontSize = 26;
  lblTurkish.ClProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff');
  lblTurkish.SetclProSettings(lblTurkish.ClProSettings);

  kelimeForm.AddNewEvent(kartPanel, tbeOnClick, 'FlipCard');

  kelimeForm.Run;
}
Yukarı Dön
 Yanıt Yaz Yanıt Yaz

Forum Atla Forum İzinleri Açılır Kutu İzle

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.

Bu Sayfa 0,031 Saniyede Yüklendi.