...
This commit is contained in:
@@ -55,8 +55,8 @@ namespace Back.Controllers
|
||||
item.InvoicIssueDate = DateTime.Now.ConvertMiladiToShamsi();
|
||||
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(item);
|
||||
//if (!ModelState.IsValid)
|
||||
// return BadRequest(item);
|
||||
|
||||
//-----GetUserAndCompany
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
|
@@ -27,7 +27,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[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
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -64,7 +64,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[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
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -109,7 +109,7 @@ namespace Back.Controllers
|
||||
|
||||
}
|
||||
[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
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
@@ -124,12 +124,12 @@ namespace Back.Controllers
|
||||
//-----Get invoice
|
||||
Invoice invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, invoiceID);
|
||||
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)
|
||||
return BadRequest(new List<string> { "invoice Item notFound..." });
|
||||
return NotFound(new List<string> { "invoice Item notFound..." });
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
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.Udate = DateTime.Now.ConvertMiladiToShamsi();
|
||||
@@ -137,12 +137,17 @@ namespace Back.Services
|
||||
if (calculate)
|
||||
{
|
||||
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
|
||||
{
|
||||
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")
|
||||
;
|
||||
}
|
||||
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)
|
||||
{
|
||||
return enumType.GetType().GetMember(enumType.ToString())
|
||||
|
@@ -69,7 +69,7 @@
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<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 class="row g-3">
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<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>
|
||||
</form>
|
||||
@@ -113,6 +113,7 @@ else
|
||||
bool Hidealert = true;
|
||||
string alertMessage = "";
|
||||
public int Tax { get; set; } = 0;
|
||||
[Parameter] public int InvoiceID { get; set; }
|
||||
[Parameter] public InvoiceItemDTO itemDTO { get; set; }
|
||||
[Parameter] public EventCallback<ActionInResultComponent> OnMultipleOfThree { get; set; }
|
||||
public List<CODIdName<int>> cods { get; set; } = new();
|
||||
@@ -135,6 +136,21 @@ else
|
||||
}
|
||||
}
|
||||
@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()
|
||||
{
|
||||
if (itemDTO.ID == null)
|
||||
@@ -143,7 +159,7 @@ else
|
||||
private async Task adisAsync()
|
||||
{
|
||||
if (itemDTO.ID == null)
|
||||
itemDTO.adis= itemDTO.prdis - itemDTO.dis;
|
||||
itemDTO.adis = itemDTO.prdis - itemDTO.dis;
|
||||
|
||||
// await AftervamAsync();
|
||||
}
|
||||
@@ -155,7 +171,7 @@ else
|
||||
private async Task tsstamAsync()
|
||||
{
|
||||
if (itemDTO.ID == null)
|
||||
itemDTO.tsstam = itemDTO.vam + itemDTO.adis ;
|
||||
itemDTO.tsstam = itemDTO.vam + itemDTO.adis;
|
||||
}
|
||||
private async Task AfterAsync()
|
||||
{
|
||||
@@ -164,27 +180,28 @@ else
|
||||
await vamAsync();
|
||||
await tsstamAsync();
|
||||
}
|
||||
//-----------------------
|
||||
public async Task OnClickDelete()
|
||||
{
|
||||
|
||||
// var rsp = await hc.Delete($"Customer/Delete/{Cus.ID}");
|
||||
// if (rsp.IsSuccessStatusCode)
|
||||
// {
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
// if (request)
|
||||
// {
|
||||
// result.Status = ComponentStatus.success;
|
||||
// result.Action = ComponentAction.delete;
|
||||
// await OnMultipleOfThree.InvokeAsync(result);
|
||||
// }
|
||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
// }
|
||||
var rsp = await hc.Delete($"InvoiceItem/DeleteItem/{InvoiceID}/{itemDTO.ID}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request)
|
||||
{
|
||||
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("خطایی در اجرای عملیات رخ داده");
|
||||
else
|
||||
{
|
||||
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
ShowDangerAlert(request[0]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -192,60 +209,91 @@ else
|
||||
}
|
||||
public async Task OnClickUpdate()
|
||||
{
|
||||
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
||||
// {
|
||||
// if (ItemSearchCustomertype > 0)
|
||||
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
||||
if (itemDTO.CODID == null || itemDTO.CODID <= 0)
|
||||
{
|
||||
ShowDangerAlert("کالا انتخاب نشده");
|
||||
return;
|
||||
}
|
||||
|
||||
// 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("فیلدهای قرمز باید مقدار دهی شوند");
|
||||
if (itemDTO.am == null || itemDTO.am <= 0)
|
||||
{
|
||||
ShowDangerAlert("تعداد وارد نشده");
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemDTO.fee == null || itemDTO.fee < 0)
|
||||
{
|
||||
ShowDangerAlert("مبلغ واحد وارد نشده");
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemDTO.dis == null || itemDTO.dis < 0)
|
||||
{
|
||||
ShowDangerAlert("مبلغ تخفیف درست نیست");
|
||||
return;
|
||||
}
|
||||
var rsp = await hc.Put<InvoiceItemDTO>($"InvoiceItem/UpdateItem/{InvoiceID}", itemDTO);
|
||||
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()
|
||||
{
|
||||
// if (ItemSearchCustomertype > 0 && !string.IsNullOrEmpty(Cus.FullName))
|
||||
// {
|
||||
// if (ItemSearchCustomertype > 0)
|
||||
// Cus.CustomerType = (CustomerType)ItemSearchCustomertype;
|
||||
// Cus.ID = null;
|
||||
if (itemDTO.CODID == null || itemDTO.CODID <= 0)
|
||||
{
|
||||
ShowDangerAlert("کالا انتخاب نشده");
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemDTO.am == null || itemDTO.am <= 0)
|
||||
{
|
||||
ShowDangerAlert("تعداد وارد نشده");
|
||||
return;
|
||||
}
|
||||
|
||||
// var rsp = await hc.Post<RCustomer>("Customer/Add", Cus);
|
||||
// if (rsp.IsSuccessStatusCode)
|
||||
// {
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (itemDTO.fee == null || itemDTO.fee < 0)
|
||||
{
|
||||
ShowDangerAlert("مبلغ واحد وارد نشده");
|
||||
return;
|
||||
}
|
||||
|
||||
// if (request)
|
||||
// {
|
||||
// result.Status = ComponentStatus.success;
|
||||
// result.Action = ComponentAction.add;
|
||||
// await OnMultipleOfThree.InvokeAsync(result);
|
||||
// }
|
||||
// else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
if (itemDTO.dis == null || itemDTO.dis < 0)
|
||||
{
|
||||
ShowDangerAlert("مبلغ تخفیف درست نیست");
|
||||
return;
|
||||
}
|
||||
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
// ShowDangerAlert(request[0]);
|
||||
// }
|
||||
// }
|
||||
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
||||
var rsp = await hc.Post<InvoiceItemDTO>($"InvoiceItem/AddItem/{InvoiceID}", itemDTO);
|
||||
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]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -46,6 +46,7 @@
|
||||
|
||||
|
||||
@code {
|
||||
[Parameter] public int InvoiceID { get; set; }
|
||||
[Parameter] public EventCallback<string> OnMultipleOfThree { get; set; }
|
||||
[Parameter] public IEnumerable<InvoiceItemDTO> InvoiceItems { get; set; }
|
||||
private Modal modal = default!;
|
||||
@@ -62,6 +63,7 @@
|
||||
|
||||
|
||||
parameters.Add("itemDTO", args.Item);
|
||||
parameters.Add("InvoiceID", InvoiceID);
|
||||
parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBack));
|
||||
await modal.ShowAsync<CUSComponent.InvoiceItem>(title: "ویرایش اطلاعات", parameters: parameters);
|
||||
|
||||
|
@@ -122,38 +122,38 @@
|
||||
<br /> <hr class="hr" />
|
||||
<div class="row g-3">
|
||||
<Tabs NavStyle="NavStyle.VerticalUnderline">
|
||||
<Tab Title="آیتم ها" IsActive="true">
|
||||
<Tab Title="آیتم ها" IsActive="InvoiceID==0 || InvoiceID==null ? false : true">
|
||||
<Content>
|
||||
<div class="row g-3">
|
||||
<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 class="form-group col-md-1">
|
||||
|
||||
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="NewItemClick" Outline="true" Type="ButtonType.Button">
|
||||
+
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</Content>
|
||||
</Tab>
|
||||
@* <Tab Title="پرداختی ها">
|
||||
<Content>
|
||||
<div class="row g-3">
|
||||
<div class="form-group col-md-11">
|
||||
<LGridInvoicePayment InvoicePays="invoice.payments" />
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
@* <Tab Title="پرداختی ها">
|
||||
<Content>
|
||||
<div class="row g-3">
|
||||
<div class="form-group col-md-11">
|
||||
<LGridInvoicePayment InvoicePays="invoice.payments" />
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
|
||||
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="OnClickDelete" Outline="true" Type="ButtonType.Button">
|
||||
+
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Button class="mt-3" Color="ButtonColor.Dark" @onclick="OnClickDelete" Outline="true" Type="ButtonType.Button">
|
||||
+
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</Content>
|
||||
|
||||
</Content>
|
||||
</Tab> *@
|
||||
|
||||
</Tabs>
|
||||
@@ -216,7 +216,7 @@
|
||||
invoice = new InvoiceDTO();
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
@@ -224,7 +224,7 @@
|
||||
Patterns = await fv.GetPatterns();
|
||||
if (InvoiceID != null && InvoiceID > 0)
|
||||
{
|
||||
|
||||
|
||||
await LoadData();
|
||||
}
|
||||
else
|
||||
@@ -248,12 +248,16 @@
|
||||
@functions {
|
||||
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()
|
||||
@@ -285,7 +289,7 @@
|
||||
// if (result.Status == ComponentStatus.success)
|
||||
// msg = "آیتم با موفقیت حذف شد";
|
||||
// }
|
||||
await CallBack(msg);
|
||||
await CallBack(msg);
|
||||
// if (result.Status == ComponentStatus.success)
|
||||
// await LoadCod(1);
|
||||
|
||||
@@ -296,7 +300,7 @@
|
||||
if (!string.IsNullOrEmpty(result))
|
||||
{
|
||||
ShowSuccessAlert(result);
|
||||
await LoadData();
|
||||
await LoadData();
|
||||
}
|
||||
}
|
||||
private void ShowSuccessAlert(string msg)
|
||||
@@ -315,33 +319,62 @@
|
||||
}
|
||||
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}");
|
||||
// if (rsp.IsSuccessStatusCode)
|
||||
// {
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
// if (request)
|
||||
// {
|
||||
// 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("خطایی در اجرای عملیات رخ داده");
|
||||
|
||||
|
||||
|
||||
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
{
|
||||
ShowDangerAlert("صورتحساب با این شناسه یافت نشد");
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
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))
|
||||
// {
|
||||
|
||||
@@ -367,33 +400,88 @@
|
||||
}
|
||||
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 (rsp.IsSuccessStatusCode)
|
||||
// {
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<bool>();
|
||||
if (request > 0)
|
||||
{
|
||||
InvoiceID = request;
|
||||
}
|
||||
else ShowDangerAlert("خطایی در اجرای عملیات رخ داده");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// 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]);
|
||||
}
|
||||
}
|
||||
|
||||
// var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
|
||||
// ShowDangerAlert(request[0]);
|
||||
// }
|
||||
// }
|
||||
// else ShowDangerAlert("فیلدهای قرمز باید مقدار دهی شوند");
|
||||
}
|
||||
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