remove Insurance job salarey validation

This commit is contained in:
SamSys
2025-05-04 17:29:58 +03:30
parent f93d0b7e89
commit f4f6fd1bf6
5 changed files with 166 additions and 158 deletions

View File

@@ -1633,7 +1633,7 @@ public class InsuranceListApplication: IInsuranceListApplication
dateSaleryviewModel.StartDateGr = startDateGr;
dateSaleryviewModel.EndDateGr = endDateGr;
var _dateSalary = _dateSalaryRepository.GetDateSalaryViewModel(dateSaleryviewModel);
if (_dateSalary != null)
if (_dateSalary != null && _dateSalary.Id >0)
{
var dateSaleryItemviewModel = new DateSalaryItemSearchModel();
dateSaleryItemviewModel.DateSalaryId = _dateSalary.Id;

View File

@@ -77,6 +77,7 @@ public class DateSalaryRepository : RepositoryBase<long, DateSalary>, IDateSalar
var dateSalary = new DateSalary(command.StartDateFa, command.EndDateFa);
Create(dateSalary);
SaveChanges();
command.DateSalaryItems = command.DateSalaryItems.Where(x => x.Salary > 0).ToList();
foreach (var item in command.DateSalaryItems)
{
@@ -104,7 +105,7 @@ public class DateSalaryRepository : RepositoryBase<long, DateSalary>, IDateSalar
var dateSalary = Get(command.Id);
dateSalary.Edit(command.StartDateFa, command.EndDateFa);
SaveChanges();
command.DateSalaryItems = command.DateSalaryItems.Where(x => x.Salary > 0).ToList();
foreach (var item in command.DateSalaryItems)
{
if (item.Id == 0)

View File

@@ -1,182 +1,188 @@
@model List<CompanyManagment.App.Contracts.Percentage.PercentageViewModel>
@model List<CompanyManagment.App.Contracts.Percentage.PercentageViewModel>
<link href="@Href("~/admintheme/css/information-insurance-jobs.css")" rel="stylesheet"/>
<link href="@Href("~/admintheme/css/information-insurance-jobs.css")" rel="stylesheet" />
@Html.AntiForgeryToken()
<div class="container">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="main-title">اطلاعات مربوط به مشاغل مقطوع </div>
<div class="box">
<form>
<div class="form">
<div class="col-md-6 inputs">
<input type="text" id="fromDate" placeholder="تاریخ شروع" class="input upper-in date">
</div>
<div class="col-md-6 inputs">
<input type="text" id="toDate" placeholder="تاریخ پایان" class="input upper-in date" style="direction: rtl;">
</div>
<div class="col-md-12 inputs" id="table-container">
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th style="border-left: 0;">مبلغ </th>
<th>ضریب</th>
<th style="border-right: 0;"> #</th>
</tr>
</thead>
<tbody>
@{ var index = 1; }
@foreach (var item in Model)
{
<tr>
<td class="col-md-6">
<input id="txtMoney-@item.Id" class="items money" type="text" onkeyup="getMoneyValue(this);" placeholder=""/>
<input class=" percentageId" type="hidden" value="@item.Id"/>
</td>
<td class="col-md-6">
<input class="items percentItem" type="text" placeholder="" disabled="disabled" value="@item.Percent"/>
</td>
<td class="col-md-1">@index</td>
</tr>
index = index + 1;
}
</tbody>
</table>
</div>
</div>
<div class="btns">
<div class="col-md-5">
<a href="#" class=" btn btn-modal" id="save">ذخیره</a>
<button class="btn btn-modal" id="close" data-dismiss="modal">بستن</button>
</div>
</div>
</form>
</div>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="main-title">اطلاعات مربوط به مشاغل مقطوع </div>
<div class="box">
<form>
<div class="form">
<div class="col-md-6 inputs">
<input type="text" id="fromDate" placeholder="تاریخ شروع" class="input upper-in date">
</div>
<div class="col-md-6 inputs">
<input type="text" id="toDate" placeholder="تاریخ پایان" class="input upper-in date" style="direction: rtl;">
</div>
<div class="col-md-12 inputs" id="table-container">
<table id="table" class="table table-bordered table-striped">
<thead>
<tr>
<th style="border-left: 0;">مبلغ </th>
<th>ضریب</th>
<th style="border-right: 0;"> #</th>
</tr>
</thead>
<tbody>
@{
var index = 1;
}
@foreach (var item in Model)
{
<tr>
<td class="col-md-6">
<input id="txtMoney-@item.Id" class="items money" type="text" onkeyup="getMoneyValue(this);" placeholder="" />
<input class=" percentageId" type="hidden" value="@item.Id" />
</td>
<td class="col-md-6">
<input class="items percentItem" type="text" placeholder="" disabled="disabled" value="@item.Percent" />
</td>
<td class="col-md-1">@index</td>
</tr>
index = index + 1;
}
</tbody>
</table>
</div>
</div>
<div class="btns">
<div class="col-md-5">
<a href="#" class=" btn btn-modal" id="save">ذخیره</a>
<button class="btn btn-modal" id="close" data-dismiss="modal">بستن</button>
</div>
</div>
</form>
</div>
</div>
<script src="~/AdminTheme/js/numeral.min.js"></script>
<script>
$(document).ready(function() {
$(".date").mask("0000/00/00");
});
$(document).ready(function() {
$(".date").mask("0000/00/00");
});
$(".date").keyup(function() {
const value = $(this).val();
const lengthValue = value.length;
$(".date").keyup(function() {
const value = $(this).val();
const lengthValue = value.length;
if (lengthValue == 10) {
if (!dateValidCheck(this)) {
$(this).addClass("errored");
} else {
$(this).removeClass("errored");
}
}
if (lengthValue == 10) {
if (!dateValidCheck(this)) {
$(this).addClass("errored");
} else {
$(this).removeClass("errored");
}
}
});
});
function getMoneyValue(element) {
const text = getNumberValue($(element).val());
const textMoney = numeral(text).format();
const id = $(element).attr('id');
function getMoneyValue(element) {
const text = getNumberValue($(element).val());
const textMoney = numeral(text).format();
const id = $(element).attr('id');
$(`#${id}`).val(textMoney);
}
$(`#${id}`).val(textMoney);
}
$("#save").click(function() {
$("#save").click(function() {
if (checkEmpty()) {
const fromDate = $("#fromDate").val();
const toDate = $("#toDate").val();
if (fromDate != '' && !checkLength(fromDate, 10)) {
if (!dateValidCheckByValue($("#fromDate"))) {
$("#fromDate").addClass("errored");
} else {
$("#fromDate").removeClass("errored");
}
}
if (toDate != '' && !checkLength(toDate, 10)) {
if (!dateValidCheckByValue($("#toDate"))) {
$("#toDate").addClass("errored");
} else {
$("#toDate").removeClass("errored");
}
}
if ((fromDate != '' && checkLength(fromDate, 10)) && (toDate != '' && checkLength(toDate, 10)) && toDate < fromDate) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند کمتر از تاریخ شروع باشد.');
return;
} else if (toDate == fromDate) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند مساوی با تاریخ شروع باشد.');
return;
} else {
if (checkEmpty()) {
const fromDate = $("#fromDate").val();
const toDate = $("#toDate").val();
if (fromDate != '' && !checkLength(fromDate, 10)) {
if (!dateValidCheckByValue($("#fromDate"))) {
$("#fromDate").addClass("errored");
} else {
$("#fromDate").removeClass("errored");
}
}
if (toDate != '' && !checkLength(toDate, 10)) {
if (!dateValidCheckByValue($("#toDate"))) {
$("#toDate").addClass("errored");
} else {
$("#toDate").removeClass("errored");
}
}
if ((fromDate != '' && checkLength(fromDate, 10)) && (toDate != '' && checkLength(toDate, 10)) && toDate < fromDate) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند کمتر از تاریخ شروع باشد.');
return;
} else if (toDate == fromDate) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند مساوی با تاریخ شروع باشد.');
return;
} else {
var dateSalaryItemsList = [];
$('#table tbody tr').each(function(index) {
var dateSalaryItemsList = [];
$('#table tbody tr').each(function(index) {
const dateSalaryItems = {};
dateSalaryItems.Salary = getNumberValue($(this).find('input.money').val());
dateSalaryItems.Percent = $(this).find('input.percentItem').val();
dateSalaryItems.PercentageId = $(this).find('input.percentageId').val();
dateSalaryItems.DateSalaryId = 0;
const dateSalaryItems = {};
dateSalaryItems.Salary = getNumberValue($(this).find('input.money').val());
dateSalaryItems.Percent = $(this).find('input.percentItem').val();
dateSalaryItems.PercentageId = $(this).find('input.percentageId').val();
dateSalaryItems.DateSalaryId = 0;
dateSalaryItemsList.push(dateSalaryItems);
});
const command = {};
command.StartDateFa = fromDate;
command.EndDateFa = toDate;
command.DateSalaryItems = dateSalaryItemsList;
dateSalaryItemsList.push(dateSalaryItems);
});
const command = {};
command.StartDateFa = fromDate;
command.EndDateFa = toDate;
command.DateSalaryItems = dateSalaryItemsList;
// console.log(command);
// console.log(command);
$.ajax({
dataType: 'json',
type: 'POST',
url: '@Url.Page("/Company/InsuranceJob/Index", "CreateDateSalaryItem")',
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
data: command,
success: function(response) {
if (response.isSuccedded) {
$("#MainModal").modal('toggle');
$.Notification.autoHideNotify('success', 'top right', 'پیام سیستم ', response.message);
} else {
$.Notification.autoHideNotify('error', 'top right', response.message);
}
},
failure: function(response) {
console.log(5, response);
}
$.ajax({
dataType: 'json',
type: 'POST',
url: '@Url.Page("/Company/InsuranceJob/Index", "CreateDateSalaryItem")',
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
data: command,
success: function(response) {
if (response.isSuccedded) {
$("#MainModal").modal('toggle');
$.Notification.autoHideNotify('success', 'top right', 'پیام سیستم ', response.message);
setTimeout(function () {
window.location.reload();
});
}
}
});
}, 1000);
} else {
$.Notification.autoHideNotify('error', 'top right', response.message);
}
},
failure: function(response) {
console.log(5, response);
}
});
}
}
});
function checkEmpty() {
const fromDate = $("#fromDate").val();
const toDate = $("#toDate").val();
function checkEmpty() {
const fromDate = $("#fromDate").val();
const toDate = $("#toDate").val();
var result = true;
var result = true;
if (fromDate == '') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع نمی تواند خالی باشد.');
result = false;
} else if (toDate == '') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند خالی باشد.');
result = false;
} else {
$('#table tbody tr').each(function(index) {
if ($(this).find('input.money').val() == '') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', `مبلغ در ردیف ${index + 1}وارد نشده است.`);
result = false;
}
});
}
return result;
}
if (fromDate == '') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ شروع نمی تواند خالی باشد.');
result = false;
} else if (toDate == '') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند خالی باشد.');
result = false;
} else {
// $('#table tbody tr').each(function(index) {
// if ($(this).find('input.money').val() == '') {
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', `مبلغ در ردیف ${index + 1}وارد نشده است.`);
// result = false;
// }
// });
}
return result;
}
</script>

View File

@@ -169,6 +169,7 @@
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند خالی باشد.');
result = false;
} else {
$('#table tbody tr').each(function(index) {
if ($(this).find('input.money').val() == '' || $(this).find('input.money').val() == '0') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', `مبلغ در ردیف ${index + 1}وارد نشده است.`);

View File

@@ -176,12 +176,12 @@
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', 'تاریخ پایان نمی تواند خالی باشد.');
result = false;
} else {
$('#table tbody tr').each(function(index) {
if ($(this).find('input.money').val() == '' || $(this).find('input.money').val() == '0') {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', `مبلغ در ردیف ${index + 1}وارد نشده است.`);
result = false;
}
});
// $('#table tbody tr').each(function(index) {
// if ($(this).find('input.money').val() == '' || $(this).find('input.money').val() == '0') {
// $.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', `مبلغ در ردیف ${index + 1}وارد نشده است.`);
// result = false;
// }
// });
}
return result;
}