Clomosy | Forum Ana Sayfa
Forum Anasayfa Forum Anasayfa > Genel Programlama > Genel İşlemler
  Aktif Konular Aktif Konular RSS - listedeki elemanlara tıklama
  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.

listedeki elemanlara tıklama

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

Kayıt Tarihi: 07 Temmuz 2025
Konum: konya
Durum: Aktif Değil
Puanlar: 8
Mesaj Seçenekleri Mesaj Seçenekleri   Teşekkürler (0) Teşekkürler(0)   Alıntı goksuselvi Alıntı  Yanıt YazCevapla Mesajın Direkt Linki Konu: listedeki elemanlara tıklama
    Gönderim Zamanı: 9 Saat 35 Dakika Önce Saat 22:37
var
  analizForm: TclForm;
  MainPnl: TCLProPanel;
  ListView1: TClProListView;
  DesignerPanel1: TClProListViewDesignerPanel;
  habitLabel: TClProLabel;
  addBtn: TClProButton;
  Edit1: TClProEdit;
  Qry: TClSQLiteQuery;
  habitId, habitName:TClProLabel;
void SqLiteInsertData;
  {
    try
      Clomosy.DBSQLiteQuery.Sql.Text = '
    INSERT INTO Habits (habitId, habitName) VALUES (1, ''İngilizce Çalışmak'');
    INSERT INTO Habits (habitId, habitName) VALUES (2, ''Spor Yapmak'');
    INSERT INTO Habits (habitId, habitName) VALUES (3, ''Meditasyon'');
    INSERT INTO Habits (habitId, habitName) VALUES (4, ''Kitap Okumak'');';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
      
      ShowMessage('Adding data to the table was successful!');
    except
     ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    }
  }




void SqLiteConnectionCreateTable;
  var
    TableExists: Boolean;
  {
    try
      Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBHabits.db3', '');
 
      // Check if the table exists
      Clomosy.DBSQLiteQuery.Sql.Text = 'SELECT name FROM sqlite_master WHERE type="table" AND name="Habits";';
      Clomosy.DBSQLiteQuery.OpenOrExecute;
      
      // Check the results
      TableExists = not Clomosy.DBSQLiteQuery.Eof;
      
      // Create the table if it does not exist
      if not (TableExists)
      {
        Clomosy.DBSQLiteQuery.Sql.Text = 'CREATE TABLE Habits(habitId INTEGER NOT NULL,
        habitName TEXT NOT NULL,
        PRIMARY KEY (habitId))';
        Clomosy.DBSQLiteQuery.OpenOrExecute;
        
        ShowMessage('Table successfully added to the database!');
        SqLiteInsertData;
      } else
      {
        ShowMessage('The habits table already exists.');
      }

    except
     ShowMessage('Exception Class: '+LastExceptionClassName+' Exception Message: '+LastExceptionMessage);
    }
  }
  
void GetData;
  var
    Qry : TClSQLiteQuery;
  {
    try
      Qry = Clomosy.DBSQLiteQueryWith('SELECT habitId as clRecord_GUID, habitName from Habits');
      Qry.OpenOrExecute;
      if (Qry.Found)
      {
        ListView1.clLoadProListViewDataFromDataset(Qry);
      }
      
    except
      ShowMessage('Exception class: '+LastExceptionClassName+' Exception Message: ' +LastExceptionMessage);
    } 
    
  }
  
// --------------------------------------------------------------------
// HABIT EKLE
void AddHabit
{
  try
    Clomosy.DBSQLiteConnect(Clomosy.AppFilesPath + 'DBHabits.db3', '');
    Clomosy.DBSQLiteQuery.Sql.Text = 
      'INSERT INTO Habits (habitName) VALUES (' + QuotedStr(Edit1.Text) + ')';
    Clomosy.DBSQLiteQuery.OpenOrExecute;

    ShowMessage('Alışkanlık eklendi: ' + Edit1.Text);

    //LoadHabitsToListView;
  except
    ShowMessage('Ekleme hatası: ' + LastExceptionMessage);
  }
}

