コード例 #1
0
ファイル: FClientKullanici.cs プロジェクト: Soul244/lan-test
 public static List <ClientKullanici> SelectAll()
 {
     using (SQLiteConnection Baglanti = new SQLiteConnection(DatabaseManager.ConnectionString))
     {
         using (SQLiteCommand com = new SQLiteCommand("SELECT * FROM ClientKullanicilar", Baglanti))
         {
             Baglanti.Open();
             List <ClientKullanici> itemList = null;
             SQLiteDataReader       rdr      = com.ExecuteReader();
             if (rdr.HasRows)
             {
                 itemList = new List <ClientKullanici>();
                 while (rdr.Read())
                 {
                     ClientKullanici item = new ClientKullanici
                     {
                         KullaniciAdi = (string)rdr["KullaniciAdi"],
                     };
                     itemList.Add(item);
                 }
             }
             Baglanti.Close();
             return(itemList);
         }
     }
 }
コード例 #2
0
ファイル: FClientKullanici.cs プロジェクト: Soul244/lan-test
        //public static int Update(Kullanici item)
        //{
        //    SQLiteCommand com = new SQLiteCommand("UPDATE Testler SET KullaniciAdi=@KullaniciAdi WHERE KullaniciId=@KullaniciId ", DatabaseManager.Baglanti);
        //    com.Parameters.AddWithValue("KullaniciId", item.KullaniciId);
        //    com.Parameters.AddWithValue("KullaniciAdi", item.KullaniciAdi);
        //    return com.ExecuteNonQuery();
        //}

        public static ClientKullanici Select(int kullaniciId)
        {
            using (SQLiteConnection Baglanti = new SQLiteConnection(DatabaseManager.ConnectionString))
            {
                using (SQLiteCommand com = new SQLiteCommand("SELECT * FROM ClientKullanicilar WHERE KullaniciId=@KullaniciId ", Baglanti))
                {
                    Baglanti.Open();
                    ClientKullanici item = null;
                    com.Parameters.AddWithValue("KullaniciId", kullaniciId);
                    SQLiteDataReader rdr = com.ExecuteReader();
                    if (rdr.HasRows)
                    {
                        while (rdr.Read())
                        {
                            item = new ClientKullanici
                            {
                                KullaniciAdi = (string)rdr["KullaniciAdi"],
                            };
                        }
                    }
                    Baglanti.Close();
                    return(item);
                }
            }
        }
コード例 #3
0
ファイル: FClientKullanici.cs プロジェクト: Soul244/lan-test
 public static int Insert(ClientKullanici item, ClientKullanici.SoruOzellikleri soruOzellikleri)
 {
     using (SQLiteConnection Baglanti = new SQLiteConnection(DatabaseManager.ConnectionString))
     {
         using (SQLiteCommand com = new SQLiteCommand("INSERT INTO ClientKullanicilar(KullaniciAdi,Puan,TestId) VALUES(@KullaniciAdi,@Puan, @TestId)", Baglanti))
         {
             Baglanti.Open();
             com.Parameters.AddWithValue("KullaniciAdi", item.KullaniciAdi);
             com.Parameters.AddWithValue("KullaniciAdi", soruOzellikleri.Puan);
             var result = com.ExecuteNonQuery();
             Baglanti.Close();
             return(result);
         }
     }
 }
コード例 #4
0
 // Kullanıcıdan VERİ AL
 private void Client_Received(Client sender, byte[] data)
 {
     Dispatcher.BeginInvoke(new Action(delegate
     {
         for (var i = 0; i < _userCount; i++)
         {
             if (_clients[i].GetId() != sender.GetId())
             {
                 continue;
             }
             object obj = _listener.GetObject(data);
             if (obj == null)
             {
                 continue;
             }
             if (obj.GetType() == typeof(ClientKullanici))
             {
                 ClientKullanici gelenKullanici = ((ClientKullanici)obj);
                 bool yeniKullanici             = true;
                 foreach (var kullanici in _kullanicilar)
                 {
                     if (kullanici.KullaniciAdi == gelenKullanici.KullaniciAdi)
                     {
                         _kullanicilar[_kullanicilar.IndexOf(kullanici)] = gelenKullanici;
                         yeniKullanici = false;
                         break;
                     }
                     else
                     {
                         yeniKullanici = true;
                     }
                 }
                 if (yeniKullanici)
                 {
                     _kullanicilar.Add(gelenKullanici);
                     _kullanicilar[_userCount - 1].Sorular = new List <ClientKullanici.SoruOzellikleri>();
                 }
             }
             _ucGirenKullanici[i].Name.Text = _kullanicilar[i].KullaniciAdi;
             break;
         }
     }));
 }