This commit is contained in:
SamSys
2025-05-17 22:56:53 +03:30
parent 140adb2588
commit b8937ef79c
12 changed files with 9831 additions and 28 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using _0_Framework.Domain;
using Company.Domain.InsuranceJobAndJobsAgg;
using Company.Domain.InsurancJobAgg;
@@ -8,13 +9,15 @@ namespace Company.Domain.InsuranceJobItemAgg;
public class InsuranceJobItem : EntityBase
{
public InsuranceJobItem(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId)
public InsuranceJobItem(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId, DateTime? startDate, DateTime? endDate)
{
PercentageLessThan = percentageLessThan;
SalaeyLessThan = salaeyLessThan;
PercentageMoreThan = percentageMoreThan;
SalaryMoreThan = salaryMoreThan;
InsuranceJobId = insuranceJobId;
StartDate = startDate;
EndDate = endDate;
}
public double PercentageLessThan { get; private set; }
@@ -22,6 +25,9 @@ public class InsuranceJobItem : EntityBase
public double PercentageMoreThan { get; private set; }
public double SalaryMoreThan { get; private set; }
public DateTime? StartDate { get; private set; }
public DateTime? EndDate { get; private set; }
public long InsuranceJobId { get; private set; }
public InsuranceJob InsuranceJob { get; set; }
public List<InsuranceJobAndJobs> InsuranceJobAndJobs { get; set; }
@@ -31,12 +37,14 @@ public class InsuranceJobItem : EntityBase
InsuranceJobAndJobs = new List<InsuranceJobAndJobs>();
}
public void Edit(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId)
public void Edit(double percentageLessThan, double salaeyLessThan, double percentageMoreThan, double salaryMoreThan, long insuranceJobId, DateTime? startDate, DateTime? endDate)
{
PercentageLessThan = percentageLessThan;
SalaeyLessThan = salaeyLessThan;
PercentageMoreThan = percentageMoreThan;
SalaryMoreThan = salaryMoreThan;
InsuranceJobId = insuranceJobId;
StartDate = startDate;
EndDate = endDate;
}
}

View File

@@ -15,6 +15,9 @@ public class CreateInsuranceJob
public string EconomicCode { get; set; }
public string Year { get; set; }
public long JobId { get; set; }
public string StartDateFa { get; set; }
public string EndDateFa { get; set; }
public List<JobViewModel> Jobs { get; set; }
public List<InsuranceJobItemViewModel> InsuranceJobItems { get; set; }
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CompanyManagment.App.Contracts.InsuranceJobItem;
namespace CompanyManagment.App.Contracts.InsuranceJob;
@@ -13,4 +14,5 @@ public class InsuranceJobViewModel
//public long YearlySalaryId { get; set; }
public string EconomicCode { get; set; }
public string Year { get; set; }
public List<InsuranceJobItemViewModel> InsuranceJobItemViewModels { get; set; }
}

View File

@@ -19,6 +19,9 @@ public class InsuranceJobItemViewModel
public string SalaryMoreThanString { get; set; }
public long InsuranceJobId { get; set; }
public DateTime? StartDate { get; set; }
public DateTime? EndDate { get; set; }
public List<long> JobIds { get; set; }
public List<JobViewModel> JobList { get; set; }
}

View File

@@ -11,6 +11,9 @@ public class InsuranceJobeItemMapping : IEntityTypeConfiguration<InsuranceJobIte
builder.ToTable("InsuranceJobItems");
builder.HasKey(x => x.id);
builder.Property(x => x.StartDate).IsRequired(false);
builder.Property(x => x.EndDate).IsRequired(false);
builder.HasOne(x => x.InsuranceJob)
.WithMany(x => x.InsuranceJobItemList)
.HasForeignKey(x => x.InsuranceJobId);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class addstartEndToInsuranceJobItems : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "EndDate",
table: "InsuranceJobItems",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "StartDate",
table: "InsuranceJobItems",
type: "datetime2",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "EndDate",
table: "InsuranceJobItems");
migrationBuilder.DropColumn(
name: "StartDate",
table: "InsuranceJobItems");
}
}
}

View File

@@ -3219,6 +3219,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("EndDate")
.HasColumnType("datetime2");
b.Property<long>("InsuranceJobId")
.HasColumnType("bigint");
@@ -3234,6 +3237,9 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<double>("SalaryMoreThan")
.HasColumnType("float");
b.Property<DateTime?>("StartDate")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("InsuranceJobId");

