From 5ba30cf9709d49fc451c97f0d040433ec37759fd Mon Sep 17 00:00:00 2001 From: mmrbnjd Date: Mon, 9 Sep 2024 17:11:28 +0330 Subject: [PATCH] ... --- Back/Controllers/InvoicePaymentController.cs | 20 ++--- TaxPayerFull/CUSComponent/InvoicePays.razor | 93 ++++++++++++-------- TaxPayerFull/Program.cs | 4 +- 3 files changed, 70 insertions(+), 47 deletions(-) diff --git a/Back/Controllers/InvoicePaymentController.cs b/Back/Controllers/InvoicePaymentController.cs index 9a19099..c24339b 100644 --- a/Back/Controllers/InvoicePaymentController.cs +++ b/Back/Controllers/InvoicePaymentController.cs @@ -83,14 +83,14 @@ namespace Back.Controllers { ID = item.ID, acn = item.acn, - iinn = item.acn, - pcn = item.acn, + iinn = item.iinn, + pcn = item.pcn, PaymentDateTime = item.PaymentDateTime.ShamciToFormatShamci(), pid = item.pid, pmt = item.pmt, pv = item.pv, trmn = item.trmn, - trn = item.acn, + trn = item.trn, paymentMethod = item.pmt.HasValue ? codings.Where(w => w.Code == item.pmt.Value.ToString()).Select(s => s.Title).FirstOrDefault() : null, } :null); } @@ -159,14 +159,14 @@ namespace Back.Controllers { ID = modelout.ID, acn = modelout.acn, - iinn = modelout.acn, - pcn = modelout.acn, + iinn = modelout.iinn, + pcn = modelout.pcn, PaymentDateTime = modelout.PaymentDateTime.ShamciToFormatShamci(), pid = modelout.pid, pmt = modelout.pmt, pv = modelout.pv, trmn = modelout.trmn, - trn = modelout.acn, + trn = modelout.trn, paymentMethod = modelout.pmt.HasValue ? codings.Where(w => w.Code == modelout.pmt.Value.ToString()).Select(s => s.Title).FirstOrDefault() : null, } : null); } @@ -191,10 +191,10 @@ namespace Back.Controllers if (payitem == null) return NotFound(new List { "invoice pay notFound..." }); - ////-----Validaton - var resultValidationmodel = await _validation.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, payitem.InvoiceID, new InvoicePaymentDTO(), eActionValidation.delete)); - if (!resultValidationmodel.IsValid) - return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); + //////-----Validaton + //var resultValidationmodel = await _validation.ValidateAsync(Tuple.Create(user.RolUsers.First().CompanyID, payitem.InvoiceID, new InvoicePaymentDTO(), eActionValidation.delete)); + //if (!resultValidationmodel.IsValid) + // return BadRequest(resultValidationmodel.Errors.Select(s => s.ErrorMessage).ToList()); diff --git a/TaxPayerFull/CUSComponent/InvoicePays.razor b/TaxPayerFull/CUSComponent/InvoicePays.razor index bf2fe6e..3710fdf 100644 --- a/TaxPayerFull/CUSComponent/InvoicePays.razor +++ b/TaxPayerFull/CUSComponent/InvoicePays.razor @@ -3,8 +3,9 @@ @using Shared.DTOs @inject Fixedvalues fv; @inject HttpClientController hc; - + +
-
+ + @if (add) { -
+
+
-
+
+
} else - { -
- -
-
- -
-
+ -
+
+ } - - @code { + private ConfirmDialog dialog = default!; bool add = true; [Parameter] public InvoiceDTO invoice { get; set; } Grid grid = default!; @@ -193,17 +196,19 @@ @functions { private async Task OnRowClick(GridRowEventArgs args) { + Hidealert = true; item = args.Item; add = false; } async Task cancell() { + Hidealert = true; add = true; item = new InvoicePaymentDTO(); } async Task AddPay() { - + Hidealert = true; if (await Validation()) { var sentItem = new InvoiceItemAction() @@ -221,6 +226,7 @@ invoice.payments.Add(request); await grid.RefreshDataAsync(); item = new InvoicePaymentDTO(); + ShowSuccessAlert("پرداخت ثبت شد"); } else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); @@ -238,6 +244,7 @@ } async Task UpdatePay() { + Hidealert = true; if (await Validation()) { var rsp = await hc.Put>("InvoicePayment/UpdatePay", new InvoiceItemAction() @@ -251,9 +258,12 @@ if (request != null && request.ID.HasValue) { + invoice.payments.Remove(item); invoice.payments.Add(request); await grid.RefreshDataAsync(); item = new InvoicePaymentDTO(); + add = true; + ShowSuccessAlert("تغییرات با موفقیت اعمال شد"); } else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); @@ -268,29 +278,41 @@ } async Task DeletePay() { - if (item.ID.HasValue) + var confirmation = await dialog.ShowAsync( + title: "عملیات حذف پرداخت", + message1: $"از حذف پرداخت", + message2: "اطمینان دارید?"); + + if (confirmation) { - var rsp = await hc.Delete($"InvoicePayment/DeletePay/{item.ID.Value}"); - if (rsp.IsSuccessStatusCode) + Hidealert = true; + if (item.ID.HasValue) { - var request = await rsp.Content.ReadFromJsonAsync(); - - if (request) + var rsp = await hc.Delete($"InvoicePayment/DeletePay/{item.ID.Value}"); + if (rsp.IsSuccessStatusCode) { - invoice.payments.Add(item); - await grid.RefreshDataAsync(); - item = new InvoicePaymentDTO(); + var request = await rsp.Content.ReadFromJsonAsync(); + + if (request) + { + invoice.payments.Remove(item); + await grid.RefreshDataAsync(); + item = new InvoicePaymentDTO(); + add = true; + ShowSuccessAlert("پرداخت خذف شد"); + } + + else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); } + else + { - else ShowDangerAlert("خطایی در اجرای عملیات رخ داده"); - } - else - { - - var request = await rsp.Content.ReadFromJsonAsync>(); - ShowDangerAlert(request[0]); + var request = await rsp.Content.ReadFromJsonAsync>(); + ShowDangerAlert(request[0]); + } } } + } private void ShowSuccessAlert(string msg) { @@ -308,9 +330,10 @@ } async Task Validation() { - if (item.pv<=0) + if (item.pv==null || item.pv <= 0) { - ShowDangerAlert("مبلغ پرداختی باید بیشتر از صفر باشد."); + ShowDangerAlert("مبلغ پرداختی باید بیشتر از صفر باشد."); + return false; } if (invoice.tbill < invoice.payments.Sum(s => s.pv) + item.pv) { @@ -341,7 +364,7 @@ } else { - ShowDangerAlert("تاریخ پرداخت نمی تواند از امروز جلوتر باشد"); + ShowDangerAlert("تاریخ پرداخت نمی تواند از امروز جلوتر باشد"); return false; } diff --git a/TaxPayerFull/Program.cs b/TaxPayerFull/Program.cs index 9180e1b..b3c5965 100644 --- a/TaxPayerFull/Program.cs +++ b/TaxPayerFull/Program.cs @@ -36,10 +36,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");