This commit is contained in:
mmrbnjd
2024-05-23 01:16:59 +03:30
parent 5dac5f70f2
commit 12b89ad630
10 changed files with 229 additions and 38 deletions

View File

@@ -0,0 +1,66 @@
@using Shared.DTOs
<Grid TItem="InvoiceItemDTO"
Class="table table-hover table-bordered table-striped"
DataProvider="DataProvider"
AllowPaging="true"
PageSize="10"
OnRowClick="OnRowClick"
Responsive="true">
<GridColumn TItem="InvoiceItemDTO" HeaderText="شناسه">
@context.ID
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="کد">
@context.CODID
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="کالا">
@context.sstt
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="واحد">
@context.mu
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="تعداد/مقدار">
@context.am
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ واحد">
@context.fee
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="نرخ مالیات">
@context.vra
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ مالیات">
@context.vam
</GridColumn>
<GridColumn TItem="InvoiceItemDTO" HeaderText="تخفیف">
@context.dis
</GridColumn>
@* <GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ بعد از تخفیف">
@context.adis
</GridColumn> *@
<GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ کل">
@context.tsstam
</GridColumn>
</Grid>
@code {
[Inject] ModalService ModalService { get; set; } = default!;
[Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; }
private async Task<GridDataProviderResult<InvoiceItemDTO>> DataProvider(GridDataProviderRequest<InvoiceItemDTO> request)
{
if (InvoiceItems is null) // pull employees only one time for client-side filtering, sorting, and paging
InvoiceItems = GetInvoiceItems(); // call a service or an API to pull the employees
return await Task.FromResult(request.ApplyTo(InvoiceItems));
}
private async Task OnRowClick(GridRowEventArgs<InvoiceItemDTO> args)
{
await ModalService.ShowAsync(new ModalOption { Type = ModalType.Primary, Title = "Event: Row Click", Message = $"Id: {args.Item.ID}, Name: {args.Item.sstt}" });
}
private IEnumerable<InvoiceItemDTO> GetInvoiceItems()
{
return new List<InvoiceItemDTO>();
}
}

View File

@@ -0,0 +1,66 @@
@using Shared.DTOs
<Grid TItem="InvoicePaymentDTO"
Class="table table-hover table-bordered table-striped"
DataProvider="DataProvider"
AllowPaging="true"
PageSize="10"
OnRowClick="OnRowClick"
Responsive="true">
<GridColumn TItem="InvoicePaymentDTO" HeaderText="شناسه">
@context.ID
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="شماره سوییچ">
@context.iinn
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="شماره پذیرنده">
@context.acn
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="شماره پایانه">
@context.trmn
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="روش پرداخت">
@context.pmt
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="شماره پیگیری">
@context.trn
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="شماره کارت پرداخت کننده">
@context.pcn
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="شناسه پرداخت کننده">
@context.pid
</GridColumn>
<GridColumn TItem="InvoicePaymentDTO" HeaderText="تاریخ و زمان پرداخت">
@context.PaymentDateTime
</GridColumn>
@* <GridColumn TItem="InvoiceItemDTO" HeaderText="مبلغ بعد از تخفیف">
@context.adis
</GridColumn> *@
<GridColumn TItem="InvoicePaymentDTO" HeaderText="مبلغ پرداختی">
@context.pv
</GridColumn>
</Grid>
@code {
[Inject] ModalService ModalService { get; set; } = default!;
[Parameter] public IEnumerable<InvoicePaymentDTO> InvoicePays { get; set; }
private async Task<GridDataProviderResult<InvoicePaymentDTO>> DataProvider(GridDataProviderRequest<InvoicePaymentDTO> request)
{
if (InvoicePays is null) // pull employees only one time for client-side filtering, sorting, and paging
InvoicePays = GetInvoicePays(); // call a service or an API to pull the employees
return await Task.FromResult(request.ApplyTo(InvoicePays));
}
private async Task OnRowClick(GridRowEventArgs<InvoicePaymentDTO> args)
{
await ModalService.ShowAsync(new ModalOption { Type = ModalType.Primary, Title = "Event: Row Click", Message = $"Id: {args.Item.ID}, Name: {args.Item.PaymentDateTime}" });
}
private IEnumerable<InvoicePaymentDTO> GetInvoicePays()
{
return new List<InvoicePaymentDTO>();
}
}

View File

@@ -0,0 +1,81 @@
@using System.Reflection
@using System.ComponentModel.DataAnnotations
@using Shared.DTOs
@typeparam T
<div class="row">
<div class="col-md-12">
<div class="mb-4">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="table-responsive text-nowrap">
<table class="table">
<thead class="table-light">
<tr>
@{
PropertyInfo[] properties = typeof(T).GetProperties();
foreach (var item in properties)
{
if (item.GetCustomAttributes(typeof(DisplayAttribute), false).Length > 0)
{
<th>
@item.CustomAttributes.Where(w => w.AttributeType.Name == "DisplayAttribute").Select(s => s.NamedArguments.Where(w => w.MemberName == "Name").Select(ss => ss.TypedValue.Value).First()).First().ToString()
</th>
}
}
<th>عملیات</th>
}
</tr>
</thead>
<tbody class="table-border-bottom-0">
@{
foreach (var item in ModelinComponent)
{
<tr>
@{
properties = item.GetType().GetProperties();
int id = 0;
foreach (PropertyInfo property in properties)
{
if (property.Name.ToLower()=="id")
id =Convert.ToInt32(property.GetValue(item, null));
if (property.CustomAttributes.Any(w => w.AttributeType.Name == "DisplayAttribute"))
{
<td>@property.GetValue(item, null)</td>
}
}
if (id>0)
{
<td><button @onclick="()=>OnMultipleOfThree.InvokeAsync(Convert.ToInt32(id))" type="button" class="btn btn-link">ویرایش</button></td>
}
else
{
<td><button type="button" class="btn btn-link disabled">ویرایش</button></td>
}
}
</tr>
}
}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@code {
[Parameter]
public List<T> ModelinComponent { get; set; } = new List<T>();
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; }
}