View File

@@ -23,7 +23,7 @@ public class InsuranceJobItemRepository : RepositoryBase<long, InsuranceJobItem>
{
InsuranceJobItem incuranceJobItemObj = new InsuranceJobItem(model.PercentageLessThan, model.SalaeyLessThan,
model.PercentageMoreThan, model.SalaryMoreThan, model.InsuranceJobId);
model.PercentageMoreThan, model.SalaryMoreThan, model.InsuranceJobId, model.StartDate,model.EndDate);
_context.InsuranceJobItems.Add(incuranceJobItemObj);
_context.SaveChanges();
List<InsuranceJobAndJobs> insuranceJobAndJobsList = new List<InsuranceJobAndJobs>();

View File

@@ -8,6 +8,7 @@ using Company.Domain.InsuranceJobItemAgg;
using Company.Domain.InsurancJobAgg;
using Company.Domain.PercentageAgg;
using CompanyManagment.App.Contracts.InsuranceJob;
using Microsoft.EntityFrameworkCore;
namespace CompanyManagment.EFCore.Repository;
@@ -49,11 +50,27 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
public List<InsuranceJobViewModel> Search(InsuranceJobSearchModel searchModel)
{
var query = _context.InsuranceJobs.Select(x => new InsuranceJobViewModel
string now = Tools.ToFarsi(DateTime.Now);
string year = now.Substring(0, 4);
string month = now.Substring(5, 2);
if (!string.IsNullOrWhiteSpace(searchModel.Year))
year = searchModel.Year;
if (!string.IsNullOrWhiteSpace(searchModel.Month))
month = searchModel.Month;
var searcheDate = ($"{year}/{month}/01").ToGeorgianDateTime();
var query = _context.InsuranceJobs
.Include(x=>x.InsuranceJobItemList).Where(x=>x.InsuranceJobItemList.Any(i=>i.StartDate <= searcheDate && i.EndDate >= searcheDate))
.Select(x => new InsuranceJobViewModel
{
Id = x.id,
InsuranceJobTitle = x.InsuranceJobTitle,
EconomicCode = x.EconomicCode
EconomicCode = x.EconomicCode,
Year = year
});
if (!string.IsNullOrWhiteSpace(searchModel.EconomicCode))
@@ -80,6 +97,8 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
item.PercentageLessThan = item.PercentageLessThan;
item.PercentageMoreThan = item.PercentageMoreThan;
item.InsuranceJobId = insuranceJobObj.id;
item.StartDate = command.StartDateFa.ToGeorgianDateTime();
item.EndDate = command.EndDateFa.ToGeorgianDateTime();
_insuranceJobItemRepositpry.CreateInsuranceJobItem(item);
if (!_percentageRepository.Exists(x => x.Percent == item.PercentageLessThan))
@@ -167,7 +186,7 @@ public class InsuranceJobRepository : RepositoryBase<long, InsuranceJob>, IInsur
else
{
var insuranceJobItem = _insuranceJobItemRepositpry.Get(item.Id);
insuranceJobItem.Edit(item.PercentageLessThan, item.SalaeyLessThan, item.PercentageMoreThan, item.SalaryMoreThan, command.Id);
insuranceJobItem.Edit(item.PercentageLessThan, item.SalaeyLessThan, item.PercentageMoreThan, item.SalaryMoreThan, command.Id,item.StartDate,item.EndDate);
#region JobAndJob

View File

@@ -25,12 +25,19 @@
<label>عنوان صنف و درجه</label>
<input type="text" placeholder="" class="input" id="insuranceJobTitle" asp-for="InsuranceJobTitle" tabindex="1">
</div>
<div class="col-md-12 inputs" style="display: flex;">
<label> کد اقتصادی </label>
<input type="text" placeholder="" class="input" style="direction: rtl;" id="economicCode" asp-for="EconomicCode" tabindex="2">
</div>
<div class="col-md-12 inputs" style="display: flex;">
<label> کد اقتصادی </label>
<input type="text" placeholder="" class="input" style="direction: rtl;" id="economicCode" asp-for="EconomicCode" tabindex="2">
</div>
<div class="col-md-6 inputs">
<input type="text" style="text-align: center" id="fromDate" placeholder="تاریخ شروع" asp-for="StartDateFa" class="input upper-in date">
</div>
<div class="col-md-6 inputs">
<input type="text" style="text-align: center" id="toDate" placeholder="تاریخ پایان" asp-for="EndDateFa" class="input upper-in date" style="direction: rtl;">
</div>
<div class="col-md-12 inputs" id="table-container">
<div class="col-md-12 inputs" id="table-container">
<table id="worksTable" class="table table-bordered table-striped">
<thead style="background-color: #a9fcff">
<tr>
@@ -97,7 +104,8 @@
<script src="~/lib/select2/js/select2.js"></script>
<script src="~/lib/select2/js/i18n/fa.js"></script>
<link href="~/AdminTheme/assets/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
<link href="~/lib/select2/css/select2.css" rel="stylesheet"/>
<link href="~/lib/select2/css/select2.css" rel="stylesheet"/>
<script src="~/AdminTheme/js/numeral.min.js"></script>
//<script src="~/AdminTheme/js/numeral.min.js"></script>
}
<script>
@@ -155,14 +163,65 @@
});
$(document).ready(function() {
$(".date").mask("0000/00/00");
});
$(".date").keyup(function() {
const value = $(this).val();
const lengthValue = value.length;
if (lengthValue == 10) {
if (!dateValidCheck(this)) {
$(this).addClass("errored");
} else {
$(this).removeClass("errored");
}
}
});
function sendData() {
if (!$('#save').is('[disabled=disabled]')) {
const fromDate = $("#fromDate").val();
const toDate = $("#toDate").val();
console.log(fromDate);
console.log(toDate);
var dateError = false
if (fromDate != '' && !checkLength(fromDate, 10)) {
if (!dateValidCheckByValue($("#fromDate"))) {
$("#fromDate").addClass("errored");
dateError = true;
} else {
$("#fromDate").removeClass("errored");
}
}
if (toDate != '' && !checkLength(toDate, 10)) {
if (!dateValidCheckByValue($("#toDate"))) {
$("#toDate").addClass("errored");
dateError = true;
} else {
$("#toDate").removeClass("errored");
}
}
if ((fromDate != '' && checkLength(fromDate, 10)) && (toDate != '' && checkLength(toDate, 10)) && toDate < fromDate) {
dateError = true;
} else if (toDate == fromDate) {
dateError = true;
}
var allInputsFilled = true;
$('.ratioLess, .ratioMore , #EconomicCode , #InsuranceJobTitle').each(function() {
if ($(this).val() === '' || $(this).val() === 0) {
allInputsFilled = false;
$(this).addClass('errored');
} else {
$(this).removeClass('errored');
}
@@ -177,13 +236,18 @@
$(this).removeClass('errored');
}
});
if (!allInputsFilled) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', "لطفا تمام فیلد ها را تکمیل کنید");
} else {
if (!allInputsFilled || dateError) {
$.Notification.autoHideNotify('error', 'top right', 'پیام سیستم ', "لطفا خطاها را برطرف کنید");
}
else {
$('#divData').html('');
$("#save").prop("disabled", true);
$('#divData').append(`<input type="hidden" name="EconomicCode" id="EconomicCode" value="${$("#economicCode").val()}" />`);
$('#divData').append(`<input type="hidden" name="InsuranceJobTitle" id="InsuranceJobTitle" value="${$("#insuranceJobTitle").val()}" />`);
$('#divData').append(`<input type="hidden" name="StartDateFa" id="StartDateFa" value="${$("#fromDate").val()}" />`);
$('#divData').append(`<input type="hidden" name="EndDateFa" id="EndDateFa" value="${$("#toDate").val()}" />`);
$("#worksTable tbody").find('tr').each(function(i) {
const ratioLess = $(this).find("input.ratioLess").val();
@@ -208,14 +272,122 @@
});
// $('#send').click();
$('#createForm').submit();
if (allInputsFilled && !dateError) {
$('#createForm').submit();
}
}
}
}
function checkLength(value, maxLength) {
var lengthValue = value.length;
if (maxLength == lengthValue)
return true;
else
return false;
}
function dateValidCheckByValue(value) {
let persianNumbers = [/۰/g, /۱/g, /۲/g, /۳/g, /۴/g, /۵/g, /۶/g, /۷/g, /۸/g, /۹/g],
arabicNumbers = [/٠/g, /١/g, /٢/g, /٣/g, /٤/g, /٥/g, /٦/g, /٧/g, /٨/g, /٩/g],
fixNumbers = function (str) {
if (typeof str === 'string') {
for (var i = 0; i < 10; i++) {
str = str.replace(persianNumbers[i], i).replace(arabicNumbers[i], i);
}
}
return str;
};
let getdate = value;
//console.log(getdate);
//console.log(getdate.length);
let m1, m2;
let y1, y2, y3, y4;
let d1, d2;
let s1, s2;
for (var i = 0; i < getdate.length; i++) {
if (i === 0) {
y1 = fixNumbers(getdate[i]);
}
if (i === 1) {
y2 = fixNumbers(getdate[i]);
}
if (i === 2) {
y3 = fixNumbers(getdate[i]);
}
if (i === 3) {
y4 = fixNumbers(getdate[i]);
}
if (i === 4) {
s1 = fixNumbers(getdate[i]);
}
if (i === 5) {
m1 = fixNumbers(getdate[i]);
}
if (i === 6) {
m2 = fixNumbers(getdate[i]);
}
if (i === 7) {
s2 = fixNumbers(getdate[i]);
}
if (i === 8) {
d1 = fixNumbers(getdate[i]);
}
if (i === 9) {
d2 = fixNumbers(getdate[i]);
}
}
let yRes = y1 + y2 + y3 + y4;
let year = parseInt(yRes);
let mRes = m1 + m2;
let month = parseInt(mRes);
let dRes = d1 + d2;
let day = parseInt(dRes);
let fixResult = yRes + s1 + mRes + s2 + dRes;
let test1 = checkEnValid(value);
let isValid = /^([1][3-4][0-9][0-9][/])([0][1-9]|[1][0-2])([/])([0][1-9]|[1-2][0-9]|[3][0-1])$/.test(fixResult);
if (isValid && test1) {
//element.style.backgroundColor = '#a6e9a6';
start1valid = true;
} else {
if (value != "") {
//element.style.backgroundColor = '#f94c4c';
//$.Notification.autoHideNotify('error', 'top center', 'پیام سیستم ', "لطفا تاریخ را بصورت صحیح وارد کنید");
start1valid = false;
}
}
return start1valid;
}
function getNumberValue(value) {
var result = '';
for (var i = 0; i < value.length; i++) {
var x = value.charAt(i);
if (x != '٬' && x != ',')
result = result + x;
}
return Number(result);
}
$('#createForm').submit(function(e) {
e.preventDefault();
e.stopImmediatePropagation();

View File

@@ -96,9 +96,11 @@
<table id="datatable" class="table table-striped table-bordered">
<thead>
<tr>
<th style="width: 5px;">#</th>
<th style="width: 5px;">#</th>
<th style="width: 20px;"> سال</th>
<th style="width: 300px;">عنوان صنف و درجه </th>
<th style="width: 200px;"> کد اقتصادی </th>
<th style="width: 180px;"> کد اقتصادی </th>
<th style="width: 300px;">عملیات</th>
</tr>
</thead>
@@ -109,19 +111,26 @@
@foreach (var item in Model.InsuranceJobList)
{
<tr>
<td style="width: 5px;"> @index</td>
<td style="width: 5px;"> @index</td>
<td style="width: 20px;">
<span> @item.Year</span>
</td>
<td style="width: 300px;">
<div class="tooltipfull-container">
<p class="text-ellipsis-name">@item.InsuranceJobTitle</p>
<span class="tooltipfull"> @item.InsuranceJobTitle</span>
</div>
</td>
<td style="width: 200px;">
<div class="tooltipfull-container">
<p class="text-ellipsis-code">@item.EconomicCode</p>
<span class="tooltipfull"> @item.EconomicCode</span>
</div>
</td>
<td style="width: 180px;">
<div class="tooltipfull-container">
<p class="text-ellipsis-code">@item.EconomicCode</p>
<span class="tooltipfull"> @item.EconomicCode</span>
</div>
</td>
<td style="width: 300px;">
<a class="btn btn-danger ionRad pull-left op-btn rad" onclick="removeInsuranceJob(@item.Id)">
<i class="fa fa-trash faSize"></i>