Commit fb6ce83b authored by ferhat tamer's avatar ferhat tamer 💬
Browse files

Initial commit

parents
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
namespace Todo.Data{
public class UserModel{
public string? UserName{get;set;}
public string? Role{get;set;}
public string? UserId{get;set;}
}
}
\ No newline at end of file
namespace Todo.Data;
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string? Summary { get; set; }
}
namespace Todo.Data;
public class WeatherForecastService
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
{
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = startDate.AddDays(index),
TemperatureC = Random.Shared.Next(-20, 55),
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
}).ToArray());
}
}
@page "/Admin"
@inherits AdminBase
@inject NavigationManager NavigationManager
@inject IJSRuntime js
<p>
@Kontrol
<input placeholder="ID" @bind="inputId" />
<br />
<input placeholder="İsim" @bind="inputAd" />
<br />
<input placeholder="Soyisim" @bind="inputSoyad" />
<br />
<input placeholder="Kullanıcı Adı" @bind="inputKullaniciadi" />
<br />
<input type="password" minlenght="8 " placeholder="Şifre" @bind="inputPassword" required />
<br />
<label for="Rol">Rol Seç:</label>
<select name="Rol" @bind="inputRole">
<option value="">Tanımsız</option>
<option value="User">User</option>
<option value="Moderator">Moderator</option>
<option value="Admin">Admin</option>
</select>
</p>
<br />
<button class="btn btn-success" @onclick="GetUser">Kullanıcı Getir</button>
<button class="btn btn-primary" @onclick="InsertUser">Kullacı Ekle</button>
<button class="btn btn-warning" @onclick="UpdateUser">Kullanıcı Güncelle</button>
<button class="btn btn-danger" @onclick="DeleteUser">Kullanıcı Sil</button>
<br />
<br />
<h1>Kullanıcılar</h1>
<br />
<table class="table">
<thead>
<tr>
<th>Kullanıcı ID</th>
<th>Kullanıcı Adı</th>
<th>Kullanıcı Soyadı</th>
<th>Kullanıcı KullancıAdı</th>
<th>Kullanıcı Şifresi</th>
<th>Kullanıcı Rolü</th>
</tr>
</thead>
<tbody>
@if (kullanici == null)
{
<p><em>Loading....</em></p>
}
else
{
@foreach (var xm in kullanici)
{
<tr>
<td>
@xm.KId
</td>
<td>@xm.KAd </td>
<td>@xm.KSoy </td>
<td>@xm.KullaniciAdi</td>
<td>@xm.KPassword </td>
<td>@xm.KRole</td>
</tr>
}
}
</tbody>
</table>
\ No newline at end of file
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;
using Microsoft.JSInterop;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Net.Http;
using Microsoft.Data.SqlClient;
using Todo.Data;
using System.Data;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using System.Text.Json;
namespace Todo.Pages.Admin
{
public class LogUser
{
public string? KId { get; set; }
public string? KAd { get; set; }
public string? KSoy { get; set; }
public string? KullaniciAdi { get; set; }
public string? KPassword { get; set; }
public string? KRole { get; set; }
}
public class AdminBase : ComponentBase
{
static string connectionString = ("Server=.;Database=TodoDb;Encrypt=False;Integrated Security=SSPI;");
static SqlConnection conn = new SqlConnection(connectionString);
static string sql = "select KId,KAd,KSoy,KullaniciAdi,KPassword,KRole from Kullanici";
static SqlDataAdapter daps = new SqlDataAdapter(sql, conn);
SqlCommandBuilder cb = new SqlCommandBuilder(daps);
DataSet dsps = new DataSet();
public List<LogUser> kullanici = new List<LogUser>();
public string? error { get; set; }
public string? inputId { get; set; }
public string? inputSoyad { get; set; }
public string? inputRole { get; set; }
public string? inputAd { get; set; }
public string? inputKullaniciadi { get; set; }
public string? inputPassword { get; set; }
private string? kontrol = "";
[Inject]
public ProtectedLocalStorage? localstr { get; set; }
public string? Kontrol
{
get
{
WhoLogin();
return kontrol;
}
set
{
kontrol = value;
}
}
public string? mystr { get; set; }
[Inject]
protected NavigationManager? Navigation { get; set; }
private async void WhoLogin()
{
var result = await localstr.GetAsync<string>("myUser");
mystr = result.Success ? result.Value : "";
UserModel user = new UserModel();
user = JsonSerializer.Deserialize<UserModel>(mystr);
if (user.Role == "Admin")
Navigation.NavigateTo("/Admin");
else
Navigation.NavigateTo("/mod");
}
public async Task InsertUser()
{
dsps.Tables[0].Rows.Add(null, inputAd, inputSoyad, inputKullaniciadi, inputPassword, inputRole);
daps.Update(dsps, "kullanici");
dsps.Tables["kullanici"].Clear();
//cb.Dispose();
inputAd = "";
inputSoyad = "";
inputKullaniciadi = "";
inputPassword = "";
inputRole = "";
await OnInitializedAsync();
}
public async Task GetUser()
{
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (dsps.Tables[0].Rows[i]["KId"].ToString() == inputId)
{
inputAd = dsps.Tables[0].Rows[i]["KAd"].ToString();
inputSoyad = dsps.Tables[0].Rows[i]["KSoy"].ToString();
inputKullaniciadi = dsps.Tables[0].Rows[i]["KullaniciAdi"].ToString();
inputPassword = dsps.Tables[0].Rows[i]["KPassword"].ToString();
inputRole = dsps.Tables[0].Rows[i]["KRole"].ToString();
}
}
dsps.Tables[0].Clear();
await OnInitializedAsync();
}
public async Task UpdateUser()
{
DataRowCollection itemColumns = dsps.Tables[0].Rows;
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (dsps.Tables[0].Rows[i]["KId"].ToString() == inputId)
{
dsps.Tables[0].Rows[i]["KAd"] = inputAd;
dsps.Tables[0].Rows[i]["KSoy"] = inputSoyad;
dsps.Tables[0].Rows[i]["KullaniciAdi"] = inputKullaniciadi;
dsps.Tables[0].Rows[i]["KPassword"] = inputPassword;
dsps.Tables[0].Rows[i]["KRole"] = inputRole;
}
}
daps.Update(dsps, "kullanici");
// cb.Dispose();
dsps.Tables[0].Clear();
inputId = "";
inputAd = "";
inputSoyad = "";
inputKullaniciadi = "";
inputPassword = "";
inputRole = "";
await OnInitializedAsync();
}
public async Task DeleteUser()
{
foreach (DataRow row in dsps.Tables[0].Rows)
{
if (row["KId"].ToString() == inputId)
row.Delete();
}
daps.Update(dsps, "kullanici");
// cb.Dispose();
dsps.Tables["kullanici"].Clear();
inputId = "";
inputAd = "";
inputSoyad = "";
inputKullaniciadi = "";
inputPassword = "";
inputRole = "";
await OnInitializedAsync();
}
protected override async Task OnInitializedAsync()
{
kullanici.Clear();
await selectproc();
}
public Task selectproc()
{
return Task.Run(() =>
{
try
{
daps.Fill(dsps, "kullanici");
error += dsps.Tables[0].Rows.Count.ToString();
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
LogUser xm = new LogUser();
xm.KId = dsps.Tables[0].Rows[i]["KId"].ToString();
xm.KAd = dsps.Tables[0].Rows[i]["KAd"].ToString();
xm.KSoy = dsps.Tables[0].Rows[i]["KSoy"].ToString();
xm.KullaniciAdi = dsps.Tables[0].Rows[i]["KullaniciAdi"].ToString();
xm.KPassword = dsps.Tables[0].Rows[i]["KPassword"].ToString();
xm.KRole = dsps.Tables[0].Rows[i]["KRole"].ToString();
kullanici.Add(xm);
}
}
catch (Exception ex)
{
error = ex.ToString();
}
});
}
}
}
\ No newline at end of file
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}
@page
@model Todo.Pages.ErrorModel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
</head>
<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>
</html>
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace Todo.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
@page "/fetchdata"
<PageTitle>Weather forecast</PageTitle>
@using Todo.Data
@inject WeatherForecastService ForecastService
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from a service.</p>
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[]? forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
}
@page "/Giris"
@inherits GirisBase
welcome back @Kontrol
<body>
<br/>
<p>
Id:<input @bind="inputId" />
Durum:
<label for="Durum">Todo Durum:</label>
<select name="Durum" @bind="inputDurum">
<option value="Devam Ediyor...">Devam Ediyor...</option>
<option value="Tamamlandı.">Tamamlandı.</option>
</select>
</p>
<br/>
<button class="btn btn-success" @onclick="GetData">Todo Getir</button>
<button class="btn btn-warning" @onclick="UpdateData">Update</button>
<div class="Tooltip">
<br/><br/><br/>
<table class="table">
<thead>
<tr>
<th>Todo ID</th>
<th>Todo Detayı</th>
<th>Todo Durumu</th>
<th>Todo Başlangıç Tarihi</th>
<th>Todo Bitiş Tarihi</th>
</tr>
</thead>
<tbody>
@if(people == null )
{
<p><em>Loading....</em></p>
}
else
{
@foreach(var p in people)
{
<tr>
<td>
@p.Id
</td>
<td>@p.TodoDetay</td>
<td>@p.TodoDurum</td>
<td>@p.TodoSDate</td>
<td>@p.TodoFDate</td>
</tr>
}
}
</tbody>
</table>
</div>
<br/>
<p>@error Adet Todo Yüklendi.</p>
</body>
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 Microsoft.Data.SqlClient;
using System.Data;
using Todo.Data;
using System.Text.Json;
namespace Todo.Pages.Giris
{
public class TodoModel
{
public string? Id { get; set; }
public string? TodoDetay { get; set; }
public string? TodoDurum { get; set; }
public string? TodoPersonel { get; set; }
public string? TodoSDate { get; set; }
public string? TodoFDate { get; set; }
}
public class GirisBase : ComponentBase
{
public string? WhoLogin { get; set; }
private string? kullanici = "";
[Inject]
public ProtectedLocalStorage? localstr1 { get; set; }
public string? Kullanici
{
get
{
KullaniciAdi();
return kullanici;
}
set
{
kullanici = value;
}
}
public string? mystr1 { get; set; }
UserModel user = new UserModel();
private async void KullaniciAdi()
{
var result = await localstr.GetAsync<string>("myUser");
mystr = result.Success ? result.Value : "";
UserModel user = new UserModel();
user = JsonSerializer.Deserialize<UserModel>(mystr);
kullanici = user.UserName;
WhoLogin = user.UserId;
}
static string connectionString = ("Server=.;Database=TodoDb;Encrypt=False;Integrated Security=SSPI;");
static string connectionStringPerson = ("Server=.;Database=TodoDb;Encrypt=False;Integrated Security=SSPI;");
static SqlConnection conn = new SqlConnection(connectionString);
static SqlConnection connPerson = new SqlConnection(connectionStringPerson);
SqlCommandBuilder cb = new SqlCommandBuilder(daps);
SqlCommandBuilder cbPerson = new SqlCommandBuilder(dapsPerson);
static string sql = "select TodoId,TodoDetay,TodoDurum,TodoPersonel,TodoSDate,TodoFDate from Todo";
static string sqlPerson = "select KId,KullaniciAdi from Kullanici";
static SqlDataAdapter dapsPerson = new SqlDataAdapter(sqlPerson, connPerson);
static SqlDataAdapter daps = new SqlDataAdapter(sql, conn);
DataSet dsps = new DataSet();
DataSet dspsPerson = new DataSet();
public List<TodoModel> people = new List<TodoModel>();
public string? error { get; set; }
public string? inputId { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? FinishDate { get; set; }
public string? inputDetay { get; set; }
public string? inputDurum { get; set; }
public string? inputPersonel { get; set; }
private string? kontrol = "";
[Inject]
public ProtectedLocalStorage? localstr { get; set; }
public string? Kontrol
{
get
{
AdminModerator();
return kontrol;
}
set
{
kontrol = value;
}
}
public string? mystr { get; set; }
[Inject]
protected NavigationManager? Navigation { get; set; }
private async void AdminModerator()
{
var result = await localstr.GetAsync<string>("myUser");
mystr = result.Success ? result.Value : "";
UserModel user = new UserModel();
user = JsonSerializer.Deserialize<UserModel>(mystr);
WhoLogin = user.UserId;
Kontrol = user.UserName;
if (user.Role == "Admin" || user.Role == "Moderator" || user.Role == "User")
Navigation.NavigateTo("/Giris");
else
Navigation.NavigateTo("/");
}
public async Task GetData()
{
DataRowCollection itemColumns = dsps.Tables[0].Rows;
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (dsps.Tables[0].Rows[i]["TodoId"].ToString() == inputId)
{
inputDetay = dsps.Tables[0].Rows[i]["TodoDetay"].ToString();
inputDurum = dsps.Tables[0].Rows[i]["TodoDurum"].ToString();
}
}
dsps.Tables[0].Clear();
await OnInitializedAsync();
}
public async Task UpdateData()
{
DataRowCollection itemColumns = dsps.Tables[0].Rows;
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (dsps.Tables[0].Rows[i]["TodoId"].ToString() == inputId)
{
dsps.Tables[0].Rows[i]["TodoDurum"] = inputDurum;
}
}
daps.Update(dsps, "people");
dsps.Tables[0].Clear();
inputId = "";
inputDetay = "";
inputDurum = "";
inputPersonel = "";
await OnInitializedAsync();
}
protected override async Task OnInitializedAsync()
{
people.Clear();
await selectproc();
}
public Task selectproc()
{
return Task.Run(() =>
{
try
{
daps.Fill(dsps, "people");
error += dsps.Tables[0].Rows.Count.ToString();
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (WhoLogin == dsps.Tables[0].Rows[i]["TodoPersonel"].ToString())
{
TodoModel pm = new TodoModel();
pm.Id = dsps.Tables[0].Rows[i]["TodoId"].ToString();
pm.TodoDetay = dsps.Tables[0].Rows[i]["TodoDetay"].ToString();
pm.TodoDurum = dsps.Tables[0].Rows[i]["TodoDurum"].ToString();
pm.TodoSDate = dsps.Tables[0].Rows[i]["TodoSDate"].ToString();
pm.TodoFDate = dsps.Tables[0].Rows[i]["TodoFDate"].ToString();
people.Add(pm);
}
}
}
catch (Exception ex)
{
error = ex.ToString();
}
});
}
}
}
\ No newline at end of file
@page "/"
@inherits ControlBase
@inject NavigationManager NavigationManager
<style>
* {
margin: 0;
padding: 0;
text-decoration: none;
font-family: sans-serif;
box-sizing: border-box;
}
body {
width: 100%;
height: 100%;
}
.kutu {
width: 400px;
background: white;
height: 700px;
padding: 80px 40px;
border-style: solid;
/*sağdan soldan 40px yukarıdan aşağıdan 80 px padding*/
border-radius: 10px;
/*köşleri ovalleştirme*/
position: absolute;
left: 58%;
/*soldan hizalama*/
top: 50%;
/*yukarıdan hizalama*/
transform: translate(-50%, -50%);
/*tam hizalama sağlamak için*/
}
.txtb {
/*alt çizgi ekleme*/
position: relative;
margin: 30px 0;
}
.txtb input {
font-size: 15px;
color: #333;
border: none;
width: 100%;
outline: none;
background: none;
padding: 0 5px;
height: 40px;
border-bottom: 2px solid #adadad;
}
img.loginimg {
margin-left: 30px;
margin-bottom: 50px;
display: block;
background: black;
border-radius: 25%;
width: 250px;
height: 200px;
}
.logbtn {
display: block;
width: 100%;
height: 50px;
border: none;
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, black 70%);
background-size: 200%;
color: white;
outline: none;
/*köşelerini kapatmak siyah olmamsı için*/
cursor: pointer;
border-radius: 15px;
}
.logbtn:hover {
background: white;
color: black;
border: 2px solid black;
}
</style>
<body>
<div class="kutu">
<div class="contact-form">
<img src="images/Login.jpg" class="loginimg">
<h2>Giriş Yap </h2>
<form>
<div class="txtb">
<input type="text" placeholder="Username" @bind="inputKullaniciAdi" minlength="8" required />
</div>
<div class="txtb">
<input type="password" placeholder="Password" minlength="8" @bind="inputPassword" required />
</div>
<input type="button" class="logbtn" value="Giriş Yap" @onclick="SearchUser" />
<br><input type="button" class="logbtn" value="Kaydol" onclick="window.location.href ='/Register'" />
</form>
</div>
</div>
</body>
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 Microsoft.Data.SqlClient;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Text.Json;
using Todo.Data;
namespace Todo.Pages.Login
{
public class User
{
public int KId { get; set; } = 1;
public string? KullaniciAdi { get; set; }
public string? KPassword { get; set; }
public string? KRole;
}
public class ControlBase : ComponentBase
{
static string connectionString = ("Server=.;Database=TodoDb;Encrypt=False;Integrated Security=SSPI;");
static SqlConnection conn = new SqlConnection(connectionString);
static string sql = "select KId,KullaniciAdi,kPassword,kRole from Kullanici";
static SqlDataAdapter daps = new SqlDataAdapter(sql, conn);
SqlCommandBuilder cb = new SqlCommandBuilder(daps);
DataSet dsps = new DataSet();
public List<User> kullanici = new List<User>();
public string? inputId { get; set; }
public string? error { get; set; }
public string? inputKullaniciAdi { get; set; }
public string? inputPassword { get; set; }
[Inject]
protected NavigationManager? Navigation { get; set; }
[Inject]
public ProtectedLocalStorage? localstr { get; set; }
public string? Text { get; set; }
public async Task SearchUser()
{
DataRowCollection itemColumns = dsps.Tables[0].Rows;
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (dsps.Tables[0].Rows[i]["KullaniciAdi"].ToString() == inputKullaniciAdi && dsps.Tables[0].Rows[i]["KPassword"].ToString() == inputPassword)
{
UserModel user = new UserModel()
{
UserName = dsps.Tables[0].Rows[i]["KullaniciAdi"].ToString(),
Role = dsps.Tables[0].Rows[i]["KRole"].ToString(),
UserId=dsps.Tables[0].Rows[i]["KId"].ToString()
};
await localstr.SetAsync("myUser", JsonSerializer.Serialize(user));
Navigation.NavigateTo("/Admin");
}
else
{
}
}
}
protected override async Task OnInitializedAsync()
{
kullanici.Clear();
await selectproc();
}
public Task selectproc()
{
return Task.Run(() =>
{
try
{
daps.Fill(dsps, "kullanici");
error += dsps.Tables[0].Rows.Count.ToString();
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
User xm = new User();
xm.KullaniciAdi = dsps.Tables[0].Rows[i]["KullaniciAdi"].ToString();
xm.KPassword = dsps.Tables[0].Rows[i]["KPassword"].ToString();
xm.KRole = dsps.Tables[0].Rows[i]["KRole"].ToString();
kullanici.Add(xm);
}
}
catch (Exception ex)
{
error = ex.ToString();
}
});
}
}
}
\ No newline at end of file
@page "/mod"
@inherits ModeratorBase
@inject IJSRuntime js
@Kontrol
<body>
<br/>
<p>
Id:<input @bind="inputId"/>
Detay:<input @bind="inputDetay"/>
Durum:
<label for="Durum">Todo Durum:</label>
<select name="Durum" @bind="inputDurum">
<option value="Devam Ediyor...">Devam Ediyor...</option>
<option value="Tamamlandı.">Tamamlandı.</option>
</select>
İlgili Personel:
<select name="Rol" @bind="inputPersonel">
@foreach(var xm in person)
{
<option value="@xm.KId">@xm.KullaniciAdi</option>
}
</select>
Başlangıç Tarihi:<input type="date" @bind="StartDate"@bind:format="yyyy-MM-dd"/>
Bitiş Tarihi:<input type="date" @bind="FinishDate"@bind:format="yyyy-MM-dd"/>
</p>
<br/>
<button class="btn btn-success" @onclick="GetData">Todo Getir</button>
<button class="btn btn-primary" @onclick="InsertData">Insert</button>
<button class="btn btn-warning" @onclick="UpdateData">Update</button>
<button class="btn btn-danger" @onclick="DeleteData">Delete</button>
<div class="Tooltip">
<br/><br/><br/>
<table class="table">
<thead>
<tr>
<th>Todo ID</th>
<th>Todo Detayı</th>
<th>Todo Durumu</th>
<th>İlgili Personel</th>
<th>Todo Başlangıç Tarihi</th>
<th>Todo Bitiş Tarihi</th>
</tr>
</thead>
<tbody>
@if(people == null )
{
<p><em>Loading....</em></p>
}
else
{
@foreach(var p in people)
{
<tr>
<td>
@p.Id
</td>
<td>@p.TodoDetay</td>
<td>@p.TodoDurum</td>
<td>@p.TodoPersonel</td>
<td>@p.TodoSDate</td>
<td>@p.TodoFDate</td>
</tr>
}
}
</tbody>
</table>
</div>
<br/>
<p>@error2 Adet Todo Yüklendi.</p>
</body>
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 Microsoft.Data.SqlClient;
using System.Data;
using Todo.Data;
using System.Text.Json;
namespace Todo.Pages.Moderator
{
public class TodoModel
{
public string? Id { get; set; }
public string? TodoDetay { get; set; }
public string? TodoDurum { get; set; }
public string? TodoPersonel { get; set; }
public string? TodoSDate { get; set; }
public string? TodoFDate { get; set; }
}
public class PersonModel
{
public string? KId { get; set; }
public string? KullaniciAdi { get; set; }
}
public class ModeratorBase : ComponentBase
{
private string? kullanici = "";
[Inject]
public ProtectedLocalStorage? localstr1 { get; set; }
public string? Kullanici
{
get
{
KullaniciAdi();
return kullanici;
}
set
{
kullanici = value;
}
}
public string? mystr1 { get; set; }
UserModel user = new UserModel();
private async void KullaniciAdi()
{
var result = await localstr.GetAsync<string>("myUser");
mystr = result.Success ? result.Value : "";
UserModel user = new UserModel();
user = JsonSerializer.Deserialize<UserModel>(mystr);
kullanici = user.UserName;
}
static string connectionString = ("Server=.;Database=TodoDb;Encrypt=False;Integrated Security=SSPI;");
static string connectionStringPerson = ("Server=.;Database=TodoDb;Encrypt=False;Integrated Security=SSPI;");
static SqlConnection conn = new SqlConnection(connectionString);
static SqlConnection connPerson = new SqlConnection(connectionStringPerson);
SqlCommandBuilder cb = new SqlCommandBuilder(daps);
SqlCommandBuilder cbPerson = new SqlCommandBuilder(dapsPerson);
static string sql = "select TodoId,TodoDetay,TodoDurum,TodoPersonel,TodoSDate,TodoFDate from Todo";
static string sqlPerson = "select KId,KullaniciAdi from Kullanici";
static SqlDataAdapter dapsPerson = new SqlDataAdapter(sqlPerson, connPerson);
static SqlDataAdapter daps = new SqlDataAdapter(sql, conn);
DataSet dsps = new DataSet();
DataSet dspsPerson = new DataSet();
public List<TodoModel> people = new List<TodoModel>();
public List<PersonModel> person = new List<PersonModel>();
public string? error { get; set; }
public string? WhoLogin { get; set; }
public string? error2 { get; set; }
public string? inputId { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? FinishDate { get; set; }
public string? inputDetay { get; set; }
public string? inputDurum { get; set; }
public string? inputPersonel { get; set; }
public string? inputYorumsahibi { get; set; }
private string? kontrol = "";
[Inject]
public ProtectedLocalStorage? localstr { get; set; }
public string? Kontrol
{
get
{
AdminModerator();
return kontrol;
}
set
{
kontrol = value;
}
}
public string? mystr { get; set; }
[Inject]
protected NavigationManager? Navigation { get; set; }
private async void AdminModerator()
{
var result = await localstr.GetAsync<string>("myUser");
mystr = result.Success ? result.Value : "";
UserModel user = new UserModel();
user = JsonSerializer.Deserialize<UserModel>(mystr);
WhoLogin = user.Role;
if (user.Role == "Admin" || user.Role == "Moderator")
Navigation.NavigateTo("/mod");
else
Navigation.NavigateTo("/Giris");
}
public async Task InsertData()
{
dsps.Tables[0].Rows.Add(null, inputDetay, inputDurum, inputPersonel, StartDate, FinishDate);
daps.Update(dsps, "people");
dspsPerson.Tables["person"].Clear();
dsps.Tables["people"].Clear();
//cb.Dispose();
inputDetay = "";
inputDurum = "";
inputPersonel = "";
await OnInitializedAsync();
}
public async Task GetData()
{
DataRowCollection itemColumns = dsps.Tables[0].Rows;
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (dsps.Tables[0].Rows[i]["TodoId"].ToString() == inputId)
{
inputDetay = dsps.Tables[0].Rows[i]["TodoDetay"].ToString();
inputDurum = dsps.Tables[0].Rows[i]["TodoDurum"].ToString();
inputPersonel = dsps.Tables[0].Rows[i]["TodoPersonel"].ToString();
}
}
dsps.Tables[0].Clear();
dspsPerson.Tables[0].Clear();
await OnInitializedAsync();
}
public async Task UpdateData()
{
DataRowCollection itemColumns = dsps.Tables[0].Rows;
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
if (dsps.Tables[0].Rows[i]["TodoId"].ToString() == inputId)
{
dsps.Tables[0].Rows[i]["TodoDetay"] = inputDetay;
dsps.Tables[0].Rows[i]["TodoDurum"] = inputDurum;
dsps.Tables[0].Rows[i]["TodoPersonel"] = inputPersonel;
dsps.Tables[0].Rows[i]["TodoSDate"] = StartDate;
dsps.Tables[0].Rows[i]["TodoFDate"] = FinishDate;
}
}
daps.Update(dsps, "people");
dsps.Tables[0].Clear();
dspsPerson.Tables[0].Clear();
inputId = "";
inputDetay = "";
inputDurum = "";
inputPersonel = "";
await OnInitializedAsync();
}
public async Task DeleteData()
{
foreach (DataRow row in dsps.Tables[0].Rows)
{
if (row["Id"].ToString() == inputId)
row.Delete();
}
daps.Update(dsps, "people");
dsps.Tables["people"].Clear();
dspsPerson.Tables["person"].Clear();
inputId = "";
inputDetay = "";
inputDurum = "";
await OnInitializedAsync();
}
protected override async Task OnInitializedAsync()
{
people.Clear();
person.Clear();
await selectproc();
await selectprocPerson();
}
public Task selectproc()
{
return Task.Run(() =>
{
try
{
daps.Fill(dsps, "people");
error += dsps.Tables[0].Rows.Count.ToString();
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
TodoModel pm = new TodoModel();
pm.Id = dsps.Tables[0].Rows[i]["TodoId"].ToString();
pm.TodoDetay = dsps.Tables[0].Rows[i]["TodoDetay"].ToString();
pm.TodoDurum = dsps.Tables[0].Rows[i]["TodoDurum"].ToString();
pm.TodoPersonel = dsps.Tables[0].Rows[i]["TodoPersonel"].ToString();
pm.TodoSDate = dsps.Tables[0].Rows[i]["TodoSDate"].ToString();
pm.TodoFDate = dsps.Tables[0].Rows[i]["TodoFDate"].ToString();
people.Add(pm);
}
}
catch (Exception ex)
{
error = ex.ToString();
}
});
}
public Task selectprocPerson()
{
return Task.Run(() =>
{
try
{
dapsPerson.Fill(dspsPerson, "person");
error2 += dspsPerson.Tables[0].Rows.Count.ToString();
for (int i = 0; i < dspsPerson.Tables[0].Rows.Count; i++)
{
PersonModel xm = new PersonModel();
xm.KId = dspsPerson.Tables[0].Rows[i]["KId"].ToString();
xm.KullaniciAdi = dspsPerson.Tables[0].Rows[i]["KullaniciAdi"].ToString();
person.Add(xm);
}
}
catch (Exception ex)
{
error2 = ex.ToString();
}
});
}
}
}
\ No newline at end of file
@page "/Register"
@inherits RegisterBase
<style>
* {
margin: 0;
padding: 0;
text-decoration: none;
font-family: sans-serif;
box-sizing: border-box;
}
body {
width: 100%;
height: 100%;
}
.kutu {
width: 400px;
background: white;
height: 700px;
padding: 80px 40px;
/*sağdan soldan 40px yukarıdan aşağıdan 80 px padding*/
border-radius: 10px;
border-style: solid ;
/*köşleri ovalleştirme*/
position: absolute;
left: 58%;
/*soldan hizalama*/
top: 50%;
/*yukarıdan hizalama*/
transform: translate(-50%, -50%);
/*tam hizalama sağlamak için*/
}
.txtb {
/*alt çizgi ekleme*/
position: relative;
margin: 30px 0;
}
.txtb input {
font-size: 15px;
color: #333;
border: none;
width: 100%;
outline: none;
background: none;
padding: 0 5px;
height: 40px;
border-bottom: 2px solid #adadad;
}
img.registerimg {
margin-left: 85px;
margin-bottom: 50px;
display: block;
background: black;
border-radius: 25%;
width: 140px;
height: 140px;
}
.logbtn {
display: block;
width: 100%;
height: 50px;
border: none;
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, black 70%);
background-size: 200%;
color: white;
outline: none;
/*köşelerini kapatmak siyah olmamsı için*/
cursor: pointer;
border-radius: 15px;
}
.logbtn:hover {
background: white;
color: black;
border: 2px solid black;
}
</style>
<body>
<div class="kutu">
<div class="contact-form">
<img src="images/Register.jpg" class="registerimg">
<h2>Kayıt Ol</h2>
<form action="">
<div class="txtb">
<input type="text" placeholder="İsim" @bind="inputAd" required />
<input type="text" placeholder="Soyisim " @bind="inputSoyad" required />
<input type="text" placeholder="Kullanıcı Adı" @bind="inputKullaniciAdi" maxlength="32"
minlength="8" required />
<input type="password" placeholder="Şifre" @bind="inputPassword" maxlength="32" minlength="8"
required />
</div>
<input type="button" class="logbtn" value="Kayıt Ol" @onclick="InsertAccount" />
<br><input type="button" class="logbtn" value="Giriş Yap" onclick="window.location.href ='/';" />
</form>
</div>
</div>
</body>
\ No newline at end of file
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 Microsoft.Data.SqlClient;
using System.Data;
namespace Todo.Pages.Register
{
public class Kayit
{
public string? KId { get; set; }
public string? KAd { get; set; }
public string? KSoy { get; set; }
public string? KullaniciAdi { get; set; }
public string? KPassword { get; set; }
}
public class RegisterBase : ComponentBase
{
static string connectionString = ("Server=.;Database=TodoDb;Encrypt=False;Integrated Security=SSPI;");
static SqlConnection conn = new SqlConnection(connectionString);
static string sql = "select KId,KAd,KSoy,KullaniciAdi,KPassword,KRole from Kullanici";
static SqlDataAdapter daps = new SqlDataAdapter(sql, conn);
SqlCommandBuilder cb = new SqlCommandBuilder(daps);
DataSet dsps = new DataSet();
public List<Kayit> people = new List<Kayit>();
public string? error { get; set; }
public string? inputSoyad { get; set; }
public string? inputAd { get; set; }
public string? inputKullaniciAdi { get; set; }
public string? inputPassword { get; set; }
public async Task InsertAccount()
{
if (inputAd != null && inputSoyad != null && inputKullaniciAdi != null && inputPassword != null)
{
dsps.Tables[0].Rows.Add(null, inputAd, inputSoyad, inputKullaniciAdi, inputPassword,null);
daps.Update(dsps, "people");
dsps.Tables["people"].Clear();
inputAd = "";
inputSoyad = "";
inputKullaniciAdi = "";
inputPassword = "";
}
else
{
}
await OnInitializedAsync();
}
protected override async Task OnInitializedAsync()
{
people.Clear();
await selectproc();
}
public Task selectproc()
{
return Task.Run(() =>
{
try
{
daps.Fill(dsps, "people");
error += dsps.Tables[0].Rows.Count.ToString();
for (int i = 0; i < dsps.Tables[0].Rows.Count; i++)
{
Kayit pm = new Kayit();
pm.KId = dsps.Tables[0].Rows[i]["KId"].ToString();
pm.KAd = dsps.Tables[0].Rows[i]["KAd"].ToString();
pm.KSoy = dsps.Tables[0].Rows[i]["KSoy"].ToString();
pm.KullaniciAdi = dsps.Tables[0].Rows[i]["KullaniciAdi"].ToString();
pm.KPassword = dsps.Tables[0].Rows[i]["KPassword"].ToString();
people.Add(pm);
}
}
catch (Exception ex)
{
error = ex.ToString();
}
});
}
}
}
\ No newline at end of file
@page "/"
@namespace Todo.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_Layout";
}
<component type="typeof(App)" render-mode="ServerPrerendered" />
@using Microsoft.AspNetCore.Components.Web
@namespace Todo.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="Todo.styles.css" rel="stylesheet" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
<body>
@RenderBody()
<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.server.js"></script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment