cus end
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
<div class="row g-3">
|
||||
<div class="form-group col-md-6">
|
||||
<label class="col-sm-4 col-form-label" style="color:red" for="inputFullName">نام کامل</label>
|
||||
<InputText @bind-Value="Cus.FullName" type="text" class="form-control" id="inputFullName" placeholder="نام کامل"/>
|
||||
</div>
|
||||
<InputText @bind-Value="Cus.FullName" type="text" class="form-control" id="inputFullName" placeholder="نام کامل" />
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label class="col-sm-4 col-form-label" style="color:red" for="inputcustomertype">نوع مشتری</label>
|
||||
<select @bind="ItemSearchCustomertype" class="form-control" aria-label="Default select example" id="inputcustomertype">
|
||||
@@ -26,46 +26,46 @@
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">تلفن</label>
|
||||
<InputText @bind-Value="Cus.Phone" type="text" class="form-control" id="inputPhone" placeholder="تلفن"/>
|
||||
<InputText @bind-Value="Cus.Phone" type="text" class="form-control" id="inputPhone" placeholder="تلفن" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">آدرس</label>
|
||||
<InputText @bind-Value="Cus.Address" type="text" class="form-control" id="inputAddress" placeholder="آدرس"/>
|
||||
<InputText @bind-Value="Cus.Address" type="text" class="form-control" id="inputAddress" placeholder="آدرس" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">پست الکترونیک</label>
|
||||
<InputText @bind-Value="Cus.Email" type="email" class="form-control" id="inputEmail" placeholder="پست الکترونیک"/>
|
||||
<InputText @bind-Value="Cus.Email" type="email" class="form-control" id="inputEmail" placeholder="پست الکترونیک" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">کد پستی</label>
|
||||
<InputText @bind-Value="Cus.ZipCode" type="text" class="form-control" id="inputZipCode" placeholder="کد پستی"/>
|
||||
<InputText @bind-Value="Cus.ZipCode" type="text" class="form-control" id="inputZipCode" placeholder="کد پستی" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">کد اقتصادی</label>
|
||||
<InputText @bind-Value="Cus.EconomicCode" type="text" class="form-control" id="inputEconomicCode" placeholder="کد اقتصادی"/>
|
||||
<InputText @bind-Value="Cus.EconomicCode" type="text" class="form-control" id="inputEconomicCode" placeholder="کد اقتصادی" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">کد ملی</label>
|
||||
<InputText @bind-Value="Cus.MeliCode" type="text" class="form-control" id="inputMeliCode" placeholder="کدملی"/>
|
||||
<InputText @bind-Value="Cus.MeliCode" type="text" class="form-control" id="inputMeliCode" placeholder="کدملی" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">کد شعبه</label>
|
||||
<InputText @bind-Value="Cus.BranchID" type="text" class="form-control" id="inputBranchID" placeholder="کد شعبه"/>
|
||||
<InputText @bind-Value="Cus.BranchID" type="text" class="form-control" id="inputBranchID" placeholder="کد شعبه" />
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="col-sm-4 col-form-label">شماره گذرنامه</label>
|
||||
<InputText @bind-Value="Cus.PassportNumber" type="text" class="form-control" id="inputPassportNumber" placeholder="شماره گذرنامه"/>
|
||||
<InputText @bind-Value="Cus.PassportNumber" type="text" class="form-control" id="inputPassportNumber" placeholder="شماره گذرنامه" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -74,14 +74,14 @@
|
||||
<label class="col-sm-4 col-form-label">توضیحات</label>
|
||||
<InputTextArea @bind-Value="Cus.Info" class="form-control" id="inputMeliInfo" placeholder="توضیحات" rows="3"></InputTextArea>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
@if (Cus.ID==-1)
|
||||
@if (Cus.ID == 0)
|
||||
{
|
||||
<Button class="mt-3" Color="ButtonColor.Success" @onclick="OnClickAdd" Type="ButtonType.Button">
|
||||
جدید
|
||||
@@ -93,7 +93,7 @@ else
|
||||
ثبت تغییرات
|
||||
</Button>
|
||||
<Button class="mt-3" Color="ButtonColor.Danger" @onclick="OnClickDelete" Type="ButtonType.Button">
|
||||
حذف
|
||||
حذف
|
||||
</Button>
|
||||
}
|
||||
|
||||
@@ -111,11 +111,19 @@ else
|
||||
public ActionInResultComponent result { get; set; }
|
||||
protected override Task OnParametersSetAsync()
|
||||
{
|
||||
result = new ActionInResultComponent();
|
||||
if (Cus.CustomerType != null)
|
||||
ItemSearchCustomertype = (int)Cus.CustomerType;
|
||||
|
||||
result = new ActionInResultComponent()
|
||||
{
|
||||
Status = ComponentStatus.fild
|
||||
};
|
||||
Hidealert = true;
|
||||
alertMessage = "";
|
||||
return base.OnParametersSetAsync();
|
||||
}
|
||||
}
|
||||
@functions{
|
||||
@functions {
|
||||
private void ShowSuccessAlert(string msg)
|
||||
{
|
||||
Hidealert = false;
|
||||
@@ -130,38 +138,88 @@ else
|
||||
alertIconName = IconName.ExclamationTriangleFill;
|
||||
alertMessage = msg;
|
||||
}
|
||||
public async Task OnClickDelete(){
|
||||
result.Action = ComponentAction.delete;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
public async Task OnClickUpdate()
|
||||
public async Task OnClickDelete()
|
||||
{
|
||||
result.Action = ComponentAction.update;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
public async Task OnClickAdd()
|
||||
{
|
||||
if (ItemSearchCustomertype > 0)
|
||||
Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
||||
Cus.ID = null;
|
||||
|
||||
|
||||
var rsp = await hc.Post<RCustomer>("Customer/Add", Cus);
|
||||
var rsp = await hc.Delete($"Customer/Delete/{Cus.ID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request)
|
||||
{
|
||||
result.Action = ComponentAction.add;
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.delete;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
else
|
||||
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
ShowDangerAlert("مشتری با این شناسه یافت نشد");
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public async Task OnClickUpdate()
|
||||
{
|
||||
if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
||||
{
|
||||
if (ItemSearchCustomertype > 0)
|
||||
Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
||||
|
||||
var rsp = await hc.Put<RCustomer>("Customer/Update", Cus);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request)
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.update;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
}
|
||||
else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
||||
}
|
||||
public async Task OnClickAdd()
|
||||
{
|
||||
if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
||||
{
|
||||
if (ItemSearchCustomertype > 0)
|
||||
Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
||||
Cus.ID = null;
|
||||
|
||||
|
||||
var rsp = await hc.Post<RCustomer>("Customer/Add", Cus);
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
|
||||
if (request)
|
||||
{
|
||||
result.Status = ComponentStatus.success;
|
||||
result.Action = ComponentAction.add;
|
||||
await OnMultipleOfThree.InvokeAsync(result);
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
}
|
||||
else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
||||
}
|
||||
}
|
@@ -23,8 +23,9 @@
|
||||
@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>
|
||||
@@ -32,20 +33,34 @@
|
||||
@{
|
||||
foreach (var item in ModelinComponent)
|
||||
{
|
||||
<tr>
|
||||
<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>
|
||||
@@ -62,5 +77,5 @@
|
||||
@code {
|
||||
[Parameter]
|
||||
public List<T> ModelinComponent { get; set; } = new List<T>();
|
||||
|
||||
[Parameter] public EventCallback<int> OnMultipleOfThree { get; set; }
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="col-auto">
|
||||
<button type="submit" @onclick="()=>CustomerItem(null)" class="btn btn-primary">جدید</button>
|
||||
<button type="submit" @onclick="()=>CustomerItem(0)" class="btn btn-primary">جدید</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -77,7 +77,7 @@
|
||||
@* data *@
|
||||
@if (request != null)
|
||||
{
|
||||
<LTable ModelinComponent="request?.list" />
|
||||
<LTable ModelinComponent="request?.list" OnMultipleOfThree="EventCallback.Factory.Create<int>(this,CustomerItem)" />
|
||||
@* pagination *@
|
||||
<p style="color:red">@request?.RowCount آیتم یافت شد</p>
|
||||
<nav aria-label="Page navigation">
|
||||
@@ -172,10 +172,10 @@
|
||||
if (result.Action == ComponentAction.add)
|
||||
{
|
||||
if (result.Status==ComponentStatus.success)
|
||||
ShowSuccessAlert("مشتری جدید با موفقیت اضافه شد");
|
||||
|
||||
ShowSuccessAlert("مشتری جدید با موفقیت اضافه شد");
|
||||
|
||||
}
|
||||
else if (result.Action == ComponentAction.update)
|
||||
else if (result.Action == ComponentAction.update)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("اطلاعات مشتری با موفقیت ویرایش شد");
|
||||
@@ -183,23 +183,25 @@
|
||||
else if (result.Action == ComponentAction.delete)
|
||||
{
|
||||
if (result.Status == ComponentStatus.success)
|
||||
ShowSuccessAlert("مشتری با موفقیت حذف شد");
|
||||
ShowSuccessAlert("مشتری با موفقیت حذف شد");
|
||||
}
|
||||
|
||||
if (result.Status == ComponentStatus.success)
|
||||
await LoadCus(1);
|
||||
await LoadCus(1);
|
||||
|
||||
await modal.HideAsync();
|
||||
}
|
||||
public async Task CustomerItem(int? ID)
|
||||
public async Task CustomerItem(int ID)
|
||||
{
|
||||
|
||||
var parameters = new Dictionary<string, object>();
|
||||
|
||||
if(ID == null) parameters.Add("Cus", new RCustomer(){ID=-1});
|
||||
else parameters.Add("Cus", request.list.Where(w=>w.ID==ID));
|
||||
if(ID == 0) parameters.Add("Cus", new RCustomer(){ID=0});
|
||||
else parameters.Add("Cus", request.list.Where(w=>w.ID==ID).First().Clone());
|
||||
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
|
||||
await modal.ShowAsync<CustomerItem>(title: ID == null ? "مشتری جدید" : "ویرایش اطلاعات", parameters: parameters);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
12
TaxPayerFull/Services/ExMethod.cs
Normal file
12
TaxPayerFull/Services/ExMethod.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
namespace Front.Services
|
||||
{
|
||||
public static class ExMethod
|
||||
{
|
||||
public static T Clone<T>(this T obj)
|
||||
{
|
||||
var inst = obj.GetType().GetMethod("MemberwiseClone", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
|
||||
|
||||
return (T)inst?.Invoke(obj, null);
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,6 +24,13 @@ namespace Front.Services
|
||||
_nav.NavigateTo("/Sign-in/unon");
|
||||
return request;
|
||||
}
|
||||
public async Task<HttpResponseMessage> Delete(string route)
|
||||
{
|
||||
var request = await _hc.DeleteAsync(route);
|
||||
if (request.StatusCode == System.Net.HttpStatusCode.Unauthorized)
|
||||
_nav.NavigateTo("/Sign-in/unon");
|
||||
return request;
|
||||
}
|
||||
public async Task<HttpResponseMessage> Post<T>(string route,T mode)
|
||||
{
|
||||
var request = await _hc.PostAsJsonAsync(route,mode);
|
||||
|
@@ -9,6 +9,7 @@ namespace Front.Services
|
||||
{
|
||||
_user = user;
|
||||
}
|
||||
|
||||
public async Task<bool> OnlineUser()
|
||||
{
|
||||
if (_user != null && !string.IsNullOrEmpty(_user.Token) && _user.exitDate.AddMinutes(-5) > DateTime.Now)
|
||||
|
Reference in New Issue
Block a user