Files
SHERPA/SHERPA.BBM.UI/Components/NegotiationEditor.razor
T
2021-12-10 10:42:12 +01:00

160 lines
5.2 KiB
Plaintext

@using Blazorise
@using SHERPA.BBM.UI.Data
@using SHERPA.BBM.UI.Components;
@using CORE.DbModels
@inject BBM_EFService BBMService
<div class="card">
<div class="card-header bg-info text-light">
<b>Modifica</b>
</div>
<div class="card-body small">
<EditForm Model="@_negotiation">
<DataAnnotationsValidator />
<Blazorise.ValidationSummary />
<div class="row">
<div class="col-6 col-lg-3">
<label for="itemSel">Cliente:</label>
<InputSelect @bind-Value="@SelCustomerId" id="itemSel" class="form-control form-control-sm" title="Cliente">
@foreach (var item in customersList)
{
<option value="@item.CustomerId">@item.RagSoc | @item.PI | @item.Descript</option>
}
</InputSelect>
</div>
<div class="col-6 col-lg-3">
<label for="compSel">Basket:</label>
<InputSelect @bind-Value="@SelBasketId" id="compSel" class="form-control form-control-sm" title="Azienda">
@foreach (var item in basketsList)
{
<option value="@item.BasketId">@item.CodBasket - @item.Descript</option>
}
</InputSelect>
</div>
<div class="col-6 col-lg-2">
<label for="anno">Anno:</label>
<InputNumber id="anno" @bind-Value="_negotiation.Anno" class="form-control form-control-sm" />
</div>
<div class="col-6 col-lg-2">
<label for="dataIns">Inserita:</label>
<DateEdit InputMode="DateInputMode.DateTime" @bind-Date="@_negotiation.DataIns" Class="form-control form-control-sm" />
</div>
<div class="col-6 col-lg-2">
<div class="form-group">
<label for="codNeg">Codice:</label>
<InputText id="codNeg" @bind-Value="_negotiation.CodNegotiation" class="form-control form-control-sm" />
</div>
</div>
<div class="col-12 col-lg-6">
<label for="descript">Descrizione:</label>
<InputTextArea id="descript" cla @bind-Value="_negotiation.Descript" class="form-control form-control-sm" />
</div>
<div class="col-12 col-lg-6">
<div>
<label for="dataIns">Path:</label>
<InputText id="BasePath" @bind-Value="_negotiation.BasePath" class="form-control form-control-sm" />
</div>
<div class="row">
<div class="col-6">
<input type="submit" class="btn btn-success btn-block" value="Save" @onclick="saveUpdate" />
</div>
<div class="col-6">
<button type="button" class="btn btn-warning btn-block" value="Cancel" @onclick="cancelUpdate">Cancel</button>
</div>
</div>
</div>
</div>
</EditForm>
</div>
</div>
@code {
private List<CORE.DbModels.CustomersModel> customersList;
private List<CORE.DbModels.BasketsModel> basketsList;
private int _selCustId = 0;
protected int SelCustomerId
{
get
{
int answ = 1;
if (_negotiation != null)
{
answ = _negotiation.CustomerId;
}
return answ;
}
set
{
_negotiation.CustomerId = value;
}
}
protected int SelBasketId
{
get
{
int answ = 1;
if (_negotiation != null)
{
answ = _negotiation.BasketId;
}
return answ;
}
set
{
_negotiation.BasketId = value;
}
}
protected CORE.DbModels.NegotiationsModel _negotiation = new NegotiationsModel();
[Parameter]
public CORE.DbModels.NegotiationsModel Negotiation
{
get
{
return _negotiation = null;
}
set
{
_negotiation = value;
}
}
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
private async Task saveUpdate()
{
if (_negotiation != null)
{
BBMService.NegotiationUpdate(_negotiation);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("Negotiation null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
customersList = await BBMService.CustomersGetAll("");
basketsList = await BBMService.BasketsGetAsync(1, "");
}
}