// --------------------------------------------------------------------
// LİSTEVIEW TASARIM PANELİ
void CreateDesignerPanel
{
  DesignerPanel1 = analizForm.AddNewProListViewDesignerPanel(ListView1, 'DesignerPanel1');
  DesignerPanel1.Height = 100;
  DesignerPanel1.Width = 200;
  DesignerPanel1.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#B3FCE5');
  DesignerPanel1.clProSettings.BorderColor = clAlphaColor.clHexToColor('#16FF8C');
  DesignerPanel1.clProSettings.BorderWidth = 2;
  DesignerPanel1.clProSettings.RoundHeight = 20;
  DesignerPanel1.clProSettings.RoundWidth = 20;
  DesignerPanel1.SetclProSettings(DesignerPanel1.clProSettings);

  ListView1.SetDesignerPanel(DesignerPanel1);

  habitName = analizForm.AddNewProLabel(DesignerPanel1, 'habitName', '-');
  habitName.Align = alClient;
  habitName.clProSettings.FontSize = 20;
  habitName.Margins.Top = 10;
  habitName.Margins.Left = 10;
  habitname.SetclProSettings(habitname.clProSettings); 
  DesignerPanel1.AddPanelObject(habitname, clText);
 
}

// --------------------------------------------------------------------
// LİSTEVIEW OLUŞTUR
void CreateListView
{
  ListView1 = analizForm.AddNewProListView(MainPnl, 'ListView1');
  ListView1.Align = alClient;
  ListView1.Margins.Bottom = 20;
  ListView1.Margins.Top = 20;
  ListView1.Margins.Right = 20;
  ListView1.Margins.Left = 20;
  ListView1.clProSettings.ViewType = lvIcon;
  ListView1.clProSettings.ColCount = 1;
  ListView1.clProSettings.ItemHeight = 100;
  ListView1.clProSettings.ItemSpace = 10;
  ListView1.clProSettings.RoundHeight = 5;
  ListView1.clProSettings.RoundWidth = 5;
  ListView1.SetclProSettings(ListView1.clProSettings);
}

// --------------------------------------------------------------------
// BUTON CLICK EVENTİ
void OnAddBtnClick
{
  AddHabit;
}

{
  analizForm = TclForm.Create(Self);

  MainPnl = analizForm.AddNewProPanel(analizForm, 'MainPnl');
  MainPnl.Align = alClient;

  Edit1 = analizForm.AddNewProEdit(MainPnl, 'Edit1', 'Write something...');
  Edit1.Align = alTop;
  Edit1.Height = 50;
  Edit1.Margins.Top = 20;
  Edit1.Margins.Left = 20;
  Edit1.Margins.Right = 20;
  Edit1.clProSettings.BackGroundColor = clAlphaColor.clHexToColor('#CDB4DB'); 
  Edit1.clProSettings.IsTransparent = True;
  Edit1.clProSettings.IsFill = False;
  Edit1.clProSettings.IsRound = True;
  Edit1.clProSettings.RoundHeight = 20;
  Edit1.clProSettings.RoundWidth = 20;
  Edit1.clProSettings.FontSize = 16;
  Edit1.clProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff');
  Edit1.clProSettings.BorderColor = clAlphaColor.clHexToColor('#ffffff');
  Edit1.SetclProSettings(Edit1.clProSettings);
 
  addBtn = analizForm.AddNewProButton(MainPnl, 'addBtn', 'Ekle');
  addBtn.Align = alBottom;
  addBtn.Height = 50;
  addBtn.clProSettings.IsRound = True;
  addBtn.SetclProSettings(addBtn.clProSettings);
  analizForm.AddNewEvent(addBtn, tbeOnClick, 'OnAddBtnClick');
  CreateListView;
  CreateDesignerPanel;
  SqLiteConnectionCreateTable;
  GetData;
  analizForm.Run;
}
//////analizform.AddNewEvent(ListView1, tbeOnItemClick, 'onItemClicked');

void onItemClicked

{

habitname.Text = clGetStringAfter(PListView.clSelectedItemData(clText), ': ');

}

//// bu yapıyı kullanmaya çalıştım her bir alışkanlığa bastığımda yeni bir unit için ama kendi kodumda yapamadım yardımcı olursanız sevinirim

      





< id="BFI_" style="width: 1px; height: 1px; display: none;">
göksu
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,080 Saniyede Yüklendi.