From 5665b91aa15562b19abc010fb1a383cde409adce Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Sun, 28 Jul 2024 15:34:46 +0330 Subject: [PATCH] ... --- Back/Back.csproj | 2 +- Shared/DTOs/PromotionDetailDto.cs | 4 +- Shared/DTOs/PromotionDto.cs | 1 + TaxPayerFull/CUSComponent/OrderItemNew.razor | 170 ++++++++++++++++--- TaxPayerFull/FixedValues.cs | 49 ++++-- TaxPayerFull/Pages/UserPanel/Orders.razor | 2 +- TaxPayerFull/Program.cs | 4 +- 7 files changed, 187 insertions(+), 45 deletions(-) diff --git a/Back/Back.csproj b/Back/Back.csproj index fd97cd7..899d7e4 100644 --- a/Back/Back.csproj +++ b/Back/Back.csproj @@ -36,7 +36,7 @@ - ..\..\Dlls\Service.dll + ..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll diff --git a/Shared/DTOs/PromotionDetailDto.cs b/Shared/DTOs/PromotionDetailDto.cs index 8a9abba..c7164ca 100644 --- a/Shared/DTOs/PromotionDetailDto.cs +++ b/Shared/DTOs/PromotionDetailDto.cs @@ -11,8 +11,8 @@ namespace Shared.DTOs public int ID { get; set; } public int PermissionID { get; set; } public string PermissionTitle { get; set; } - public int CreditAmount { get; set; } - public decimal APrice { get; set; } + public int CreditAmount { get; set; } + public decimal APrice { get; set; } public decimal TPrice { get { return APrice * CreditAmount; } } } } diff --git a/Shared/DTOs/PromotionDto.cs b/Shared/DTOs/PromotionDto.cs index 45ee97c..bd4a335 100644 --- a/Shared/DTOs/PromotionDto.cs +++ b/Shared/DTOs/PromotionDto.cs @@ -10,6 +10,7 @@ namespace Shared.DTOs { public int ID { get; set; } public string Name { get; set; } + public decimal TotalPrice { get { return promotionDetails==null ? 0 : promotionDetails.Sum(s => s.TPrice); } } public ICollection promotionDetails { get; set; } } } diff --git a/TaxPayerFull/CUSComponent/OrderItemNew.razor b/TaxPayerFull/CUSComponent/OrderItemNew.razor index 4328df6..d91f11a 100644 --- a/TaxPayerFull/CUSComponent/OrderItemNew.razor +++ b/TaxPayerFull/CUSComponent/OrderItemNew.razor @@ -6,10 +6,10 @@ -
-
+
+
- نوع سفارش + @orderSelectName @foreach (var i in orderstype) { @@ -18,46 +18,172 @@
-
+
- -
-
-
+
+ + + + + + + + + + + @if (Selected!=null) + { + if (Selected.promotionDetails.Any(w => w.PermissionID == 3)) + { + + + + + + } + + if (Selected.promotionDetails.Any(w => w.PermissionID == 4)) + { + + + + + + } + + + if (Selected.promotionDetails.Any(w => w.PermissionID == 5)) + { + + + + + + } + if (Selected.promotionDetails.Any(w => w.PermissionID == 16)) + { + + + + + + } + + } + +
سیستمقیمت پایهتعداد
@Selected.promotionDetails.Where(w => w.PermissionID == 3).Select(s => s.PermissionTitle).FirstOrDefault()@Selected.promotionDetails.Where(w => w.PermissionID == 3).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال + @if (Selected.ID < 0) + { + + + } + else + { + + + } +
@Selected.promotionDetails.Where(w => w.PermissionID == 4).Select(s => s.PermissionTitle).FirstOrDefault()@Selected.promotionDetails.Where(w => w.PermissionID == 4).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال + @if (Selected.ID < 0) + { + + + } + else + { + + + } +
@Selected.promotionDetails.Where(w => w.PermissionID == 5).Select(s => s.PermissionTitle).FirstOrDefault()@Selected.promotionDetails.Where(w => w.PermissionID == 5).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال + @if (Selected.ID < 0) + { + + + } + else + { + + + } +
@Selected.promotionDetails.Where(w => w.PermissionID == 16).Select(s => s.PermissionTitle).FirstOrDefault()@Selected.promotionDetails.Where(w => w.PermissionID == 16).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال + @if (Selected.ID < 0) + { + + } + else + { + + + } +
+ + + +
+
+ قیمت نهایی : @TotalPrice.ToString("N0") ريال +
- +
@code { - string orderSelectName = ""; + string orderSelectName = "نوع سفارش"; int orderSelectID = 0; [Inject] protected PreloadService PreloadService { get; set; } = default!; [Parameter] public EventCallback OnMultipleOfThree { get; set; } - List> orderstype = new List>() - { new IdName() { ID=999,Title="شخصی" }, - new IdName() { ID=919,Title="qw" }}; - public List Promotions { get; set; } = new(); - public List Pricing { get; set; } = new(); + List> orderstype = new List>(); + public List Promotions { get; set; } = new(); + public PromotionDto? Selected { get; set; } = null; + // invoice cod cus tax + int[] values = { 0,0,0,0}; + decimal TotalPrice = 0; } @functions { protected override async Task OnParametersSetAsync() { + Promotions = await fv.LoadPromotion(); - Pricing = await fv.LoadPricing(); orderstype.AddRange(Promotions.Select(s => new IdName - { - ID = s.ID, - Title = s.Name - }).ToList()); + { ID = s.ID, Title = s.Name }).ToList()); await base.OnParametersSetAsync(); } - public async Task OnChange(int ID,string Title) + public async Task OnChange(int ID, string Title) { orderSelectID = ID; orderSelectName = Title; + + Selected = Promotions.Where(w => w.ID == ID).First(); + } + private async Task OnInput() + { + if (Selected != null) + { + var itemFac= Selected.promotionDetails.Where(w => w.PermissionID == 3).FirstOrDefault(); + if (itemFac!=null) + itemFac.CreditAmount = values[0]; + + var itemcod = Selected.promotionDetails.Where(w => w.PermissionID == 4).FirstOrDefault(); + if (itemcod != null) + itemcod.CreditAmount = values[1]; + + var itemcus = Selected.promotionDetails.Where(w => w.PermissionID == 5).FirstOrDefault(); + if (itemcus != null) + itemcus.CreditAmount = values[2]; + + var itemtax = Selected.promotionDetails.Where(w => w.PermissionID == 16).FirstOrDefault(); + if (itemtax != null) + itemtax.CreditAmount = values[3]; + + TotalPrice = Selected.TotalPrice; + } + + + } + public async Task NewOrder() + { + } - public async Task NewOrder() { } } diff --git a/TaxPayerFull/FixedValues.cs b/TaxPayerFull/FixedValues.cs index 5813e5c..d5e3841 100644 --- a/TaxPayerFull/FixedValues.cs +++ b/TaxPayerFull/FixedValues.cs @@ -18,8 +18,8 @@ namespace Front public InvoiceDTO? invoice { get; set; } = null; public DashBoardDTO? dashBoard { get; set; } = null; - private List? Promotions { get; set; } = null; - private List? Pricing { get; set; } = null; + private List Promotions { get; set; } = null; + public Fixedvalues(HttpClientController hc) { _hc = hc; @@ -114,26 +114,41 @@ namespace Front - } - public async Task> LoadPricing() - { - if (Pricing == null) - { - var rsp = await _hc.Get($"Orders/GetAllPricing"); - if (rsp.IsSuccessStatusCode) - Pricing = await rsp.Content.ReadFromJsonAsync>(); - } - return Pricing ?? new List() ; - } public async Task> LoadPromotion() { - if(Promotions==null) - {var rsp = await _hc.Get($"Orders/GetAllPromotion"); + if (Promotions == null) + { + List Pricing = new List(); + var rsp = await _hc.Get($"Orders/GetAllPromotion"); if (rsp.IsSuccessStatusCode) - Promotions = await rsp.Content.ReadFromJsonAsync>(); + { + Promotions = await rsp.Content.ReadFromJsonAsync>() ?? new List(); + + rsp = await _hc.Get($"Orders/GetAllPricing"); + if (rsp.IsSuccessStatusCode) + Pricing = await rsp.Content.ReadFromJsonAsync>() ?? new List(); + + if (Pricing.Count>0) + { + Promotions.Add(new PromotionDto() + { + ID = -1, + Name = "شخصی", + promotionDetails = Pricing.Select(s => new PromotionDetailDto + { + ID = 0, + APrice = s.Price, + CreditAmount = 0, + PermissionID = s.PermissionID, + PermissionTitle = s.PermissionTitle + }).ToList() + }); + } + + } } - return Promotions?? new List(); + return Promotions ?? new List(); } diff --git a/TaxPayerFull/Pages/UserPanel/Orders.razor b/TaxPayerFull/Pages/UserPanel/Orders.razor index 0bacfbb..803ace2 100644 --- a/TaxPayerFull/Pages/UserPanel/Orders.razor +++ b/TaxPayerFull/Pages/UserPanel/Orders.razor @@ -8,7 +8,7 @@ @inject Fixedvalues fv; سفارشات - + @* search *@
diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index ea0270a..670070e 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -37,10 +37,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO() //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") }); //Home -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); +//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") }); //farzan -//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); +builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") }); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");