using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components; using System.Diagnostics; using System.Net.Http; using System.Net.Http.Json; using System.Text.Json; using System.Data; using Microsoft.Extensions.Configuration; using Microsoft.JSInterop; using System.Data.SqlClient; using static pro_todo.Pages.Users; namespace pro_todo.Pages { public class kullanicilar { public string kullaniciId {get;set;} public string kullaniciAdi{get;set;} public string kullaniciSoyadi{get;set;} public string kullaniciEmail {get;set;} public string kullaniciSifre {get;set;} public string kullaniciRolId {get;set;} public string kullaniciBolumId {get;set;} public string kullaniciKayitTarih {get;set;} public bool kullaniciOnay {get;set;} } public class Prtodo:ComponentBase { [Inject] IJSRuntime JSRuntime { get; set; } static string BaglantiKodu="workstation id=protodo.mssql.somee.com;packet size=4096;user id=Ruveyda044_SQLLogin_1;pwd=xyzm27u3xo;data source=protodo.mssql.somee.com;persist security info=False;initial catalog=protodo"; static SqlConnection Baglanti = new SqlConnection(BaglantiKodu); static string KomutKodu = "select *from kullanicilar"; static SqlDataAdapter KullanicilarDataAdapter= new SqlDataAdapter (KomutKodu, Baglanti); SqlCommandBuilder KullanicilarKomut = new SqlCommandBuilder(KullanicilarDataAdapter); DataSet KullanicilarDataSet = new DataSet(); public List kullanici= new List(); protected override void OnInitialized() { if(MyUser.kullanici_email != "NULL" && MyUser.kullanici_sifre != "NULL" && MyUser.kullanici_rol == "1" && MyUser.kullanici_bolum != "NULL" && MyUser.kullanici_id != "NULL") { kullanici.Clear(); kullanici=KullaniciGetir(); } else { JSRuntime.InvokeVoidAsync("logingit"); } } public List KullaniciGetir(){ try { KullanicilarDataAdapter.Fill(KullanicilarDataSet, "kullanici"); for (int i = 0; i < KullanicilarDataSet.Tables[0].Rows.Count; i++) { kullanicilar pm = new kullanicilar(); pm.kullaniciId = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_id"].ToString(); pm.kullaniciAdi = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_adi"].ToString(); pm.kullaniciSoyadi = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_soyadi"].ToString(); pm.kullaniciEmail = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_email"].ToString(); pm.kullaniciSifre = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_sifre"].ToString(); pm.kullaniciRolId = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_rol_id"].ToString(); pm.kullaniciBolumId = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_bolum_id"].ToString(); pm.kullaniciKayitTarih = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_kayit_tarihi"].ToString(); string onaystr = KullanicilarDataSet.Tables[0].Rows[i]["kullanici_onay"].ToString(); if (onaystr=="0") pm.kullaniciOnay=false; else pm.kullaniciOnay=true; kullanici.Add(pm); } } catch (Exception ex) { Console.WriteLine(ex); } return kullanici; } public async void IsDoneSet(string todoID, object checkedValue) { SqlCommand komut=Baglanti.CreateCommand(); bool newIsDone=(bool)checkedValue?true:false; foreach(kullanicilar kisi in kullanici){ if(kisi.kullaniciId == todoID){ if(kisi.kullaniciOnay==true) { kisi.kullaniciOnay = newIsDone; komut.CommandText="update kullanicilar set kullanici_onay=0 where kullanici_id="+todoID+""; } else { kisi.kullaniciOnay = newIsDone; komut.CommandText="update kullanicilar set kullanici_onay=1 where kullanici_id="+todoID+""; } break; } } Baglanti.Open(); komut.ExecuteNonQuery(); Baglanti.Close(); } } }