This commit is contained in:
mmrbnjd
2024-07-28 15:34:46 +03:30
parent 888b63dcd4
commit 5665b91aa1
7 changed files with 187 additions and 45 deletions

View File

@@ -36,7 +36,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="Service"> <Reference Include="Service">
<HintPath>..\..\Dlls\Service.dll</HintPath> <HintPath>..\..\..\LocalGit\TaxPayerTools\Service\bin\Debug\Service.dll</HintPath>
</Reference> </Reference>
</ItemGroup> </ItemGroup>

View File

@@ -10,6 +10,7 @@ namespace Shared.DTOs
{ {
public int ID { get; set; } public int ID { get; set; }
public string Name { get; set; } public string Name { get; set; }
public decimal TotalPrice { get { return promotionDetails==null ? 0 : promotionDetails.Sum(s => s.TPrice); } }
public ICollection<PromotionDetailDto> promotionDetails { get; set; } public ICollection<PromotionDetailDto> promotionDetails { get; set; }
} }
} }

View File

@@ -6,10 +6,10 @@
<div class="row g-3"> <div class="row">
<div class="col-md-2"> <div class="col-md-6">
<Dropdown Color="DropdownColor.Secondary"> <Dropdown Color="DropdownColor.Secondary">
<DropdownToggleButton>نوع سفارش</DropdownToggleButton> <DropdownToggleButton>@orderSelectName</DropdownToggleButton>
<DropdownMenu> <DropdownMenu>
@foreach (var i in orderstype) @foreach (var i in orderstype)
{ {
@@ -18,46 +18,172 @@
</DropdownMenu> </DropdownMenu>
</Dropdown> </Dropdown>
</div> </div>
<div class="col-md-6"> </div>
<label>@orderSelectName</label> <hr class="hr" />
</div>
</div> <table class="table table-sm">
<div class="row g-3"> <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"> <div class="col-md-4">
<button type="submit" @onclick="NewOrder" class="btn btn-primary">ثبت</button> <button type="submit" @onclick="NewOrder" class="btn btn-primary">ثبت</button>
</div> </div>
</div> </div>
@code { @code {
string orderSelectName = ""; string orderSelectName = "نوع سفارش";
int orderSelectID = 0; int orderSelectID = 0;
[Inject] protected PreloadService PreloadService { get; set; } = default!; [Inject] protected PreloadService PreloadService { get; set; } = default!;
[Parameter] public EventCallback<OrderDto> OnMultipleOfThree { get; set; } [Parameter] public EventCallback<OrderDto> OnMultipleOfThree { get; set; }
List<IdName<int>> orderstype = new List<IdName<int>>() List<IdName<int>> orderstype = new List<IdName<int>>();
{ new IdName<int>() { ID=999,Title="شخصی" },
new IdName<int>() { ID=919,Title="qw" }};
public List<PromotionDto> Promotions { get; set; } = new(); public List<PromotionDto> Promotions { get; set; } = new();
public List<PricingDto> Pricing { get; set; } = new(); public PromotionDto? Selected { get; set; } = null;
// invoice cod cus tax
int[] values = { 0,0,0,0};
decimal TotalPrice = 0;
} }
@functions { @functions {
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
Promotions = await fv.LoadPromotion(); Promotions = await fv.LoadPromotion();
Pricing = await fv.LoadPricing();
orderstype.AddRange(Promotions.Select(s => new IdName<int> orderstype.AddRange(Promotions.Select(s => new IdName<int>
{ { ID = s.ID, Title = s.Name }).ToList());
ID = s.ID,
Title = s.Name
}).ToList());
await base.OnParametersSetAsync(); await base.OnParametersSetAsync();
} }
public async Task OnChange(int ID,string Title) public async Task OnChange(int ID, string Title)
{ {
orderSelectID = ID; orderSelectID = ID;
orderSelectName = Title; 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()
{
} }
public async Task NewOrder() { }
} }

View File

@@ -18,8 +18,8 @@ namespace Front
public InvoiceDTO? invoice { get; set; } = null; public InvoiceDTO? invoice { get; set; } = null;
public DashBoardDTO? dashBoard { get; set; } = null; public DashBoardDTO? dashBoard { get; set; } = null;
private List<PromotionDto>? Promotions { get; set; } = null; private List<PromotionDto> Promotions { get; set; } = null;
private List<PricingDto>? Pricing { get; set; } = null;
public Fixedvalues(HttpClientController hc) public Fixedvalues(HttpClientController hc)
{ {
_hc = hc; _hc = hc;
@@ -114,26 +114,41 @@ namespace Front
}
public async Task<List<PricingDto>> LoadPricing()
{
if (Pricing == null)
{
var rsp = await _hc.Get($"Orders/GetAllPricing");
if (rsp.IsSuccessStatusCode)
Pricing = await rsp.Content.ReadFromJsonAsync<List<PricingDto>>();
}
return Pricing ?? new List<PricingDto>() ;
} }
public async Task<List<PromotionDto>> LoadPromotion() public async Task<List<PromotionDto>> LoadPromotion()
{ {
if(Promotions==null) if (Promotions == null)
{var rsp = await _hc.Get($"Orders/GetAllPromotion"); {
List<PricingDto> Pricing = new List<PricingDto>();
var rsp = await _hc.Get($"Orders/GetAllPromotion");
if (rsp.IsSuccessStatusCode) if (rsp.IsSuccessStatusCode)
Promotions = await rsp.Content.ReadFromJsonAsync<List<PromotionDto>>(); {
Promotions = await rsp.Content.ReadFromJsonAsync<List<PromotionDto>>() ?? new List<PromotionDto>();
rsp = await _hc.Get($"Orders/GetAllPricing");
if (rsp.IsSuccessStatusCode)
Pricing = await rsp.Content.ReadFromJsonAsync<List<PricingDto>>() ?? new List<PricingDto>();
if (Pricing.Count>0)
{
Promotions.Add(new PromotionDto()
{
ID = -1,
Name = "شخصی",
promotionDetails = Pricing.Select(s => new PromotionDetailDto
{
ID = 0,
APrice = s.Price,
CreditAmount = 0,
PermissionID = s.PermissionID,
PermissionTitle = s.PermissionTitle
}).ToList()
});
}
}
} }
return Promotions?? new List<PromotionDto>(); return Promotions ?? new List<PromotionDto>();
} }

View File

@@ -8,7 +8,7 @@
@inject Fixedvalues fv; @inject Fixedvalues fv;
<PageTitle>سفارشات</PageTitle> <PageTitle>سفارشات</PageTitle>
<Modal Size="ModalSize.ExtraLarge" @ref="modal" /> <Modal Size="ModalSize.ExtraLarge" @ref="modal" />
<Modal Size="ModalSize.ExtraLarge" @ref="Newordermodal" /> <Modal Size="ModalSize.Small" @ref="Newordermodal" />
<Preload LoadingText="در حال بارگذاری..." /> <Preload LoadingText="در حال بارگذاری..." />
@* search *@ @* search *@
<div class="row"> <div class="row">

View File

@@ -37,10 +37,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") }); //builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") });
//Home //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 //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"); CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");