...
This commit is contained in:
@@ -114,7 +114,8 @@ namespace Back.Controllers
|
||||
|
||||
////-----change Cod
|
||||
Cod.TaxRate = item.TaxRate;
|
||||
//Cod.Title = item.Title;
|
||||
if(!await _servCOD.UsedInTheInvoice(Cod.ID))
|
||||
Cod.Title = item.Title;
|
||||
Cod.UnitID = item.UnitID;
|
||||
Cod.ItemTaxID = item.TaxID;
|
||||
Cod.IsDeleted = false;
|
||||
@@ -138,5 +139,10 @@ namespace Back.Controllers
|
||||
//----Update and sendResult
|
||||
return Ok(await _servCOD.DeleteCod(cod));
|
||||
}
|
||||
[HttpGet("UsedInTheInvoice/{ID}")]
|
||||
public async Task<ActionResult<bool>> UsedInTheInvoice(int ID)
|
||||
{
|
||||
return Ok(await _servCOD.UsedInTheInvoice(ID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -130,7 +130,8 @@ namespace Back.Controllers
|
||||
cus.CustomerType = item.CustomerType;
|
||||
cus.EconomicCode = item.EconomicCode;
|
||||
cus.Email = item.Email;
|
||||
// cus.FullName = item.FullName;
|
||||
if(!await _servCus.UsedInTheInvoice(cus.ID))
|
||||
cus.FullName = item.FullName;
|
||||
cus.Info = item.Info;
|
||||
cus.MeliCode = item.MeliCode;
|
||||
cus.PassportNumber = item.PassportNumber;
|
||||
@@ -157,5 +158,10 @@ namespace Back.Controllers
|
||||
//----Update and sendResult
|
||||
return Ok(await _servCus.DeleteCustomer(cus));
|
||||
}
|
||||
[HttpGet("UsedInTheInvoice/{ID}")]
|
||||
public async Task<ActionResult<bool>> UsedInTheInvoice(int ID)
|
||||
{
|
||||
return Ok(await _servCus.UsedInTheInvoice(ID));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -170,5 +170,9 @@ namespace Back.Services
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> UsedInTheInvoice(int codID)
|
||||
{
|
||||
return await _CODRepo.Get(w => w.invoiceDetails.Any(a=>a.CODID==codID)).AnyAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,12 +9,13 @@ namespace Back.Services
|
||||
public class servCustomer
|
||||
{
|
||||
private readonly IAsyncRepository<Customer> _repoCus;
|
||||
private readonly IAsyncRepository<Invoice> _repoInvoice;
|
||||
private readonly CheckPermission _checkPermission;
|
||||
public servCustomer(IAsyncRepository<Customer> repoCus, CheckPermission checkPermission)
|
||||
public servCustomer(IAsyncRepository<Customer> repoCus, CheckPermission checkPermission, IAsyncRepository<Invoice> repoInvoice)
|
||||
{
|
||||
_repoCus = repoCus;
|
||||
_checkPermission = checkPermission;
|
||||
|
||||
_repoInvoice = repoInvoice;
|
||||
}
|
||||
public async Task<PagingDto<RCustomer>?> GetCustomers(int CompanyID, ItemSerchGetCustomer itemSerch)
|
||||
{
|
||||
@@ -189,6 +190,10 @@ namespace Back.Services
|
||||
|
||||
}
|
||||
}
|
||||
public async Task<bool> UsedInTheInvoice(int cusID)
|
||||
{
|
||||
return await _repoInvoice.Get(w => w.CustomerID == cusID).AnyAsync();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -125,6 +125,9 @@ namespace Back.Services
|
||||
|
||||
if (itemSerch.refInvoiceID != null)
|
||||
invok = invok.Where(w => w.BillReference==itemSerch.refInvoiceID);
|
||||
|
||||
if(itemSerch.CodID != null)
|
||||
invok = invok.Where(w => w.invoiceDetails.Any(wa=>wa.CODID== itemSerch.CodID));
|
||||
//foreach (InputObj item in inputObjs)
|
||||
// invok = invok.Where(ExMethod.GetFunc<Customer>(item.Param, item.Value));
|
||||
|
||||
|
@@ -12,6 +12,7 @@ namespace Shared.DTOs.Serch
|
||||
public int? InvoiceID { get; set; }//
|
||||
public int? refInvoiceID { get; set; }//
|
||||
public int? CustomerID { get; set; }
|
||||
public int? CodID { get; set; }
|
||||
public InvoiceType? invoiceType { get; set; }//
|
||||
public int PageIndex { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 5;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user