190 lines
7.3 KiB
Plaintext
190 lines
7.3 KiB
Plaintext
@using Front.Services
|
|
@using Shared.DTOs
|
|
@inject Fixedvalues fv;
|
|
@inject HttpClientController hc;
|
|
<Preload LoadingText="در حال بارگذاری..." />
|
|
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<Dropdown Color="DropdownColor.Secondary">
|
|
<DropdownToggleButton>@orderSelectName</DropdownToggleButton>
|
|
<DropdownMenu>
|
|
@foreach (var i in orderstype)
|
|
{
|
|
<DropdownItem @onclick="()=>OnChange(i.ID,i.Title)">@i.Title</DropdownItem>
|
|
}
|
|
</DropdownMenu>
|
|
</Dropdown>
|
|
</div>
|
|
</div>
|
|
|
|
<hr class="hr" />
|
|
|
|
<table class="table table-sm">
|
|
<thead>
|
|
<tr>
|
|
<th style="width:40%" scope="col">سیستم</th>
|
|
<th style="width:30%" scope="col">قیمت پایه</th>
|
|
<th scope="col">تعداد</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@if (Selected!=null)
|
|
{
|
|
if (Selected.promotionDetails.Any(w => w.PermissionID == 3))
|
|
{
|
|
<tr>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 3).Select(s => s.PermissionTitle).FirstOrDefault()</td>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 3).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال</td>
|
|
<td>
|
|
@if (Selected.ID < 0)
|
|
{
|
|
<InputNumber @bind-Value="values[0]" @bind-Value:after="OnInput" type="text" class="form-control" id="inputfa" style="text-align:center;" placeholder="تعداد" />
|
|
|
|
}
|
|
else
|
|
{
|
|
<input value="@Selected.promotionDetails.Where(w => w.PermissionID == 3).Select(s => s.CreditAmount).FirstOrDefault()" style="text-align:center;" class="form-control" type="text" readonly>
|
|
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
|
|
if (Selected.promotionDetails.Any(w => w.PermissionID == 4))
|
|
{
|
|
<tr>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 4).Select(s => s.PermissionTitle).FirstOrDefault()</td>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 4).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال</td>
|
|
<td>
|
|
@if (Selected.ID < 0)
|
|
{
|
|
<InputNumber @bind-Value="values[1]" @bind-Value:after="OnInput" type="text" class="form-control" id="inputcod" style="text-align:center;" placeholder="تعداد" />
|
|
|
|
}
|
|
else
|
|
{
|
|
<input value="@Selected.promotionDetails.Where(w => w.PermissionID == 4).Select(s => s.CreditAmount).FirstOrDefault()" style="text-align:center;" class="form-control" type="text" readonly>
|
|
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
|
|
|
|
if (Selected.promotionDetails.Any(w => w.PermissionID == 5))
|
|
{
|
|
<tr>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 5).Select(s => s.PermissionTitle).FirstOrDefault()</td>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 5).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال</td>
|
|
<td>
|
|
@if (Selected.ID < 0)
|
|
{
|
|
<InputNumber @bind-Value="values[2]" @bind-Value:after="OnInput" type="text" class="form-control" id="inputcus" style="text-align:center;" placeholder="تعداد" />
|
|
|
|
}
|
|
else
|
|
{
|
|
<input value="@Selected.promotionDetails.Where(w => w.PermissionID == 5).Select(s => s.CreditAmount).FirstOrDefault()" style="text-align:center;" class="form-control" type="text" readonly>
|
|
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
if (Selected.promotionDetails.Any(w => w.PermissionID == 16))
|
|
{
|
|
<tr>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 16).Select(s => s.PermissionTitle).FirstOrDefault()</td>
|
|
<td>@Selected.promotionDetails.Where(w => w.PermissionID == 16).Select(s => s.APrice).FirstOrDefault().ToString("N0") ريال</td>
|
|
<td>
|
|
@if (Selected.ID < 0)
|
|
{
|
|
<InputNumber @bind-Value="values[3]" @bind-Value:after="OnInput" type="text" class="form-control" id="inputax" style="text-align:center;" placeholder="تعداد" />
|
|
}
|
|
else
|
|
{
|
|
<input value="@Selected.promotionDetails.Where(w => w.PermissionID == 16).Select(s => s.CreditAmount).FirstOrDefault()" style="text-align:center;" class="form-control" type="text" readonly>
|
|
|
|
}
|
|
</td>
|
|
</tr>
|
|
}
|
|
|
|
}
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
<span class="text-muted fw-light">قیمت نهایی :</span> @TotalPrice.ToString("N0") ريال
|
|
</div>
|
|
<div class="col-md-4">
|
|
<button type="submit" @onclick="NewOrder" class="btn btn-primary">ثبت</button>
|
|
</div>
|
|
</div>
|
|
@code {
|
|
string orderSelectName = "نوع سفارش";
|
|
int orderSelectID = 0;
|
|
[Inject] protected PreloadService PreloadService { get; set; } = default!;
|
|
[Parameter] public EventCallback<OrderDto> OnMultipleOfThree { get; set; }
|
|
List<IdName<int>> orderstype = new List<IdName<int>>();
|
|
public List<PromotionDto> 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();
|
|
|
|
orderstype.AddRange(Promotions.Select(s => new IdName<int>
|
|
{ ID = s.ID, Title = s.Name }).ToList());
|
|
|
|
await base.OnParametersSetAsync();
|
|
|
|
}
|
|
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()
|
|
{
|
|
|
|
}
|
|
}
|