Sayfayı Yazdır | Pencereyi Kapat

SQL ekleme

Nereden Yazdırıldığı: Clomosy | Forum
Kategori: Genel Programlama
Forum Adı: Genel İşlemler
Forum Tanımlaması: TRObject dili ile programlama yaparken karşılaşılan genel işlemler
URL: https://forum.clomosy.com.tr/forum_posts.asp?TID=1111
Tarih: 22 Temmuz 2025 Saat 01:02
Program Versiyonu: Web Wiz Forums 12.07 - https://www.webwizforums.com


Konu: SQL ekleme
Mesajı Yazan: dilarayaprak
Konu: SQL ekleme
Mesaj Tarihi: 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.BaseUrl = ' https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=xxxxxxxxxxxxxx" rel="nofollow - https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=xxxxxxxxxxxxxx ';
    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" rel="nofollow - 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" rel="nofollow - 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" rel="nofollow - 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;
}



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