251 lines
9.2 KiB
Plaintext
251 lines
9.2 KiB
Plaintext
@using Front.Services
|
|
@using Shared.DTOs
|
|
@inject HttpClientController hc;
|
|
@inject Fixedvalues fv;
|
|
<form>
|
|
@* alert *@
|
|
<div class="row">
|
|
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
|
<Icon Name="@alertIconName" class="me-2"></Icon>
|
|
@alertMessage
|
|
</Alert>
|
|
|
|
</div>
|
|
<div class="row g-3">
|
|
|
|
<div class="form-group col-md-6">
|
|
<label class="col-sm-4 col-form-label" style="color:red" for="inputcod">کالا</label>
|
|
<select @bind="itemDTO.CODID" @bind:after="() =>
|
|
{
|
|
if(itemDTO.ID==null)
|
|
itemDTO.vra=cods.Where(w=>w.ID==itemDTO.CODID).Select(s=>s.Tax).FirstOrDefault();
|
|
}" class="form-control" aria-label="Default select example" id="inputcod">
|
|
@if (itemDTO.CODID > 0)
|
|
{
|
|
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
|
|
|
|
}
|
|
|
|
@if (cods != null)
|
|
{
|
|
foreach (var item in cods)
|
|
{
|
|
if (itemDTO.CODID == item.ID)
|
|
{
|
|
<option value="@item.ID" selected>@item.Title</option>
|
|
}
|
|
else
|
|
{
|
|
<option value="@item.ID">@item.Title</option>
|
|
}
|
|
}
|
|
}
|
|
</select>
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">تعداد</label>
|
|
<InputNumber @bind-Value="itemDTO.am" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputam" placeholder="تعداد" />
|
|
</div>
|
|
<div class="form-group col-md-3">
|
|
<label style="color:red" class="col-sm-6 col-form-label">مبلغ واحد</label>
|
|
<InputNumber @bind-Value="itemDTO.fee" @bind-Value:after="AfterAsync" type="text" class="form-control" id="inputfee" placeholder="مبلغ واحد" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row g-3">
|
|
<div class="form-group col-md-4">
|
|
<label class="col-sm-6 col-form-label">مبلغ کل</label>
|
|
<InputNumber @bind-Value="itemDTO.prdis" type="text" class="form-control" id="inputfee" placeholder="مبلغ کل" readonly />
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label class="col-sm-6 col-form-label">مبلغ تخفیف</label>
|
|
<InputNumber @bind-Value="itemDTO.dis" type="text" @bind-Value:after="AfterAsync" class="form-control" id="inputdis" placeholder="مبلغ تخفیف" />
|
|
</div>
|
|
<div class="col-md-4">
|
|
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
|
|
<InputNumber @bind-Value="itemDTO.adis" type="text" class="form-control" id="inputadis" placeholder="مبلغ تخفیف" readonly />
|
|
</div>
|
|
</div>
|
|
<div class="row g-3">
|
|
<div class="form-group col-md-4">
|
|
<label class="col-sm-6 col-form-label">نرخ مالیات</label>
|
|
<InputNumber @bind-Value="itemDTO.vra" type="text" class="form-control" id="inputvra" placeholder="نرخ مالیات" readonly />
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label class="col-sm-6 col-form-label">مبلغ مالیات</label>
|
|
<InputNumber @bind-Value="itemDTO.vam" type="text" class="form-control" id="inputvra" placeholder="مبلغ مالیات" readonly />
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label class="col-sm-6 col-form-label">مبلغ نهایی</label>
|
|
<InputNumber @bind-Value="itemDTO.tsstam" type="text" class="form-control" id="inputvra" placeholder="مبلغ مالیات" readonly />
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
@if (itemDTO.ID == null)
|
|
{
|
|
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
|
|
جدید
|
|
</Button>
|
|
}
|
|
else
|
|
{
|
|
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickUpdate" Type="ButtonType.Button">
|
|
ثبت تغییرات
|
|
</Button>
|
|
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
|
|
حذف
|
|
</Button>
|
|
}
|
|
|
|
|
|
@code {
|
|
// alert
|
|
AlertColor alertColor = AlertColor.Primary;
|
|
IconName alertIconName = IconName.CheckCircleFill;
|
|
bool Hidealert = true;
|
|
string alertMessage = "";
|
|
public int Tax { get; set; } = 0;
|
|
[Parameter] public InvoiceItemDTO itemDTO { get; set; }
|
|
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
|
public List<CODIdName<int>> cods { get; set; } = new();
|
|
public ActionInResultComponent result { get; set; }
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
cods = await fv.GetCODs();
|
|
await base.OnInitializedAsync();
|
|
}
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
|
|
result = new ActionInResultComponent()
|
|
{
|
|
Status = ComponentStatus.fild
|
|
};
|
|
Hidealert = true;
|
|
alertMessage = "";
|
|
await base.OnParametersSetAsync();
|
|
}
|
|
}
|
|
@functions {
|
|
private async Task prdisAsync()
|
|
{
|
|
if (itemDTO.ID == null)
|
|
itemDTO.prdis = itemDTO.fee * itemDTO.am;
|
|
}
|
|
private async Task adisAsync()
|
|
{
|
|
if (itemDTO.ID == null)
|
|
itemDTO.adis= itemDTO.prdis - itemDTO.dis;
|
|
|
|
// await AftervamAsync();
|
|
}
|
|
private async Task vamAsync()
|
|
{
|
|
if (itemDTO.ID == null)
|
|
itemDTO.vam = itemDTO.vra * itemDTO.adis / 100;
|
|
}
|
|
private async Task tsstamAsync()
|
|
{
|
|
if (itemDTO.ID == null)
|
|
itemDTO.tsstam = itemDTO.vam + itemDTO.adis ;
|
|
}
|
|
private async Task AfterAsync()
|
|
{
|
|
await prdisAsync();
|
|
await adisAsync();
|
|
await vamAsync();
|
|
await tsstamAsync();
|
|
}
|
|
public async Task OnClickDelete()
|
|
{
|
|
|
|
// var rsp = await hc.Delete($"Customer/Delete/{Cus.ID}");
|
|
// if (rsp.IsSuccessStatusCode)
|
|
// {
|
|
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
|
// if (request)
|
|
// {
|
|
// result.Status = ComponentStatus.success;
|
|
// result.Action = ComponentAction.delete;
|
|
// await OnMultipleOfThree.InvokeAsync(result);
|
|
// }
|
|
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
|
// }
|
|
|
|
// else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
|
// {
|
|
// ShowDangerAlert("مشتری با این شناسه یافت نشد");
|
|
// }
|
|
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
|
|
|
|
|
|
|
|
|
}
|
|
public async Task OnClickUpdate()
|
|
{
|
|
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
|
// {
|
|
// if (ItemSearchCustomertype > 0)
|
|
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
|
|
|
// var rsp = await hc.Put<RCustomer>("Customer/Update", Cus);
|
|
// if (rsp.IsSuccessStatusCode)
|
|
// {
|
|
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
|
// if (request)
|
|
// {
|
|
// result.Status = ComponentStatus.success;
|
|
// result.Action = ComponentAction.update;
|
|
// await OnMultipleOfThree.InvokeAsync(result);
|
|
// }
|
|
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
|
// }
|
|
// else
|
|
// {
|
|
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
|
// ShowDangerAlert(request[0]);
|
|
// }
|
|
// }
|
|
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
|
}
|
|
public async Task OnClickAdd()
|
|
{
|
|
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
|
// {
|
|
// if (ItemSearchCustomertype > 0)
|
|
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
|
// Cus.ID = null;
|
|
|
|
|
|
// var rsp = await hc.Post<RCustomer>("Customer/Add", Cus);
|
|
// if (rsp.IsSuccessStatusCode)
|
|
// {
|
|
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
|
|
|
// if (request)
|
|
// {
|
|
// result.Status = ComponentStatus.success;
|
|
// result.Action = ComponentAction.add;
|
|
// await OnMultipleOfThree.InvokeAsync(result);
|
|
// }
|
|
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
|
// }
|
|
// else
|
|
// {
|
|
|
|
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
|
// ShowDangerAlert(request[0]);
|
|
// }
|
|
// }
|
|
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
|
}
|
|
} |