You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
386 lines
17 KiB
386 lines
17 KiB
@page "/Teacher/TeacherContact"
|
|
@inject Blazored.SessionStorage.ISessionStorageService sessionStorage
|
|
@inject NavigationManager NavManager
|
|
@inherits Admin.ListBase;
|
|
@using System.ComponentModel.DataAnnotations
|
|
@using Syncfusion.Blazor.Grids;
|
|
@using Syncfusion.Blazor.Buttons;
|
|
@using Syncfusion.Blazor.Spinner;
|
|
@using Syncfusion.Blazor.Navigations;
|
|
@using Syncfusion.Blazor.Popups;
|
|
@using BlazorApp.Helper
|
|
@using BWPMModels;
|
|
|
|
<div class="control-section e-tab-section">
|
|
|
|
<EditForm Model="_lehrer" OnValidSubmit="@Submit" OnInvalidSubmit="@InvalidSubmit">
|
|
|
|
|
|
<DataAnnotationsValidator />
|
|
<SfTab ID="BlazorTab" Height="390" @ref="Tab">
|
|
<TabEvents Created="TabCreate"></TabEvents>
|
|
<TabItems>
|
|
<TabItem>
|
|
<ChildContent>
|
|
<TabHeader Text="Kontakt-Daten"></TabHeader>
|
|
</ChildContent>
|
|
<ContentTemplate>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="card">
|
|
|
|
<div class="card-body">
|
|
<h5 class="card-title">Adress-Daten</h5>
|
|
<form>
|
|
<div class="form-group row">
|
|
<label for="Anrede" class="col-2 col-form-label">Anrede</label>
|
|
<div class="col-10">
|
|
<select id="Anrede" name="Anrede" class="form-control" @bind="@_lehrer.anredeID">
|
|
<option value="1">Herr</option>
|
|
<option value="2">Frau</option>
|
|
<option value="3">Damen und Herren</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="nameZ1" class="col-2 col-form-label">Name</label>
|
|
<div class="col-10">
|
|
<InputText id="namez1" class="form-control" @bind-Value="_lehrer.name" placeholder="Nachname" />
|
|
<ValidationMessage For="@(() => _lehrer.name)" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="nameZ2" class="col-2 col-form-label">Zusatz</label>
|
|
<div class="col-10">
|
|
<InputText id="nameZ2" class="form-control" @bind-Value="@_lehrer.vorname" placeholder="vorname" />
|
|
<ValidationMessage For="@(() => _lehrer.vorname)" />
|
|
</div>
|
|
</div>
|
|
<hr />
|
|
<div class="form-group row">
|
|
<label for="telefon" class="col-2 col-form-label">Telefon</label>
|
|
<div class="col-10">
|
|
<InputText id="tel" class="form-control" @bind-Value="@_lehrer.tel" placeholder="Telefon-Nummer" />
|
|
<ValidationMessage For="@(() => _lehrer.tel)" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="handy" class="col-2 col-form-label">Mobile</label>
|
|
<div class="col-10">
|
|
<InputText id="handy" class="form-control" @bind-Value="@_lehrer.handy" placeholder="Mobile-Nummer" />
|
|
<ValidationMessage For="@(() => _lehrer.handy)" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="email" class="col-2 col-form-label">E-Mail</label>
|
|
<div class="col-10">
|
|
<InputText id="mail" class="form-control" @bind-Value="@_lehrer.email" placeholder="E-Mail" required="required" typeof="email" />
|
|
<ValidationMessage For="@(() => _lehrer.email)" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group row">
|
|
<label for="Schulhaus" class="col-2 col-form-label">Schulhaus</label>
|
|
<div class="col-10">
|
|
<select id="Schulhaus" name="Schulhaus" class="form-control" @bind="@_lehrer.schulhausID">
|
|
@foreach (var sh in _schulhaus)
|
|
{
|
|
<option value="@sh.ID">@sh.bezeichnung</option>
|
|
}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="card">
|
|
|
|
<div class="card-body">
|
|
<SfButton IsPrimary="true" OnClick="@(() => SaveClick())">Speichern und weiter</SfButton>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</ContentTemplate>
|
|
</TabItem>
|
|
<TabItem>
|
|
<ChildContent>
|
|
<TabHeader Text="Stammdaten"></TabHeader>
|
|
</ChildContent>
|
|
<ContentTemplate>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6" id="TestCol">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h5 class="card-title">Klassen und Klassengrösse</h5>
|
|
<div class="col-lg-12 control-section">
|
|
<div class="content-wrapper">
|
|
<div class="row">
|
|
<SfGrid @bind-Visible="@ShowErrorDialog_grid" DataSource="@GridData" @ref="Grid" AllowPaging="true" AllowSorting="true" Toolbar="@(new List<string>() { "Add", "Edit", "Update", "Cancel" })">
|
|
<GridPageSettings PageCount="5" PageSizes="true"></GridPageSettings>
|
|
<GridEditSettings AllowAdding="true" AllowDeleting="false" AllowEditing="true" Mode="EditMode.Dialog"></GridEditSettings>
|
|
<GridEvents OnActionBegin="OnBeginHandler" OnActionComplete="OnCompletedHandler" TValue="Klasse" OnDataBound="RowDataBoundHandler"></GridEvents>
|
|
<GridColumns>
|
|
<GridColumn Type="ColumnType.CheckBox" AllowFiltering="false" AllowSorting="false" Width="60"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Klasse.ID) HeaderText="Id" IsPrimaryKey="true" AllowAdding="false" Width="60" Visible="true"></GridColumn>
|
|
<GridForeignColumn Field=@nameof(Klasse.schulhausID) HeaderText="Schulhaus" ForeignKeyValue="bezeichnung" ForeignKeyField="ID" ForeignDataSource="@_schulhaus" Width="150"></GridForeignColumn>
|
|
@*<GridColumn Field=@nameof(Klasse.schulhausID) HeaderText="Schulhausid" Width="100" Visible="true"></GridColumn>*@
|
|
|
|
<GridColumn Field=@nameof(Klasse.bezeichnung) HeaderText="Bezeichnung" Width="100" Visible="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Klasse.klassengroesse) HeaderText="Klassengrösse" Width="100" Visible="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Klasse.aktiv) HeaderText="Aktiv" Width="100" Visible="false" DisplayAsCheckBox="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Klasse.erstellt_am) HeaderText="Erstellt_am" Width="100" Visible="false" Format="d" Type="ColumnType.Date"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Klasse.mutiert_am) HeaderText="Mutiert_am" Width="100" Visible="false" Format="d" Type="ColumnType.Date"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Klasse.mutierer) HeaderText="Mutierer" Width="100" Visible="false"></GridColumn>
|
|
|
|
|
|
<GridColumn Field=@nameof(Klasse.lehrerID) HeaderText="Lehrerid" Width="100" Visible="false"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Klasse.mandantnr) HeaderText="Mandantnr" Width="100" Visible="false"></GridColumn>
|
|
</GridColumns>
|
|
</SfGrid>
|
|
|
|
<form>
|
|
</form>
|
|
<div class="card">
|
|
|
|
<div class="card-body">
|
|
<SfButton IsPrimary="true" OnClick="@(() => WeiterClick())">Weiter zu Schülerdaten</SfButton>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</ContentTemplate>
|
|
|
|
</TabItem>
|
|
</TabItems>
|
|
</SfTab>
|
|
|
|
|
|
</EditForm>
|
|
</div>
|
|
<SfDialog Width="250px" IsModal="true" @bind-Visible="@ShowErrorDialog">
|
|
<DialogTemplates>
|
|
<Header> Formmular unvollständig </Header>
|
|
<Content> Bitte das Formular vollständig ausfüllen. </Content>
|
|
|
|
</DialogTemplates>
|
|
<DialogButtons>
|
|
<DialogButton Content="OK" IsPrimary="true" OnClick="@CloseDialog" />
|
|
</DialogButtons>
|
|
</SfDialog>
|
|
|
|
|
|
|
|
@code {
|
|
SfTab Tab;
|
|
SfGrid<Klasse> Grid { get; set; }
|
|
public int Value = 0;
|
|
public List<BWPMModels.Klasse> GridData { get; set; }
|
|
public List<BWPMModels.Klasse> Klasses { get; set; }
|
|
public int foundrow = 0;
|
|
public bool ContinuePaging = true;
|
|
public bool InitialRender { get; set; }
|
|
|
|
private List<BWPMModels.Schulhaus> _schulhaus { get; set; } = BlazorApp.Controller.SchulhausController.GetAllData();
|
|
private Lehrer _lehrer { get; set; } = new BWPMModels.Lehrer();
|
|
public List<BWPMModels.Lehrer> Lehrerdaten { get; set; }
|
|
string userid = "";
|
|
public static int? pkey { get; set; }
|
|
public bool Initial { get; set; } = true;
|
|
private bool ShowErrorDialog { get; set; } = false;
|
|
private bool ShowErrorDialog_grid { get; set; } = false;
|
|
|
|
public void Submit()
|
|
{
|
|
BlazorApp.Controller.LehrerController.PUT(_lehrer);
|
|
Tab.EnableTab(1, true);
|
|
Tab.Select(1);
|
|
|
|
}
|
|
public void InvalidSubmit()
|
|
{
|
|
Tab.EnableTab(1, false);
|
|
Tab.Select(0);
|
|
ShowErrorDialog = true;
|
|
}
|
|
private void CloseDialog()
|
|
{
|
|
this.ShowErrorDialog = false;
|
|
}
|
|
|
|
private void SaveClick()
|
|
{
|
|
}
|
|
private void WeiterClick()
|
|
{
|
|
NavManager.NavigateTo("/Teacher/TeacherStudent");
|
|
}
|
|
|
|
protected override async void OnInitialized()
|
|
{
|
|
|
|
}
|
|
|
|
public async Task TabCreate()
|
|
{
|
|
await Tab.EnableTab(1, false);
|
|
@*await Tab.EnableTab(2, false);*@
|
|
@*Tab.EnableTab(3, false);*@
|
|
}
|
|
public async Task SelectTrainBack()
|
|
{
|
|
await Tab.Select(0);
|
|
}
|
|
protected override async Task OnAfterRenderAsync(bool firstRender)
|
|
{
|
|
|
|
userid = await sessionStorage.GetItemAsync<string>("UserID");
|
|
if (userid == null)
|
|
{
|
|
var authState = await authenticationStateTask;
|
|
var userId = authState.User.Claims.FirstOrDefault().Value;
|
|
var user = authState.User;
|
|
|
|
if (user.Identity.IsAuthenticated)
|
|
|
|
{
|
|
await sessionStorage.SetItemAsync("UserID", userId);
|
|
userid = userId;
|
|
}
|
|
else
|
|
{
|
|
await sessionStorage.SetItemAsync("UserID", userId);
|
|
userid = userId;
|
|
}
|
|
}
|
|
if (firstRender)
|
|
{
|
|
Lehrerdaten = BlazorApp.Controller.LehrerController.GetByUserID(userid);
|
|
_lehrer = Lehrerdaten.First<BWPMModels.Lehrer>();
|
|
GridData = BlazorApp.Controller.KlasseController.GetByLehrerID(_lehrer.ID);
|
|
await sessionStorage.SetItemAsync("LehrerID", _lehrer.ID);
|
|
}
|
|
|
|
}
|
|
|
|
private async Task OnBeginHandler(ActionEventArgs<BWPMModels.Klasse> Args)
|
|
|
|
{
|
|
|
|
@* try
|
|
{
|
|
if (_lehrer.ID == 0)
|
|
{
|
|
ShowErrorDialog_grid = true;
|
|
return;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
ShowErrorDialog_grid = true;
|
|
return;
|
|
}*@
|
|
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
|
|
{
|
|
if (Args.Action == "Add")
|
|
{
|
|
Args.Data.lehrerID = _lehrer.ID;
|
|
Args.Data.erstellt_am = DateTime.Now;
|
|
Args.Data.mutierer = userid;
|
|
Args.Data.mutiert_am = DateTime.Now;
|
|
Args.Data.aktiv = true;
|
|
Args.Data.ID = BlazorApp.Controller.KlasseController.POST(Args.Data);
|
|
Value = Args.Data.ID;
|
|
}
|
|
else
|
|
{
|
|
Args.Data.mutierer = userid.ToString();
|
|
Args.Data.mutiert_am = DateTime.Now;
|
|
BlazorApp.Controller.KlasseController.PUT(Args.Data);
|
|
|
|
Value = Args.Data.ID;
|
|
Grid.Refresh();
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public async Task OnCompletedHandler(ActionEventArgs<BWPMModels.Klasse> Args)
|
|
|
|
{
|
|
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
|
|
{
|
|
await Grid.SetRowData(Args.Data.ID, Args.Data);
|
|
double xx = 0;
|
|
Value = Args.Data.ID;
|
|
xx = await DataHandler();
|
|
await Grid.SelectRow(xx);
|
|
|
|
}
|
|
}
|
|
|
|
public async void RowDataBoundHandler(BeforeDataBoundArgs<BWPMModels.Klasse> args)
|
|
{
|
|
if (!Initial)
|
|
{
|
|
//await Task.Delay(100);
|
|
//var Idx = await this.Grid.GetRowIndexByPrimaryKey(Convert.ToDouble(Value)); //get index value
|
|
//this.Grid.SelectRow(Convert.ToDouble(Idx));
|
|
}
|
|
Initial = false;
|
|
}
|
|
|
|
|
|
public async Task<double> DataHandler()
|
|
{
|
|
var PageCount = (GridData.Count / Grid.PageSettings.PageSize) + 1;
|
|
ContinuePaging = true;
|
|
var CurrentPage = 1;
|
|
Grid.Refresh();
|
|
await Grid.GoToPage(1);
|
|
|
|
for (int i = 1; i <= PageCount; i++)
|
|
|
|
{
|
|
List<Klasse> Rows = await Grid.GetCurrentViewRecords(); // returns the current view data
|
|
for (int j = 0; j < Grid.PageSettings.PageSize; j++)
|
|
{
|
|
if (j < Rows.Count && Rows[j].ID == Value)
|
|
{
|
|
foundrow = j;
|
|
|
|
ContinuePaging = false; // prevent the default navigation
|
|
break;
|
|
}
|
|
}
|
|
if (ContinuePaging)
|
|
{
|
|
if (i >= PageCount)
|
|
{
|
|
i = 0;
|
|
}
|
|
await Grid.GoToPage(i + 1);
|
|
|
|
}
|
|
else
|
|
{
|
|
return foundrow;
|
|
}
|
|
}
|
|
return foundrow;
|
|
}
|
|
} |