2024-05-05 18:15:37 +03:30
|
|
|
@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>
|
|
|
|
}
|
2024-05-08 17:25:02 +03:30
|
|
|
|
2024-05-05 18:15:37 +03:30
|
|
|
}
|
2024-05-08 17:25:02 +03:30
|
|
|
<th>عملیات</th>
|
2024-05-05 18:15:37 +03:30
|
|
|
}
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody class="table-border-bottom-0">
|
|
|
|
@{
|
|
|
|
foreach (var item in ModelinComponent)
|
|
|
|
{
|
2024-05-08 17:25:02 +03:30
|
|
|
<tr>
|
2024-05-05 18:15:37 +03:30
|
|
|
@{
|
|
|
|
properties = item.GetType().GetProperties();
|
2024-05-08 17:25:02 +03:30
|
|
|
int id = 0;
|
2024-05-05 18:15:37 +03:30
|
|
|
foreach (PropertyInfo property in properties)
|
|
|
|
{
|
2024-05-08 17:25:02 +03:30
|
|
|
if (property.Name.ToLower()=="id")
|
|
|
|
id =Convert.ToInt32(property.GetValue(item, null));
|
|
|
|
|
2024-05-05 18:15:37 +03:30
|
|
|
if (property.CustomAttributes.Any(w => w.AttributeType.Name == "DisplayAttribute"))
|
|
|
|
{
|
2024-05-28 15:03:08 +03:30
|
|
|
if (property.PropertyType == typeof(Nullable<System.Decimal>) || property.PropertyType == typeof(System.Decimal))
|
|
|
|
{
|
|
|
|
<td>
|
|
|
|
@decimal.Parse(property.GetValue(item, null).ToString()).ToString("N0") ريال
|
|
|
|
</td>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<td>@property.GetValue(item, null)</td>
|
|
|
|
}
|
|
|
|
|
2024-05-05 18:15:37 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-05-08 17:25:02 +03:30
|
|
|
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>
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-05-05 18:15:37 +03:30
|
|
|
</tr>
|
|
|
|
}
|
2024-05-08 17:25:02 +03:30
|
|
|
|
2024-05-05 18:15:37 +03:30
|
|
|
}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
@code {
|
|
|
|
[Parameter]
|
|
|
|
public List<T> ModelinComponent { get; set; } = new List<T>();
|
2024-05-08 17:25:02 +03:30
|
|
|
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; }
|
2024-05-05 18:15:37 +03:30
|
|
|
}
|