...
This commit is contained in:
@@ -55,8 +55,8 @@ namespace Back.Controllers
|
|||||||
item.InvoicIssueDate = DateTime.Now.ConvertMiladiToShamsi();
|
item.InvoicIssueDate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
|
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
//if (!ModelState.IsValid)
|
||||||
return BadRequest(item);
|
// return BadRequest(item);
|
||||||
|
|
||||||
//-----GetUserAndCompany
|
//-----GetUserAndCompany
|
||||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
|
@@ -27,7 +27,7 @@ namespace Back.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
[HttpPost("AddItem/{invoiceID}")]
|
[HttpPost("AddItem/{invoiceID}")]
|
||||||
public async Task<ActionResult> AddItem([FromRoute] int invoiceID, [FromBody] InvoiceItemDTO model)
|
public async Task<ActionResult<bool>> AddItem([FromRoute] int invoiceID, [FromBody] InvoiceItemDTO model)
|
||||||
{
|
{
|
||||||
//-----GetUserAndCompany
|
//-----GetUserAndCompany
|
||||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
@@ -64,7 +64,7 @@ namespace Back.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
[HttpPut("UpdateItem/{invoiceID}")]
|
[HttpPut("UpdateItem/{invoiceID}")]
|
||||||
public async Task<ActionResult> UpdateItem([FromRoute] int invoiceID, [FromBody] InvoiceItemDTO model)
|
public async Task<ActionResult<bool>> UpdateItem([FromRoute] int invoiceID, [FromBody] InvoiceItemDTO model)
|
||||||
{
|
{
|
||||||
//-----GetUserAndCompany
|
//-----GetUserAndCompany
|
||||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
@@ -109,7 +109,7 @@ namespace Back.Controllers
|
|||||||
|
|
||||||
}
|
}
|
||||||
[HttpDelete("DeleteItem/{invoiceID}/{invoiceItemID}")]
|
[HttpDelete("DeleteItem/{invoiceID}/{invoiceItemID}")]
|
||||||
public async Task<ActionResult> DeleteItem([FromRoute] int invoiceID, [FromRoute] int invoiceItemID)
|
public async Task<ActionResult<bool>> DeleteItem([FromRoute] int invoiceID, [FromRoute] int invoiceItemID)
|
||||||
{
|
{
|
||||||
//-----GetUserAndCompany
|
//-----GetUserAndCompany
|
||||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||||
@@ -124,12 +124,12 @@ namespace Back.Controllers
|
|||||||
//-----Get invoice
|
//-----Get invoice
|
||||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, invoiceID);
|
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, invoiceID);
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return BadRequest(new List<string> { "invoice notFound..." });
|
return NotFound(new List<string> { "invoice notFound..." });
|
||||||
|
|
||||||
|
|
||||||
var invoiceitem = await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, invoiceID, model.ID.Value);
|
var invoiceitem = await _servInvoiceItem.Getinvoiceitem(user.RolUsers.First().CompanyID, invoiceID, invoiceItemID);
|
||||||
if (invoiceitem == null)
|
if (invoiceitem == null)
|
||||||
return BadRequest(new List<string> { "invoice Item notFound..." });
|
return NotFound(new List<string> { "invoice Item notFound..." });
|
||||||
|
|
||||||
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
invoice.LastChangeUserID = Convert.ToInt32(UserID);
|
||||||
|
|
||||||
|
@@ -129,7 +129,7 @@ namespace Back.Services
|
|||||||
return await _invoiceRepo.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
|
return await _invoiceRepo.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task<bool> AddInvoice(Invoice invoice, bool calculate = true)
|
public async Task<int> AddInvoice(Invoice invoice, bool calculate = true)
|
||||||
{
|
{
|
||||||
invoice.Cdate = DateTime.Now.ConvertMiladiToShamsi();
|
invoice.Cdate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
invoice.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
invoice.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
||||||
@@ -137,12 +137,17 @@ namespace Back.Services
|
|||||||
if (calculate)
|
if (calculate)
|
||||||
{
|
{
|
||||||
if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
|
if (await _checkPermission.ExtensionofAccess(invoice.CompanyID.Value, 3, "-1"))
|
||||||
return await _invoiceRepo.AddBoolResultAsync(invoice);
|
{
|
||||||
return false;
|
var item= await _invoiceRepo.AddAsync(invoice);
|
||||||
|
return item.ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return await _invoiceRepo.AddBoolResultAsync(invoice);
|
var item = await _invoiceRepo.AddAsync(invoice);
|
||||||
|
return item.ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -24,6 +24,11 @@ namespace Shared
|
|||||||
PersianCal.GetDayOfMonth(date).ToString("00")
|
PersianCal.GetDayOfMonth(date).ToString("00")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
public static DateTime ToMiladiinFront(this string value)
|
||||||
|
{
|
||||||
|
PersianCalendar p = new PersianCalendar();
|
||||||
|
return p.ToDateTime(Convert.ToInt32(value.Substring(0, 4)), Convert.ToInt32(value.Substring(4, 2)), Convert.ToInt32(value.Substring(6, 2)), DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond);
|
||||||
|
}
|
||||||
public static string GetEnumDisplayName(this Enum enumType)
|
public static string GetEnumDisplayName(this Enum enumType)
|
||||||
{
|
{
|
||||||
return enumType.GetType().GetMember(enumType.ToString())
|
return enumType.GetType().GetMember(enumType.ToString())
|
||||||
|
@@ -69,7 +69,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
|
<label class="col-sm-8 col-form-label">مبلغ بعد تخفیف</label>
|
||||||
<InputNumber @bind-Value="itemDTO.adis" type="text" class="form-control" id="inputadis" placeholder="مبلغ تخفیف" readonly />
|
<InputNumber @bind-Value="itemDTO.adis" type="text" class="form-control" id="inputadis" placeholder="مبلغ تخفیف" readonly />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label class="col-sm-6 col-form-label">مبلغ نهایی</label>
|
<label class="col-sm-6 col-form-label">مبلغ نهایی</label>
|
||||||
<InputNumber @bind-Value="itemDTO.tsstam" type="text" class="form-control" id="inputvra" placeholder="مبلغ مالیات" readonly />
|
<InputNumber @bind-Value="itemDTO.tsstam" type="text" class="form-control" id="inputvra" placeholder="مبلغ نهایی" readonly />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@@ -113,6 +113,7 @@ else
|
|||||||
bool Hidealert = true;
|
bool Hidealert = true;
|
||||||
string alertMessage = "";
|
string alertMessage = "";
|
||||||
public int Tax { get; set; } = 0;
|
public int Tax { get; set; } = 0;
|
||||||
|
[Parameter] public int InvoiceID { get; set; }
|
||||||
[Parameter] public InvoiceItemDTO itemDTO { get; set; }
|
[Parameter] public InvoiceItemDTO itemDTO { get; set; }
|
||||||
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
||||||
public List<CODIdName<int>> cods { get; set; } = new();
|
public List<CODIdName<int>> cods { get; set; } = new();
|
||||||
@@ -135,6 +136,21 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
@functions {
|
@functions {
|
||||||
|
private void ShowSuccessAlert(string msg)
|
||||||
|
{
|
||||||
|
Hidealert = false;
|
||||||
|
alertColor = AlertColor.Success;
|
||||||
|
alertIconName = IconName.CheckCircleFill;
|
||||||
|
alertMessage = msg;
|
||||||
|
}
|
||||||
|
private void ShowDangerAlert(string msg)
|
||||||
|
{
|
||||||
|
Hidealert = false;
|
||||||
|
alertColor = AlertColor.Danger;
|
||||||
|
alertIconName = IconName.ExclamationTriangleFill;
|
||||||
|
alertMessage = msg;
|
||||||
|
}
|
||||||
|
//-----------------------
|
||||||
private async Task prdisAsync()
|
private async Task prdisAsync()
|
||||||
{
|
{
|
||||||
if (itemDTO.ID == null)
|
if (itemDTO.ID == null)
|
||||||
@@ -143,7 +159,7 @@ else
|
|||||||
private async Task adisAsync()
|
private async Task adisAsync()
|
||||||
{
|
{
|
||||||
if (itemDTO.ID == null)
|
if (itemDTO.ID == null)
|
||||||
itemDTO.adis= itemDTO.prdis - itemDTO.dis;
|
itemDTO.adis = itemDTO.prdis - itemDTO.dis;
|
||||||
|
|
||||||
// await AftervamAsync();
|
// await AftervamAsync();
|
||||||
}
|
}
|
||||||
@@ -155,7 +171,7 @@ else
|
|||||||
private async Task tsstamAsync()
|
private async Task tsstamAsync()
|
||||||
{
|
{
|
||||||
if (itemDTO.ID == null)
|
if (itemDTO.ID == null)
|
||||||
itemDTO.tsstam = itemDTO.vam + itemDTO.adis ;
|
itemDTO.tsstam = itemDTO.vam + itemDTO.adis;
|
||||||
}
|
}
|
||||||
private async Task AfterAsync()
|
private async Task AfterAsync()
|
||||||
{
|
{
|
||||||
@@ -164,27 +180,28 @@ else
|
|||||||
await vamAsync();
|
await vamAsync();
|
||||||
await tsstamAsync();
|
await tsstamAsync();
|
||||||
}
|
}
|
||||||
|
//-----------------------
|
||||||
public async Task OnClickDelete()
|
public async Task OnClickDelete()
|
||||||
{
|
{
|
||||||
|
|
||||||
// var rsp = await hc.Delete($"Customer/Delete/{Cus.ID}");
|
var rsp = await hc.Delete($"InvoiceItem/DeleteItem/{InvoiceID}/{itemDTO.ID}");
|
||||||
// if (rsp.IsSuccessStatusCode)
|
if (rsp.IsSuccessStatusCode)
|
||||||
// {
|
{
|
||||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||||
// if (request)
|
if (request)
|
||||||
// {
|
{
|
||||||
// result.Status = ComponentStatus.success;
|
result.Status = ComponentStatus.success;
|
||||||
// result.Action = ComponentAction.delete;
|
result.Action = ComponentAction.delete;
|
||||||
// await OnMultipleOfThree.InvokeAsync(result);
|
await OnMultipleOfThree.InvokeAsync(result);
|
||||||
// }
|
}
|
||||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||||
// }
|
}
|
||||||
|
|
||||||
// else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
else
|
||||||
// {
|
{
|
||||||
// ShowDangerAlert("مشتری با این شناسه یافت نشد");
|
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||||
// }
|
ShowDangerAlert(request[0]);
|
||||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -192,60 +209,91 @@ else
|
|||||||
}
|
}
|
||||||
public async Task OnClickUpdate()
|
public async Task OnClickUpdate()
|
||||||
{
|
{
|
||||||
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
if (itemDTO.CODID == null || itemDTO.CODID <= 0)
|
||||||
// {
|
{
|
||||||
// if (ItemSearchCustomertype > 0)
|
ShowDangerAlert("کالا انتخاب نشده");
|
||||||
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// var rsp = await hc.Put<RCustomer>("Customer/Update", Cus);
|
if (itemDTO.am == null || itemDTO.am <= 0)
|
||||||
// if (rsp.IsSuccessStatusCode)
|
{
|
||||||
// {
|
ShowDangerAlert("تعداد وارد نشده");
|
||||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
return;
|
||||||
// if (request)
|
}
|
||||||
// {
|
|
||||||
// result.Status = ComponentStatus.success;
|
if (itemDTO.fee == null || itemDTO.fee < 0)
|
||||||
// result.Action = ComponentAction.update;
|
{
|
||||||
// await OnMultipleOfThree.InvokeAsync(result);
|
ShowDangerAlert("مبلغ واحد وارد نشده");
|
||||||
// }
|
return;
|
||||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
}
|
||||||
// }
|
|
||||||
// else
|
if (itemDTO.dis == null || itemDTO.dis < 0)
|
||||||
// {
|
{
|
||||||
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
ShowDangerAlert("مبلغ تخفیف درست نیست");
|
||||||
// ShowDangerAlert(request[0]);
|
return;
|
||||||
// }
|
}
|
||||||
// }
|
var rsp = await hc.Put<InvoiceItemDTO>($"InvoiceItem/UpdateItem/{InvoiceID}", itemDTO);
|
||||||
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
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]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public async Task OnClickAdd()
|
public async Task OnClickAdd()
|
||||||
{
|
{
|
||||||
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
if (itemDTO.CODID == null || itemDTO.CODID <= 0)
|
||||||
// {
|
{
|
||||||
// if (ItemSearchCustomertype > 0)
|
ShowDangerAlert("کالا انتخاب نشده");
|
||||||
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
return;
|
||||||
// Cus.ID = null;
|
}
|
||||||
|
|
||||||
|
if (itemDTO.am == null || itemDTO.am <= 0)
|
||||||
|
{
|
||||||
|
ShowDangerAlert("تعداد وارد نشده");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// var rsp = await hc.Post<RCustomer>("Customer/Add", Cus);
|
if (itemDTO.fee == null || itemDTO.fee < 0)
|
||||||
// if (rsp.IsSuccessStatusCode)
|
{
|
||||||
// {
|
ShowDangerAlert("مبلغ واحد وارد نشده");
|
||||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if (request)
|
if (itemDTO.dis == null || itemDTO.dis < 0)
|
||||||
// {
|
{
|
||||||
// result.Status = ComponentStatus.success;
|
ShowDangerAlert("مبلغ تخفیف درست نیست");
|
||||||
// result.Action = ComponentAction.add;
|
return;
|
||||||
// await OnMultipleOfThree.InvokeAsync(result);
|
}
|
||||||
// }
|
|
||||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
|
|
||||||
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
var rsp = await hc.Post<InvoiceItemDTO>($"InvoiceItem/AddItem/{InvoiceID}", itemDTO);
|
||||||
// ShowDangerAlert(request[0]);
|
if (rsp.IsSuccessStatusCode)
|
||||||
// }
|
{
|
||||||
// }
|
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||||
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
|
[Parameter] public int InvoiceID { get; set; }
|
||||||
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
|
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
|
||||||
[Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; }
|
[Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; }
|
||||||
private Modal modal = default!;
|
private Modal modal = default!;
|
||||||
@@ -62,6 +63,7 @@
|
|||||||
|
|
||||||
|
|
||||||
parameters.Add("itemDTO", args.Item);
|
parameters.Add("itemDTO", args.Item);
|
||||||
|
parameters.Add("InvoiceID", InvoiceID);
|
||||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
|
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
|
||||||
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters);
|
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters);
|
||||||
|
|
||||||
|
@@ -122,38 +122,38 @@
|
|||||||
<br /> <hr class="hr" />
|
<br /> <hr class="hr" />
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<Tabs NavStyle="NavStyle.VerticalUnderline">
|
<Tabs NavStyle="NavStyle.VerticalUnderline">
|
||||||
<Tab Title="آیتم ها" IsActive="true">
|
<Tab Title="آیتم ها" IsActive="InvoiceID==0 || InvoiceID==null ? false : true">
|
||||||
<Content>
|
<Content>
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="form-group col-md-11">
|
<div class="form-group col-md-11">
|
||||||
<LGridInvoiceItem OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" />
|
<LGridInvoiceItem InvoiceID="InvoiceID??0" OnMultipleOfThree="EventCallback.Factory.Create<string>(this, CallBack)" InvoiceItems="invoice.items" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-1">
|
<div class="form-group col-md-1">
|
||||||
|
|
||||||
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
|
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
|
||||||
+
|
+
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</Content>
|
</Content>
|
||||||
</Tab>
|
</Tab>
|
||||||
@* <Tab Title="پرداختی ها">
|
@* <Tab Title="پرداختی ها">
|
||||||
<Content>
|
<Content>
|
||||||
<div class="row g-3">
|
<div class="row g-3">
|
||||||
<div class="form-group col-md-11">
|
<div class="form-group col-md-11">
|
||||||
<LGridInvoicePayment InvoicePays="invoice.payments" />
|
<LGridInvoicePayment InvoicePays="invoice.payments" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-1">
|
<div class="form-group col-md-1">
|
||||||
|
|
||||||
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="OnClickDelete" Outline="true" Type="ButtonType.Button">
|
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="OnClickDelete" Outline="true" Type="ButtonType.Button">
|
||||||
+
|
+
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</Content>
|
</Content>
|
||||||
</Tab> *@
|
</Tab> *@
|
||||||
|
|
||||||
</Tabs>
|
</Tabs>
|
||||||
@@ -216,7 +216,7 @@
|
|||||||
invoice = new InvoiceDTO();
|
invoice = new InvoiceDTO();
|
||||||
await base.OnInitializedAsync();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
{
|
{
|
||||||
PreloadService.Show(SpinnerColor.Dark);
|
PreloadService.Show(SpinnerColor.Dark);
|
||||||
@@ -224,7 +224,7 @@
|
|||||||
Patterns = await fv.GetPatterns();
|
Patterns = await fv.GetPatterns();
|
||||||
if (InvoiceID != null && InvoiceID > 0)
|
if (InvoiceID != null && InvoiceID > 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
await LoadData();
|
await LoadData();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -248,12 +248,16 @@
|
|||||||
@functions {
|
@functions {
|
||||||
private async Task NewItemClick()
|
private async Task NewItemClick()
|
||||||
{
|
{
|
||||||
var parameters = new Dictionary<string, object>();
|
if (InvoiceID.HasValue)
|
||||||
|
{
|
||||||
|
var parameters = new Dictionary<string, object>();
|
||||||
|
|
||||||
|
parameters.Add("InvoiceID", InvoiceID);
|
||||||
|
parameters.Add("itemDTO", new InvoiceItemDTO());
|
||||||
|
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
|
||||||
|
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "آیتم جدید", parameters: parameters);
|
||||||
|
}
|
||||||
|
|
||||||
parameters.Add("itemDTO", new InvoiceItemDTO());
|
|
||||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
|
|
||||||
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "آیتم جدید", parameters: parameters);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private async Task LoadData()
|
private async Task LoadData()
|
||||||
@@ -285,7 +289,7 @@
|
|||||||
// if (result.Status == ComponentStatus.success)
|
// if (result.Status == ComponentStatus.success)
|
||||||
// msg = "آیتم با موفقیت حذف شد";
|
// msg = "آیتم با موفقیت حذف شد";
|
||||||
// }
|
// }
|
||||||
await CallBack(msg);
|
await CallBack(msg);
|
||||||
// if (result.Status == ComponentStatus.success)
|
// if (result.Status == ComponentStatus.success)
|
||||||
// await LoadCod(1);
|
// await LoadCod(1);
|
||||||
|
|
||||||
@@ -296,7 +300,7 @@
|
|||||||
if (!string.IsNullOrEmpty(result))
|
if (!string.IsNullOrEmpty(result))
|
||||||
{
|
{
|
||||||
ShowSuccessAlert(result);
|
ShowSuccessAlert(result);
|
||||||
await LoadData();
|
await LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ShowSuccessAlert(string msg)
|
private void ShowSuccessAlert(string msg)
|
||||||
@@ -315,33 +319,62 @@
|
|||||||
}
|
}
|
||||||
public async Task OnClickDelete()
|
public async Task OnClickDelete()
|
||||||
{
|
{
|
||||||
|
if (InvoiceID.HasValue)
|
||||||
|
{
|
||||||
|
var rsp = await hc.Delete($"Invoice/Delete/{InvoiceID.Value}");
|
||||||
|
if (rsp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||||
|
if (request)
|
||||||
|
{
|
||||||
|
hc._nav.NavigateTo("Invoice");
|
||||||
|
}
|
||||||
|
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||||
|
}
|
||||||
|
|
||||||
// var rsp = await hc.Delete($"Cod/Delete/{invoice.ID}");
|
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||||
// if (rsp.IsSuccessStatusCode)
|
{
|
||||||
// {
|
ShowDangerAlert("صورتحساب با این شناسه یافت نشد");
|
||||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
}
|
||||||
// if (request)
|
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||||
// {
|
}
|
||||||
// result.Status = ComponentStatus.success;
|
|
||||||
// result.Action = ComponentAction.delete;
|
|
||||||
|
|
||||||
// //await OnMultipleOfThree.InvokeAsync(result);
|
|
||||||
// }
|
|
||||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
|
||||||
// {
|
|
||||||
// ShowDangerAlert("کالا با این شناسه یافت نشد");
|
|
||||||
// }
|
|
||||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task OnClickUpdate()
|
public async Task OnClickUpdate()
|
||||||
{
|
{
|
||||||
|
if (InvoiceID.HasValue)
|
||||||
|
{
|
||||||
|
if (await Validate())
|
||||||
|
{
|
||||||
|
var rsp = await hc.Put<NUInvoiceDTO>("Invoice/Update", new NUInvoiceDTO
|
||||||
|
{
|
||||||
|
ID = InvoiceID,
|
||||||
|
CustomerID = invoice.CustomerID,
|
||||||
|
Des = invoice.Des,
|
||||||
|
InvoiceDate = invoice.InvoiceDate,
|
||||||
|
InvoicIssueDate = invoice.InvoicIssueDate,
|
||||||
|
PatternID = invoice.PatternID,
|
||||||
|
Title = invoice.Title
|
||||||
|
});
|
||||||
|
if (rsp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var request = await rsp.Content.ReadFromJsonAsync<int>();
|
||||||
|
|
||||||
|
if (request > 0)
|
||||||
|
{
|
||||||
|
InvoiceID = request;
|
||||||
|
}
|
||||||
|
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||||
|
ShowDangerAlert(request[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// if (Cod.UnitID > 0 && Cod.TaxRate > 0 && !string.IsNullOrEmpty(Cod.Title))
|
// if (Cod.UnitID > 0 && Cod.TaxRate > 0 && !string.IsNullOrEmpty(Cod.Title))
|
||||||
// {
|
// {
|
||||||
|
|
||||||
@@ -367,33 +400,88 @@
|
|||||||
}
|
}
|
||||||
public async Task OnClickAdd()
|
public async Task OnClickAdd()
|
||||||
{
|
{
|
||||||
// if (Cod.UnitID > 0 && Cod.TaxRate > 0 && !string.IsNullOrEmpty(Cod.Title))
|
if (await Validate())
|
||||||
// {
|
{
|
||||||
|
var rsp = await hc.Post<NUInvoiceDTO>("Invoice/Add", new NUInvoiceDTO
|
||||||
|
{
|
||||||
|
CustomerID = invoice.CustomerID,
|
||||||
|
Des = invoice.Des,
|
||||||
|
InvoiceDate = invoice.InvoiceDate,
|
||||||
|
InvoicIssueDate = invoice.InvoicIssueDate,
|
||||||
|
PatternID = invoice.PatternID,
|
||||||
|
Title = invoice.Title
|
||||||
|
});
|
||||||
|
if (rsp.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
var request = await rsp.Content.ReadFromJsonAsync<int>();
|
||||||
|
|
||||||
// var rsp = await hc.Post<RCOD>("Cod/Add", Cod);
|
if (request > 0)
|
||||||
// if (rsp.IsSuccessStatusCode)
|
{
|
||||||
// {
|
InvoiceID = request;
|
||||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
}
|
||||||
|
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
// if (request)
|
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||||
// {
|
ShowDangerAlert(request[0]);
|
||||||
// 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("فیلدهای قرمز باید مقدار دهی شوند");
|
|
||||||
}
|
}
|
||||||
public async Task<bool> Validate()
|
public async Task<bool> Validate()
|
||||||
{
|
{
|
||||||
return false;
|
if (string.IsNullOrEmpty(invoice.Title))
|
||||||
|
{
|
||||||
|
ShowDangerAlert("عنوان نمی تواند خالی باشد");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(invoice.InvoiceDate))
|
||||||
|
{
|
||||||
|
ShowDangerAlert("تاریخ صورتحساب نمی تواند خالی باشد");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int InvoiceDate = 0;
|
||||||
|
if (invoice.InvoiceDate.Replace("/", "").Length != 8 || !int.TryParse(invoice.InvoiceDate.Replace("/", ""), out InvoiceDate))
|
||||||
|
{
|
||||||
|
ShowDangerAlert("تاریخ صورتحساب صحیح نمی باشد");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (InvoiceDate.ToString().Trim().ToMiladiinFront() > DateTime.Now)
|
||||||
|
{
|
||||||
|
ShowDangerAlert("تاریخ صورتحساب نمی تواند از امروز جلوتر باشد");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(invoice.InvoicIssueDate))
|
||||||
|
{ ShowDangerAlert("تاریخ صدور نمی تواند خالی باشد"); return false; }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int InvoicIssueDate = 0;
|
||||||
|
if (invoice.InvoicIssueDate.Replace("/", "").Length != 8 || !int.TryParse(invoice.InvoicIssueDate.Replace("/", ""), out InvoicIssueDate))
|
||||||
|
{ ShowDangerAlert("تاریخ صدور صحیح نمی باشد"); return false; }
|
||||||
|
|
||||||
|
else if (InvoicIssueDate.ToString().Trim().ToMiladiinFront() > DateTime.Now)
|
||||||
|
{ ShowDangerAlert("تاریخ صدور نمی تواند از امروز جلوتر باشد"); return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invoice.PatternID.HasValue)
|
||||||
|
if (invoice.PatternID <= 0 || !Patterns.Any(w => w.ID == invoice.PatternID.Value))
|
||||||
|
{ ShowDangerAlert("شناسه الگو صحیح نمی باشد"); return false; }
|
||||||
|
|
||||||
|
if (invoice.CustomerID == null || invoice.CustomerID <= 0 || !Cus.Any(w => w.ID == invoice.CustomerID))
|
||||||
|
{ ShowDangerAlert("مشتری صحیح نمی باشد"); return false; }
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user