cus
This commit is contained in:
@@ -29,8 +29,7 @@ namespace Back.Services
|
|||||||
if (!string.IsNullOrEmpty(itemSerch.Phone))
|
if (!string.IsNullOrEmpty(itemSerch.Phone))
|
||||||
invok = invok.Where(w => w.Phone.Contains(itemSerch.Phone));
|
invok = invok.Where(w => w.Phone.Contains(itemSerch.Phone));
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(itemSerch.MeliCode))
|
|
||||||
invok = invok.Where(w => w.MeliCode.Contains(itemSerch.MeliCode));
|
|
||||||
|
|
||||||
if (itemSerch.CustomerType.HasValue)
|
if (itemSerch.CustomerType.HasValue)
|
||||||
invok = invok.Where(w => w.CustomerType==itemSerch.CustomerType);
|
invok = invok.Where(w => w.CustomerType==itemSerch.CustomerType);
|
||||||
@@ -39,7 +38,7 @@ namespace Back.Services
|
|||||||
invok = invok.Where(w => w.ID == itemSerch.ID);
|
invok = invok.Where(w => w.ID == itemSerch.ID);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(itemSerch.EconomicCode))
|
if (!string.IsNullOrEmpty(itemSerch.EconomicCode))
|
||||||
invok = invok.Where(w => w.EconomicCode.Contains(itemSerch.EconomicCode));
|
invok = invok.Where(w => w.EconomicCode.Contains(itemSerch.EconomicCode) || w.MeliCode.Contains(itemSerch.EconomicCode));
|
||||||
#endregion
|
#endregion
|
||||||
//-----------------------
|
//-----------------------
|
||||||
return await invok.Select(s=>new RCustomer()
|
return await invok.Select(s=>new RCustomer()
|
||||||
|
25
Shared/DTOs/ActionInResultComponent.cs
Normal file
25
Shared/DTOs/ActionInResultComponent.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Shared.DTOs
|
||||||
|
{
|
||||||
|
public enum ComponentAction
|
||||||
|
{
|
||||||
|
add,
|
||||||
|
update,
|
||||||
|
delete
|
||||||
|
}
|
||||||
|
public enum ComponentStatus
|
||||||
|
{
|
||||||
|
success,
|
||||||
|
fild
|
||||||
|
}
|
||||||
|
public class ActionInResultComponent
|
||||||
|
{
|
||||||
|
public ComponentAction Action { get; set; }
|
||||||
|
public ComponentStatus Status { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -13,7 +13,6 @@ namespace Shared.DTOs
|
|||||||
public CustomerType? CustomerType { get; set; }
|
public CustomerType? CustomerType { get; set; }
|
||||||
public string? EconomicCode { get; set; }
|
public string? EconomicCode { get; set; }
|
||||||
public string? Phone { get; set; }
|
public string? Phone { get; set; }
|
||||||
public string? MeliCode { get; set; }
|
|
||||||
public string? ZipCode { get; set; }
|
public string? ZipCode { get; set; }
|
||||||
public int PageIndex { get; set; } = 1;
|
public int PageIndex { get; set; } = 1;
|
||||||
public int PageSize { get; set; } = 5;
|
public int PageSize { get; set; } = 5;
|
||||||
|
47
TaxPayerFull/CUSComponent/CustomerItem.razor
Normal file
47
TaxPayerFull/CUSComponent/CustomerItem.razor
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
@using Shared.DTOs
|
||||||
|
<p>سلام</p>
|
||||||
|
@if (Cus.ID==-1)
|
||||||
|
{
|
||||||
|
<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 {
|
||||||
|
|
||||||
|
[Parameter] public RCustomer Cus { get; set; }
|
||||||
|
|
||||||
|
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
||||||
|
|
||||||
|
public ActionInResultComponent result { get; set; }
|
||||||
|
protected override Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
return base.OnParametersSetAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@functions{
|
||||||
|
public async Task OnClickDelete(){
|
||||||
|
result.Action = ComponentAction.delete;
|
||||||
|
await OnMultipleOfThree.InvokeAsync(result);
|
||||||
|
}
|
||||||
|
public async Task OnClickUpdate()
|
||||||
|
{
|
||||||
|
result.Action = ComponentAction.update;
|
||||||
|
await OnMultipleOfThree.InvokeAsync(result);
|
||||||
|
}
|
||||||
|
public async Task OnClickAdd()
|
||||||
|
{
|
||||||
|
result.Action = ComponentAction.add;
|
||||||
|
await OnMultipleOfThree.InvokeAsync(result);
|
||||||
|
}
|
||||||
|
}
|
8
TaxPayerFull/CUSComponent/Employee.cs
Normal file
8
TaxPayerFull/CUSComponent/Employee.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Front.CUSComponent
|
||||||
|
{
|
||||||
|
public class Employee
|
||||||
|
{
|
||||||
|
public string LastName { get; set; }
|
||||||
|
public string FirstName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="CUSComponent\Employee.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Blazor.Bootstrap" Version="2.2.0" />
|
<PackageReference Include="Blazor.Bootstrap" Version="2.2.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
@using Shared.DTOs.Serch
|
@using Shared.DTOs.Serch
|
||||||
@inject HttpClientController hc;
|
@inject HttpClientController hc;
|
||||||
<PageTitle>مشتری</PageTitle>
|
<PageTitle>مشتری</PageTitle>
|
||||||
|
<Modal @ref="modal" />
|
||||||
|
|
||||||
<Preload LoadingText="در حال بارگذاری..." />
|
<Preload LoadingText="در حال بارگذاری..." />
|
||||||
@* search *@
|
@* search *@
|
||||||
@@ -17,22 +18,28 @@
|
|||||||
<li class="list-group-item" data-toggle="modal" data-target="#issue">
|
<li class="list-group-item" data-toggle="modal" data-target="#issue">
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="col-md-1">
|
<div class="col-md-1">
|
||||||
<input placeholder="شناسه" style="text-align:center;" class="form-control" type="text" >
|
<input @bind-value="itemsearch.ID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text" >
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<input placeholder="نوع" style="text-align:center;" class="form-control" type="text">
|
<select @bind="ItemSearchCustomertype" class="form-control" aria-label="Default select example">
|
||||||
|
<option value="0" style="color: #b5b5b5" selected>نوع مشتری...</option>
|
||||||
|
<option value="1">حقیقی</option>
|
||||||
|
<option value="2">حقوقی</option>
|
||||||
|
<option value="3">مشارکت مدنی</option>
|
||||||
|
<option value="4">اتباع غیر ایرانی</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<input placeholder="کد اقتصادی / کدملی" style="text-align:center;" class="form-control" type="text">
|
<input @bind-value="itemsearch.EconomicCode" placeholder="کد اقتصادی / کدملی" style="text-align:center;" class="form-control" type="text">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<input placeholder="تلفن" style="text-align:center;" class="form-control" type="text">
|
<input @bind-value="itemsearch.Phone" placeholder="تلفن" style="text-align:center;" class="form-control" type="text">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
<input placeholder="کد پستی" style="text-align:center;" class="form-control" type="text">
|
<input @bind-value="itemsearch.ZipCode" placeholder="کد پستی" style="text-align:center;" class="form-control" type="text">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<button type="submit" class="btn btn-primary">جستجو</button>
|
<button @onclick="() => LoadCus(1)" type="submit" class="btn btn-primary">جستجو</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -50,7 +57,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<button type="submit" class="btn btn-primary">جدید</button>
|
<button type="submit" @onclick="()=>CustomerItem(null)" class="btn btn-primary">جدید</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -71,8 +78,8 @@
|
|||||||
@if (request != null)
|
@if (request != null)
|
||||||
{
|
{
|
||||||
<LTable ModelinComponent="request?.list" />
|
<LTable ModelinComponent="request?.list" />
|
||||||
|
|
||||||
@* pagination *@
|
@* pagination *@
|
||||||
|
<p style="color:red">@request?.RowCount آیتم یافت شد</p>
|
||||||
<nav aria-label="Page navigation">
|
<nav aria-label="Page navigation">
|
||||||
<ul class="pagination justify-content-center">
|
<ul class="pagination justify-content-center">
|
||||||
@for (int page = 1; page <= request?.PageCount; page++)
|
@for (int page = 1; page <= request?.PageCount; page++)
|
||||||
@@ -94,17 +101,18 @@
|
|||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@layout PanelLayout
|
@layout PanelLayout
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
|
||||||
|
|
||||||
|
|
||||||
|
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||||
|
public int? ItemSearchCustomertype { get; set; }
|
||||||
|
ItemSerchGetCustomer itemsearch = new ItemSerchGetCustomer();
|
||||||
|
[Parameter, SupplyParameterFromQuery]
|
||||||
|
public int? PageIndex { get; set; }
|
||||||
|
public Shared.DTOs.PagingDto<RCustomer>? request { get; set; }
|
||||||
|
private Modal modal = default!;
|
||||||
// alert
|
// alert
|
||||||
AlertColor alertColor = AlertColor.Primary;
|
AlertColor alertColor = AlertColor.Primary;
|
||||||
IconName alertIconName = IconName.CheckCircleFill;
|
IconName alertIconName = IconName.CheckCircleFill;
|
||||||
@@ -113,15 +121,10 @@
|
|||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (PageIndex == null) PageIndex = 1;
|
if (PageIndex == null) PageIndex = 1;
|
||||||
await LoadCus(PageIndex.Value);
|
await LoadCus(PageIndex.Value);
|
||||||
await base.OnParametersSetAsync();
|
await base.OnParametersSetAsync();
|
||||||
}
|
}
|
||||||
[Parameter, SupplyParameterFromQuery]
|
|
||||||
public int? PageIndex { get; set; }
|
|
||||||
|
|
||||||
public Shared.DTOs.PagingDto<RCustomer>? request { get; set; }
|
|
||||||
}
|
}
|
||||||
@functions {
|
@functions {
|
||||||
private void ShowSuccessAlert(string msg)
|
private void ShowSuccessAlert(string msg)
|
||||||
@@ -131,7 +134,6 @@
|
|||||||
alertIconName = IconName.CheckCircleFill;
|
alertIconName = IconName.CheckCircleFill;
|
||||||
alertMessage = msg;
|
alertMessage = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowDangerAlert(string msg)
|
private void ShowDangerAlert(string msg)
|
||||||
{
|
{
|
||||||
Hidealert = false;
|
Hidealert = false;
|
||||||
@@ -141,11 +143,15 @@
|
|||||||
}
|
}
|
||||||
public async Task LoadCus(int pi)
|
public async Task LoadCus(int pi)
|
||||||
{
|
{
|
||||||
|
if (ItemSearchCustomertype > 0)
|
||||||
|
itemsearch.CustomerType = (CustomerType)ItemSearchCustomertype;
|
||||||
|
else
|
||||||
|
itemsearch.CustomerType = null;
|
||||||
|
|
||||||
|
itemsearch.PageSize = 10;
|
||||||
|
itemsearch.PageIndex = pi;
|
||||||
PreloadService.Show(SpinnerColor.Dark);
|
PreloadService.Show(SpinnerColor.Dark);
|
||||||
var rsp = await hc.Post<ItemSerchGetCustomer>("Customer/GetAll", new ItemSerchGetCustomer()
|
var rsp = await hc.Post<ItemSerchGetCustomer>("Customer/GetAll", itemsearch);
|
||||||
{
|
|
||||||
PageIndex=pi
|
|
||||||
});
|
|
||||||
if (rsp.IsSuccessStatusCode)
|
if (rsp.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
request = await rsp.Content.ReadFromJsonAsync<PagingDto<RCustomer>>();
|
request = await rsp.Content.ReadFromJsonAsync<PagingDto<RCustomer>>();
|
||||||
@@ -160,4 +166,40 @@
|
|||||||
}
|
}
|
||||||
PreloadService.Hide();
|
PreloadService.Hide();
|
||||||
}
|
}
|
||||||
|
public async Task CallBackCustomerItem(ActionInResultComponent result)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (result.Action == ComponentAction.add)
|
||||||
|
{
|
||||||
|
if (result.Status==ComponentStatus.success)
|
||||||
|
ShowSuccessAlert("مشتری جدید با موفقیت اضافه شد");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (result.Action == ComponentAction.update)
|
||||||
|
{
|
||||||
|
if (result.Status == ComponentStatus.success)
|
||||||
|
ShowSuccessAlert("اطلاعات مشتری با موفقیت ویرایش شد");
|
||||||
|
}
|
||||||
|
else if (result.Action == ComponentAction.delete)
|
||||||
|
{
|
||||||
|
if (result.Status == ComponentStatus.success)
|
||||||
|
ShowSuccessAlert("مشتری با موفقیت حذف شد");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.Status == ComponentStatus.success)
|
||||||
|
await LoadCus(1);
|
||||||
|
|
||||||
|
await modal.HideAsync();
|
||||||
|
}
|
||||||
|
public async Task CustomerItem(int? ID)
|
||||||
|
{
|
||||||
|
var parameters = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
if(ID == null) parameters.Add("Cus", new RCustomer(){ID=-1});
|
||||||
|
else parameters.Add("Cus", request.list.Where(w=>w.ID==ID));
|
||||||
|
|
||||||
|
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
||||||
|
await modal.ShowAsync<CustomerItem>(title: ID == null ? "مشتری جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user