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.Globalization; using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; using Microsoft.JSInterop; using System.IO; using System.Net; using System.Net.Sockets; using System.Text; using System.Net.Http; using System.Data.SqlClient; using System.Data; using static Todo.Pages.LoginCheck; namespace Todo.Pages { public class Bolumler { public int bolum_id{get;set;} public string bolum_adi {get;set;} } public class BolumBase:ComponentBase { [Inject] public NavigationManager NavigationManager { get; set; } public List bolumler=new List(); public string YeniBolum{get;set;} public string Bolumsilid{get;set;} public string Bolumguncid{get;set;} public string Bolumyeni{get;set;} protected override async Task OnInitializedAsync() { if(Loginclass.m1=="NULL" && Loginclass.m2=="NULL") { NavigationManager.NavigateTo("/"); } else { if(Loginclass.rol_id_tut=="0"){ bolumler=Bolumgoster(); } } } public List Bolumgoster(){ string db = @"workstation id=blazortodos.mssql.somee.com;packet size=4096;user id=latral4_SQLLogin_1;pwd=516swqticy;data source=blazortodos.mssql.somee.com;persist security info=False;initial catalog=blazortodos"; SqlConnection baglanti = new SqlConnection(db); string sql = "select *from bolum"; SqlDataAdapter daps= new SqlDataAdapter (sql,baglanti); DataSet dsps = new DataSet(); try { daps.Fill(dsps, "bolumler"); for (int i = 0; i < dsps.Tables[0].Rows.Count; i++) { Bolumler pm = new Bolumler(); pm.bolum_id = Int32.Parse(dsps.Tables[0].Rows[i]["bolum_id"].ToString()); pm.bolum_adi = dsps.Tables[0].Rows[i]["bolum_adi"].ToString(); bolumler.Add(pm); } } catch (Exception ex) { Console.WriteLine(ex.Message); } return bolumler; } public void bolumekle(){ string db = @"workstation id=blazortodos.mssql.somee.com;packet size=4096;user id=latral4_SQLLogin_1;pwd=516swqticy;data source=blazortodos.mssql.somee.com;persist security info=False;initial catalog=blazortodos"; SqlConnection baglanti = new SqlConnection(db); baglanti.Open(); SqlCommand cmd = baglanti.CreateCommand(); cmd.CommandText = "insert into bolum values('"+YeniBolum+"')"; Console.WriteLine(cmd.CommandText); cmd.ExecuteNonQuery(); baglanti.Close(); } public void bolumguncelle(){ string db = @"workstation id=blazortodos.mssql.somee.com;packet size=4096;user id=latral4_SQLLogin_1;pwd=516swqticy;data source=blazortodos.mssql.somee.com;persist security info=False;initial catalog=blazortodos"; SqlConnection baglanti = new SqlConnection(db); baglanti.Open(); SqlCommand cmd = baglanti.CreateCommand(); cmd.CommandText = "update bolum set bolum_adi='"+Bolumyeni+"' where bolum_id="+Int32.Parse(Bolumguncid)+""; Console.WriteLine(cmd.CommandText); cmd.ExecuteNonQuery(); baglanti.Close(); } } }