View COD
This commit is contained in:
182
TaxPayerFull/CUSComponent/CodItem.razor
Normal file
182
TaxPayerFull/CUSComponent/CodItem.razor
Normal file
@@ -0,0 +1,182 @@
|
||||
@using Front.Services
|
||||
@using Shared.DTOs
|
||||
@inject HttpClientController hc;
|
||||
<form>
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||
<Icon Name="@alertIconName" class="me-2"></Icon>
|
||||
@alertMessage
|
||||
</Alert>
|
||||
|
||||
</div>
|
||||
<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>
|
||||
<InputText @bind-Value="Cod.Title" type="text" class="form-control" id="inputTitle" placeholder="نام کالا" />
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label class="col-sm-5 col-form-label" style="color:red" for="inputUnitID">واحد اندازه گیزی</label>
|
||||
<select @bind="Cod.UnitID" class="form-control" aria-label="Default select example" id="inputUnitID">
|
||||
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
|
||||
@if (Unitrequest != null)
|
||||
{
|
||||
foreach (var item in Unitrequest)
|
||||
{
|
||||
<option value="@item.ID">@item.Title</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-5 col-form-label">شناسه مالیاتی کالا</label>
|
||||
<InputText @bind-Value="Cod.TaxID" type="text" class="form-control" id="inputTaxID" placeholder="شناسه مالیاتی کالا" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label style="color:red" class="col-sm-5 col-form-label">% نرخ مالیات کالا</label>
|
||||
<NumberInput @bind-Value="Cod.TaxRate" type="text" class="form-control" id="inputTaxRate" placeholder="نرخ مالیات کالا" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
@if (Cod.ID == 0)
|
||||
{
|
||||
<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 {
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
IconName alertIconName = IconName.CheckCircleFill;
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
[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()
|
||||
{
|
||||
|
||||
result = new ActionInResultComponent()
|
||||
{
|
||||
Status = ComponentStatus.fild
|
||||
};
|
||||
Hidealert = true;
|
||||
alertMessage = "";
|
||||
return base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions {
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Success;
|
||||
alertIconName = IconName.CheckCircleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
private void ShowDangerAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Danger;
|
||||
alertIconName = IconName.ExclamationTriangleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
public async Task OnClickDelete()
|
||||
{
|
||||
|
||||
var rsp = await hc.Delete($"Cod/Delete/{Cod.ID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request)
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.delete;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
ShowDangerAlert("کالا با این شناسه یافت نشد");
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task OnClickUpdate()
|
||||
{
|
||||
if (Cod.UnitID > 0 && Cod.TaxRate > 0 && !string.IsNullOrEmpty(Cod.Title))
|
||||
{
|
||||
|
||||
var rsp = await hc.Put<RCOD>("Cod/Update", Cod);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request)
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.update;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
}
|
||||
else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
||||
}
|
||||
public async Task OnClickAdd()
|
||||
{
|
||||
if (Cod.UnitID > 0 && Cod.TaxRate > 0 && !string.IsNullOrEmpty(Cod.Title))
|
||||
{
|
||||
|
||||
var rsp = await hc.Post<RCOD>("Cod/Add", Cod);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
|
||||
if (request)
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.add;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
}
|
||||
else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
||||
}
|
||||
}
|
@@ -20,7 +20,7 @@
|
||||
</NavLink>
|
||||
</li>
|
||||
<li class="menu-item @cssActionItem[2]" @onclick="() => onClickcssActionItem(2)">
|
||||
<NavLink href="icons-boxicons.html" class="menu-link">
|
||||
<NavLink href="Cod" class="menu-link">
|
||||
<i class="menu-icon tf-icons bx bx-collection"></i>
|
||||
<div>کالا</div>
|
||||
</NavLink>
|
||||
|
213
TaxPayerFull/Pages/UserPanel/COD.razor
Normal file
213
TaxPayerFull/Pages/UserPanel/COD.razor
Normal file
@@ -0,0 +1,213 @@
|
||||
@page "/Cod"
|
||||
@using Front.Services
|
||||
@using Shared.DTOs
|
||||
@using Front.CUSComponent
|
||||
@using Shared.DTOs.Serch
|
||||
@inject HttpClientController hc;
|
||||
<PageTitle>کالا</PageTitle>
|
||||
<Modal @ref="modal" />
|
||||
|
||||
<Preload LoadingText="در حال بارگذاری..." />
|
||||
@* search *@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="card mb-2">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<ul class="list-group fa-padding" style="border: 2px solid #0d6efd">
|
||||
<li class="list-group-item" data-toggle="modal" data-target="#issue">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-1">
|
||||
<input @bind-value="itemsearch.CODID" placeholder="شناسه" style="text-align:center;" class="form-control" type="text" >
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<input @bind-value="itemsearch.Title" placeholder="نام کالا" style="text-align:center;" class="form-control" type="text">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select @bind="itemsearch.UnitID" class="form-control" aria-label="Default select example">
|
||||
<option value="0" style="color: #b5b5b5" selected>واحد اندازه گیری ...</option>
|
||||
@if (Unitrequest!=null)
|
||||
{
|
||||
foreach (var item in Unitrequest)
|
||||
{
|
||||
<option value="@item.ID">@item.Title</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<input @bind-value="itemsearch.ItemTaxID" placeholder="شناسه مالیاتی" style="text-align:center;" class="form-control" type="text">
|
||||
</div>
|
||||
|
||||
<div class="col-auto">
|
||||
<button @onclick="() => LoadCod(1)" type="submit" class="btn btn-primary">جستجو</button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* action *@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="mb-2">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="col-auto">
|
||||
<button type="submit" @onclick="()=>CodItem(0)" class="btn btn-primary">جدید</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@* alert *@
|
||||
<div class="row">
|
||||
<Alert hidden="@Hidealert" Color="@alertColor" Dismissable="false">
|
||||
<Icon Name="@alertIconName" class="me-2"></Icon>
|
||||
@alertMessage
|
||||
</Alert>
|
||||
|
||||
</div>
|
||||
|
||||
@* data *@
|
||||
@if (request != null)
|
||||
{
|
||||
<LTable ModelinComponent="request?.list" OnMultipleOfThree="EventCallback.Factory.Create<int>(this,CodItem)" />
|
||||
@* pagination *@
|
||||
<p style="color:red">@request?.RowCount آیتم یافت شد</p>
|
||||
<nav aria-label="Page navigation">
|
||||
<ul class="pagination justify-content-center">
|
||||
@for (int page = 1; page <= request?.PageCount; page++)
|
||||
{
|
||||
if (page == PageIndex)
|
||||
{
|
||||
<li class="page-item active">
|
||||
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
|
||||
</li>
|
||||
}
|
||||
else
|
||||
{
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="@hc._nav.GetUriWithQueryParameter("PageIndex",page)">@(page)</a>
|
||||
</li>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
</ul>
|
||||
</nav>
|
||||
}
|
||||
|
||||
@layout PanelLayout
|
||||
@code {
|
||||
|
||||
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
||||
ItemSerchGetCOD itemsearch = new ItemSerchGetCOD();
|
||||
[Parameter, SupplyParameterFromQuery]
|
||||
public int? PageIndex { get; set; }
|
||||
public List<IdName<int>>? Unitrequest { get; set; }
|
||||
public Shared.DTOs.PagingDto<RCOD>? request { get; set; }
|
||||
private Modal modal = default!;
|
||||
// alert
|
||||
AlertColor alertColor = AlertColor.Primary;
|
||||
IconName alertIconName = IconName.CheckCircleFill;
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var rsp = await hc.Get("COD/GetUnits");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
Unitrequest = await rsp.Content.ReadFromJsonAsync<List<IdName<int>>>();
|
||||
}
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (PageIndex == null) PageIndex = 1;
|
||||
await LoadCod(PageIndex.Value);
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions {
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Success;
|
||||
alertIconName = IconName.CheckCircleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
private void ShowDangerAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
alertColor = AlertColor.Danger;
|
||||
alertIconName = IconName.ExclamationTriangleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
public async Task LoadCod(int pi)
|
||||
{
|
||||
|
||||
itemsearch.PageSize = 10;
|
||||
itemsearch.PageIndex = pi;
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Post<ItemSerchGetCOD>("COD/GetAll", itemsearch);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
request = await rsp.Content.ReadFromJsonAsync<PagingDto<RCOD>>();
|
||||
}
|
||||
else if(rsp.StatusCode==System.Net.HttpStatusCode.Forbidden)
|
||||
{
|
||||
ShowDangerAlert("شما دسترسی به خواندن اطلاعات کالا را نداربد");
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
PreloadService.Hide();
|
||||
}
|
||||
public async Task CallBackCodItem(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 LoadCod(1);
|
||||
|
||||
await modal.HideAsync();
|
||||
}
|
||||
public async Task CodItem(int ID)
|
||||
{
|
||||
|
||||
var parameters = new Dictionary<string, object>();
|
||||
|
||||
if(ID == 0) parameters.Add("Cod", new RCOD(){ID=0});
|
||||
else parameters.Add("Cod", request.list.Where(w=>w.ID==ID).First().Clone());
|
||||
parameters.Add("Unitrequest", Unitrequest);
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCodItem));
|
||||
await modal.ShowAsync<CodItem>(title: ID == 0 ? "کالا جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -200,7 +200,7 @@
|
||||
else parameters.Add("Cus", request.list.Where(w=>w.ID==ID).First().Clone());
|
||||
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
||||
await modal.ShowAsync<CustomerItem>(title: ID == null ? "مشتری جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
await modal.ShowAsync<CustomerItem>(title: ID == 0 ? "مشتری جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -33,9 +33,9 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
|
||||
}) ;
|
||||
|
||||
|
||||
//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/") });
|
||||
|
||||
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");
|
||||
|
||||
|
Reference in New Issue
Block a user