This commit is contained in:
mmrbnjd
2024-06-27 19:18:50 +03:30
parent 6c8aaadac3
commit a44b27b8a7
9 changed files with 109 additions and 16 deletions

View File

@@ -16,21 +16,24 @@
<h6 style="color:red">نکته:</h6>
<ul>
<li>در زمان ویرایش نمیتوانید نام کالا را عوض کنید</li>
@if (_UsedInTheInvoice)
{
<li>با این کالا صورتحسابی صادر کرده اید ،نمیتوانید نام کالا را ویرایش کنید</li>
}
<li>زمان ویرایش دقت کنید تغییرات میتواند روی فاکتورهای صادر شده تائیر بگذارد</li>
</ul>
}
<div class="row g-3">
<div class="form-group col-md-6">
<label class="col-sm-4 col-form-label" style="color:red" for="inputTitle">نام کالا</label>
@if (Cod.ID != 0)
@if (Cod.ID == 0 || !_UsedInTheInvoice)
{
<InputText @bind-Value="Cod.Title" type="text" class="form-control" id="inputTitle" placeholder="نام کالا"
readonly />
/>
}
else
{
<InputText @bind-Value="Cod.Title" type="text" class="form-control" id="inputTitle" placeholder="نام کالا" />
<InputText @bind-Value="Cod.Title" type="text" class="form-control" id="inputTitle" placeholder="نام کالا" readonly />
}
</div>
@@ -95,6 +98,13 @@ else
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
حذف
</Button>
@if (_UsedInTheInvoice)
{
<Button class="mt-3" Color="ButtonColor.Link" @onclick="OnClickGoToInvoice" Type="ButtonType.Button">
صورتحساب های مرتبط
</Button>
}
}
@@ -105,25 +115,43 @@ else
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
bool _UsedInTheInvoice = false;
[Parameter] public RCOD Cod { get; set; }
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
[Parameter] public List<IdName<int>>? Unitrequest { get; set; }
public ActionInResultComponent result { get; set; }
protected override Task OnParametersSetAsync()
protected override async Task OnParametersSetAsync()
{
result = new ActionInResultComponent()
{
Status = ComponentStatus.fild
};
Hidealert = true;
alertMessage = "";
return base.OnParametersSetAsync();
await UsedInTheInvoice();
await base.OnParametersSetAsync();
}
}
@functions {
public async Task OnClickGoToInvoice()
{
hc._nav.NavigateTo($"Invoice/{"cod:" + Cod.ID}");
}
public async Task UsedInTheInvoice()
{
if (Cod.ID!=0)
{
var rsp = await hc.Get($"Cod/UsedInTheInvoice/{Cod.ID}");
if (rsp.IsSuccessStatusCode)
_UsedInTheInvoice = await rsp.Content.ReadFromJsonAsync<bool>();
else _UsedInTheInvoice = false;
}
}
private void ShowSuccessAlert(string msg)
{
Hidealert = false;

View File

@@ -15,14 +15,19 @@
<h6 style="color:red">نکته:</h6>
<ul>
<li>در زمان ویرایش نمیتوانید نام کامل را عوض کنید</li>
@if (_UsedInTheInvoice)
{
<li>با این مشتری صورتحسابی صادر کرده اید ، نمیتوانید نام کامل را ویرایش کنید</li>
}
<li>زمان ویرایش دقت کنید تغییرات میتواند روی فاکتورهای صادر شده تائیر بگذارد</li>
</ul>
}
<div class="row g-3">
<div class="form-group col-md-6">
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">نام کامل</label>
@if (Cus.ID == 0)
@if (Cus.ID == 0 || !_UsedInTheInvoice)
{
<InputText @bind-Value="Cus.FullName" type="text" class="form-control" id="inputFullName" placeholder="نام کامل" />
}
@@ -111,6 +116,12 @@ else
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
حذف
</Button>
@if (_UsedInTheInvoice)
{
<Button class="mt-3" Color="ButtonColor.Link" @onclick="OnClickGoToInvoice" Type="ButtonType.Button">
صورتحساب های مرتبط
</Button>
}
}
@@ -119,13 +130,14 @@ else
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
bool _UsedInTheInvoice = false;
string alertMessage = "";
[Parameter] public RCustomer Cus { get; set; }
public int? ItemSearchCustomertype { get; set; }
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
public ActionInResultComponent result { get; set; }
protected override Task OnParametersSetAsync()
protected override async Task OnParametersSetAsync()
{
if (Cus.CustomerType != null)
ItemSearchCustomertype = (int)Cus.CustomerType;
@@ -136,7 +148,8 @@ else
};
Hidealert = true;
alertMessage = "";
return base.OnParametersSetAsync();
await UsedInTheInvoice();
await base.OnParametersSetAsync();
}
}
@functions {
@@ -154,6 +167,10 @@ else
alertIconName = IconName.ExclamationTriangleFill;
alertMessage = msg;
}
public async Task OnClickGoToInvoice()
{
hc._nav.NavigateTo($"Invoice/{"cus:"+Cus.ID}");
}
public async Task OnClickDelete()
{
@@ -238,4 +255,16 @@ else
}
else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
}
public async Task UsedInTheInvoice()
{
if (Cus.ID!=0)
{
var rsp = await hc.Get($"Customer/UsedInTheInvoice/{Cus.ID}");
if (rsp.IsSuccessStatusCode)
_UsedInTheInvoice = await rsp.Content.ReadFromJsonAsync<bool>();
else _UsedInTheInvoice = false;
}
}
}

View File

@@ -1,4 +1,5 @@
@page "/Invoice"
@page "/Invoice/{input}"
@using Front.Services
@using Shared
@using Shared.DTOs
@@ -130,6 +131,7 @@
return await Task.FromResult(request.ApplyTo(customers.OrderBy(customer => customer.CustomerName)));
}
//-----------
[Parameter] public string? input { get; set; }
[Inject] protected PreloadService PreloadService { get; set; } = default!;
public int? ItemSearchInvoicetype { get; set; }
ItemSerchGetInvoices itemsearch = new ItemSerchGetInvoices();
@@ -146,6 +148,15 @@
protected override async Task OnParametersSetAsync()
{
if (PageIndex == null) PageIndex = 1;
if (!string.IsNullOrEmpty(input))
{
if (input.StartsWith("cus"))
itemsearch.CustomerID = Convert.ToInt32(input.Split(':')[1]);
else if (input.StartsWith("cod"))
itemsearch.CodID =Convert.ToInt32(input.Split(':')[1]);
}
await LoadInvoice(PageIndex.Value);
await base.OnParametersSetAsync();
}