...
This commit is contained in:
81
TaxPayerFull/Layout/LTable.razor
Normal file
81
TaxPayerFull/Layout/LTable.razor
Normal 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; }
|
||||
}
|
Reference in New Issue
Block a user