...
This commit is contained in:
197
TaxPayerFull/CUSComponent/InvoiceItem.razor
Normal file
197
TaxPayerFull/CUSComponent/InvoiceItem.razor
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
@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">
|
||||||
|
@if (Cod.UnitID > 0)
|
||||||
|
{
|
||||||
|
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (Unitrequest != null)
|
||||||
|
{
|
||||||
|
foreach (var item in Unitrequest)
|
||||||
|
{
|
||||||
|
if (Cod.UnitID == item.ID)
|
||||||
|
{
|
||||||
|
<option value="@item.ID" selected>@item.Title</option>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<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 InvoiceDTO invoice { 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("فیلدهای قرمز باید مقدار دهی شوند");
|
||||||
|
}
|
||||||
|
}
|
@@ -6,7 +6,7 @@
|
|||||||
@using Shared.DTOs.Serch
|
@using Shared.DTOs.Serch
|
||||||
@inject HttpClientController hc;
|
@inject HttpClientController hc;
|
||||||
<PageTitle>صورتحساب</PageTitle>
|
<PageTitle>صورتحساب</PageTitle>
|
||||||
<Modal @ref="modal" />
|
<Modal Size="ModalSize.ExtraLarge" @ref="modal" />
|
||||||
|
|
||||||
<Preload LoadingText="در حال بارگذاری..." />
|
<Preload LoadingText="در حال بارگذاری..." />
|
||||||
@* search *@
|
@* search *@
|
||||||
@@ -210,14 +210,13 @@
|
|||||||
}
|
}
|
||||||
public async Task InvoiceItem(int ID)
|
public async Task InvoiceItem(int ID)
|
||||||
{
|
{
|
||||||
|
|
||||||
var parameters = new Dictionary<string, object>();
|
var parameters = new Dictionary<string, object>();
|
||||||
|
|
||||||
if (ID == 0) parameters.Add("Invoice", new InvoiceDTO() { ID = 0 });
|
if (ID == 0) parameters.Add("Invoice", new InvoiceDTO() { ID = 0 });
|
||||||
else parameters.Add("Invoice", request.list.Where(w => w.ID == ID).First().Clone());
|
else parameters.Add("invoice", request.list.Where(w => w.ID == ID).First().Clone());
|
||||||
|
|
||||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
||||||
await modal.ShowAsync<CustomerItem>(title: ID == 0 ? "صورتحساب جدید" : "ویرایش اطلاعات", parameters: parameters);
|
await modal.ShowAsync<InvoiceItem>(title: ID == 0 ? "صورتحساب جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -235,9 +234,5 @@
|
|||||||
private void OnAutoCompleteChanged(ForCustomerSearch customer)
|
private void OnAutoCompleteChanged(ForCustomerSearch customer)
|
||||||
{
|
{
|
||||||
itemsearch.CustomerID = customer?.ID;
|
itemsearch.CustomerID = customer?.ID;
|
||||||
// // TODO: handle your own logic
|
|
||||||
|
|
||||||
// // NOTE: do null check
|
|
||||||
// Console.WriteLine($"'{customer?.Name}' selected.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user