This commit is contained in:
mmrbnjd
2024-05-16 23:40:32 +03:30
parent 354316abba
commit 3ca7f9deb0
25 changed files with 7727 additions and 101 deletions

View File

@@ -1,5 +1,6 @@
@using Front.Services
@using Shared.DTOs
@using Shared
@inject HttpClientController hc;
<form>
@* alert *@
@@ -12,14 +13,14 @@
</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 class="form-group col-md-2">
<label class="col-sm-4 col-form-label" style="color:red" for="inputTitle">عنوان</label>
<InputText @bind-Value="invoice.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)
<div class="form-group col-md-2">
<label class="col-sm-4 col-form-label" for="inputinvoiceTypeTitle">نوع</label>
<select @bind="invoice.invoiceType" class="form-control" aria-label="Default select example" id="inputinvoiceTypeTitle">
@if (!invoice.invoiceType.HasValue)
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
}
@@ -28,11 +29,42 @@
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
}
@if (Unitrequest != null)
{
foreach (var item in Unitrequest)
@foreach (InvoiceType i in Enum.GetValues(typeof(InvoiceType)))
{
if (Cod.UnitID == item.ID)
if (invoice.invoiceType == i)
{
<option value="@i" selected>@i.GetEnumDisplayName()</option>
}
else
{
<option value="@i">@i.GetEnumDisplayName()</option>
}
}
</select>
</div>
<div class="form-group col-md-2">
<label class="col-sm-8 col-form-label" for="inputPatternID">الگو صورتحساب</label>
<select @bind="invoice.PatternID" class="form-control" aria-label="Default select example" id="inputPatternID">
@if (invoice.PatternID == null || invoice.PatternID ==0)
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
}
else
{
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
}
@if (Patterns != null)
{
foreach (var item in Patterns)
{
if (invoice.PatternID == item.ID)
{
<option value="@item.ID" selected>@item.Title</option>
}
@@ -44,23 +76,79 @@
}
</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>
<div class="form-group col-md-2">
<label class="col-sm-5 col-form-label" style="color:red" for="inputCustomerID">مشتری</label>
<select @bind="invoice.CustomerID" class="form-control" aria-label="Default select example" id="inputCustomerID">
@if (invoice.CustomerID == null || invoice.CustomerID == 0)
{
<option value="0" style="color: #b5b5b5" selected>انتخاب کنید...</option>
}
else
{
<option value="0" style="color: #b5b5b5">انتخاب کنید...</option>
}
@if (Cus != null)
{
foreach (var item in Cus)
{
if (invoice.CustomerID == item.ID)
{
<option value="@item.ID" selected>@item.CustomerName</option>
}
else
{
<option value="@item.ID">@item.CustomerName</option>
}
}
}
</select>
</div>
<div class="form-group col-md-2">
<label class="col-sm-5 col-form-label" for="inputInvoicIssueDate">تاریخ صدور</label>
<InputText style=" text-align: center;" @bind-Value="invoice.InvoicIssueDate" type="text" class="form-control" id="inputInvoicIssueDate" placeholder="تاریخ صدور" />
</div>
<div class="form-group col-md-2">
<label class="col-sm-4 col-form-label" for="inputInvoiceDate">تاریخ</label>
<InputText style=" text-align: center;" @bind-Value="invoice.InvoiceDate" type="text" class="form-control" id="inputInvoiceDate" placeholder="تاریخ" />
</div>
</div>
<br /> <hr class="hr" />
<div class="row g-3">
<Tabs NavStyle="NavStyle.VerticalUnderline">
<Tab Title="آیتم ها" IsActive="true">
<Content>
<p class="ms-3">This is the placeholder content for the <b>Home</b> tab.</p>
</Content>
</Tab>
<Tab Title="پرداختی ها">
<Content>
<p class="ms-3">This is the placeholder content for the <b>Profile</b> tab.</p>
</Content>
</Tab>
</Tabs>
</div>
<hr class="hr" />
<br />
<div class="row g-3">
<div class="form-group col-md-8">
<label class="col-sm-4 col-form-label" for="inputdes">توضیحات</label>
<InputText @bind-Value="invoice.Des" type="text" class="form-control" id="inputdes" placeholder="توضیحات" />
</div>
<div class="form-group col-md-4">
<label class="col-sm-4 col-form-label" for="inputUdate">آخرین ویرایش</label>
<InputText style=" text-align: center;" @bind-Value="invoice.Udate" class="form-control" id="inputUdate" readonly />
</div>
</div>
</form>
@if (Cod.ID == 0)
@if (invoice.ID == 0)
{
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
جدید
@@ -78,11 +166,14 @@ else
@code {
// alert
AlertColor alertColor = AlertColor.Primary;
IconName alertIconName = IconName.CheckCircleFill;
bool Hidealert = true;
string alertMessage = "";
[Parameter] public List<ForCustomerSearch> Cus { get; set; }
[Parameter] public List<IdName<int>> Patterns { get; set; }
[Parameter] public InvoiceDTO invoice { get; set; }
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
// [Parameter] public List<IdName<int>>? Unitrequest { get; set; }
@@ -91,7 +182,6 @@ else
protected override Task OnParametersSetAsync()
{
result = new ActionInResultComponent()
{
Status = ComponentStatus.fild
@@ -119,7 +209,7 @@ else
public async Task OnClickDelete()
{
var rsp = await hc.Delete($"Cod/Delete/{Cod.ID}");
var rsp = await hc.Delete($"Cod/Delete/{invoice.ID}");
if (rsp.IsSuccessStatusCode)
{
var request = await rsp.Content.ReadFromJsonAsync<bool>();
@@ -144,54 +234,58 @@ else
}
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("فیلدهای قرمز باید مقدار دهی شوند");
// 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))
{
// 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>();
// 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
{
// 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("فیلدهای قرمز باید مقدار دهی شوند");
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
// ShowDangerAlert(request[0]);
// }
// }
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
}
public async Task<bool> Validate()
{
return false;
}
}