diff --git a/Back/Services/servCustomer.cs b/Back/Services/servCustomer.cs
index 1a7a819..83cc57e 100644
--- a/Back/Services/servCustomer.cs
+++ b/Back/Services/servCustomer.cs
@@ -29,8 +29,7 @@ namespace Back.Services
if (!string.IsNullOrEmpty(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)
invok = invok.Where(w => w.CustomerType==itemSerch.CustomerType);
@@ -39,7 +38,7 @@ namespace Back.Services
invok = invok.Where(w => w.ID == itemSerch.ID);
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
//-----------------------
return await invok.Select(s=>new RCustomer()
diff --git a/Shared/DTOs/ActionInResultComponent.cs b/Shared/DTOs/ActionInResultComponent.cs
new file mode 100644
index 0000000..2b425ad
--- /dev/null
+++ b/Shared/DTOs/ActionInResultComponent.cs
@@ -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; }
+ }
+}
diff --git a/Shared/DTOs/ItemSerchGetCustomer.cs b/Shared/DTOs/ItemSerchGetCustomer.cs
index 3d00ee5..3cb15a6 100644
--- a/Shared/DTOs/ItemSerchGetCustomer.cs
+++ b/Shared/DTOs/ItemSerchGetCustomer.cs
@@ -13,7 +13,6 @@ namespace Shared.DTOs
public CustomerType? CustomerType { get; set; }
public string? EconomicCode { get; set; }
public string? Phone { get; set; }
- public string? MeliCode { get; set; }
public string? ZipCode { get; set; }
public int PageIndex { get; set; } = 1;
public int PageSize { get; set; } = 5;
diff --git a/TaxPayerFull/CUSComponent/CustomerItem.razor b/TaxPayerFull/CUSComponent/CustomerItem.razor
new file mode 100644
index 0000000..dc99b87
--- /dev/null
+++ b/TaxPayerFull/CUSComponent/CustomerItem.razor
@@ -0,0 +1,47 @@
+@using Shared.DTOs
+
سلام
+@if (Cus.ID==-1)
+{
+
+}
+else
+{
+
+
+}
+
+
+@code {
+
+ [Parameter] public RCustomer Cus { get; set; }
+
+ [Parameter] public EventCallback 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);
+ }
+}
\ No newline at end of file
diff --git a/TaxPayerFull/CUSComponent/Employee.cs b/TaxPayerFull/CUSComponent/Employee.cs
new file mode 100644
index 0000000..967586a
--- /dev/null
+++ b/TaxPayerFull/CUSComponent/Employee.cs
@@ -0,0 +1,8 @@
+namespace Front.CUSComponent
+{
+ public class Employee
+ {
+ public string LastName { get; set; }
+ public string FirstName { get; set; }
+ }
+}
diff --git a/TaxPayerFull/Front.csproj b/TaxPayerFull/Front.csproj
index 7f214af..ac6ab40 100644
--- a/TaxPayerFull/Front.csproj
+++ b/TaxPayerFull/Front.csproj
@@ -8,6 +8,10 @@
+
+
+
+
diff --git a/TaxPayerFull/Pages/UserPanel/Customer.razor b/TaxPayerFull/Pages/UserPanel/Customer.razor
index 788052c..fafbc0a 100644
--- a/TaxPayerFull/Pages/UserPanel/Customer.razor
+++ b/TaxPayerFull/Pages/UserPanel/Customer.razor
@@ -5,6 +5,7 @@
@using Shared.DTOs.Serch
@inject HttpClientController hc;
مشتری
+
@* search *@
@@ -17,22 +18,28 @@
@@ -50,7 +57,7 @@
-
+
@@ -71,8 +78,8 @@
@if (request != null)
{
-
@* pagination *@
+ @request?.RowCount آیتم یافت شد
-
-
-
}
@layout PanelLayout
@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? request { get; set; }
+ private Modal modal = default!;
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
@@ -113,15 +121,10 @@
protected override async Task OnParametersSetAsync()
{
-
if (PageIndex == null) PageIndex = 1;
await LoadCus(PageIndex.Value);
await base.OnParametersSetAsync();
- }
- [Parameter, SupplyParameterFromQuery]
- public int? PageIndex { get; set; }
-
- public Shared.DTOs.PagingDto? request { get; set; }
+ }
}
@functions {
private void ShowSuccessAlert(string msg)
@@ -131,7 +134,6 @@
alertIconName = IconName.CheckCircleFill;
alertMessage = msg;
}
-
private void ShowDangerAlert(string msg)
{
Hidealert = false;
@@ -141,11 +143,15 @@
}
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);
- var rsp = await hc.Post("Customer/GetAll", new ItemSerchGetCustomer()
- {
- PageIndex=pi
- });
+ var rsp = await hc.Post("Customer/GetAll", itemsearch);
if (rsp.IsSuccessStatusCode)
{
request = await rsp.Content.ReadFromJsonAsync>();
@@ -160,4 +166,40 @@
}
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();
+
+ 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(this, CallBackCustomerItem));
+ await modal.ShowAsync(title: ID == null ? "مشتری جدید" : "ویرایش اطلاعات", parameters: parameters);
+
+ }
}
\ No newline at end of file