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.
188 lines
6.9 KiB
188 lines
6.9 KiB
@page "/Admin/Zeiten/ZeitenList"
|
|
@inject Blazored.SessionStorage.ISessionStorageService sessionStorage
|
|
@inherits ListBase
|
|
@using Syncfusion.Blazor.Grids;
|
|
@using Syncfusion.Blazor.Buttons;
|
|
@using Syncfusion.Blazor.Spinner;
|
|
@using BlazorApp.Helper
|
|
@using BWPMModels;
|
|
|
|
@using BlazorApp.Controller;
|
|
|
|
|
|
<h1>Zeiten</h1>
|
|
|
|
<div class="col-lg-12 control-section">
|
|
<div class="content-wrapper">
|
|
<div class="row">
|
|
<SfGrid DataSource="@GridData" @ref="Grid" AllowPaging="true" AllowSorting="true" AllowRowDragAndDrop="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="Zeiten" OnDataBound="RowDataBoundHandler"></GridEvents>
|
|
<GridColumns>
|
|
@*<GridColumn Type="ColumnType.CheckBox" AllowFiltering="false" AllowSorting="false" Width="60"></GridColumn>*@
|
|
|
|
<GridColumn Field=@nameof(Zeiten.ID) HeaderText="ID" IsIdentity="true" IsPrimaryKey="true" Width="100" Visible="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.bezeichnung) HeaderText="Bezeichnung" Width="100" Visible="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.beschreibung) HeaderText="Beschreibung" Width="100" Visible="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.reihenfolge) HeaderText="Reihenfolge" Width="100" Visible="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.aktiv) HeaderText="Aktiv" Width="100" Visible="true" DisplayAsCheckBox="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.erstellt_am) HeaderText="Erstellt_am" Width="100" Visible="false" Format="d" Type="ColumnType.Date"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.mutiert_am) HeaderText="Mutiert_am" Width="100" Visible="false" Format="d" Type="ColumnType.Date"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.mutierer) HeaderText="Mutierer" Width="100" Visible="false"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.oeffentlich) HeaderText="Oeffentlich" Width="100" Visible="true" DisplayAsCheckBox="true" DefaultValue="true"></GridColumn>
|
|
|
|
<GridColumn Field=@nameof(Zeiten.mandantnr) HeaderText="Mandantnr" Width="100" Visible="false"></GridColumn>
|
|
</GridColumns>
|
|
</SfGrid>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@code{ SfGrid<Zeiten> Grid { get; set; }
|
|
public List<BWPMModels.Zeiten> GridData { get; set; }
|
|
public List<BWPMModels.Zeiten> Zeitens { get; set; }
|
|
string userid = "";
|
|
public static int? pkey { get; set; }
|
|
public bool Initial { get; set; } = true;
|
|
|
|
public bool ContinuePaging = true;
|
|
public bool InitialRender { get; set; }
|
|
public int Value = 0; // consider that value your querystring contains
|
|
public int foundrow = 0;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
/// GridData = OrdersDetails.GetAllRecords();
|
|
GridData = BlazorApp.Controller.ZeitenController.GetAllData();
|
|
}
|
|
|
|
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);
|
|
}
|
|
else
|
|
{
|
|
await sessionStorage.SetItemAsync("UserID", userId);
|
|
}
|
|
}
|
|
}
|
|
private async Task OnBeginHandler(ActionEventArgs<BWPMModels.Zeiten> Args)
|
|
|
|
{
|
|
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save)
|
|
{
|
|
if (Args.Action == "Add")
|
|
{
|
|
|
|
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.ZeitenController.POST(Args.Data);
|
|
Value = Args.Data.ID;
|
|
}
|
|
else
|
|
{
|
|
Args.Data.mutierer = userid.ToString();
|
|
Args.Data.mutiert_am = DateTime.Now;
|
|
BlazorApp.Controller.ZeitenController.PUT(Args.Data);
|
|
}
|
|
}
|
|
}
|
|
|
|
public async Task OnCompletedHandler(ActionEventArgs<BWPMModels.Zeiten> Args)
|
|
|
|
{
|
|
if (Args.RequestType == Syncfusion.Blazor.Grids.Action.RowDragAndDrop)
|
|
{
|
|
List<Zeiten> Rows = await Grid.GetCurrentViewRecords();
|
|
int order = 1;
|
|
foreach (Zeiten row in Rows)
|
|
{
|
|
row.reihenfolge = order;
|
|
BlazorApp.Controller.ZeitenController.PUT(row);
|
|
order = order + 1;
|
|
Grid.Refresh();
|
|
}
|
|
|
|
}
|
|
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.Zeiten> 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<Zeiten> 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;
|
|
} }
|