Uvoz, ce je vec projektov da je scroll bar

This commit is contained in:
2026-02-03 19:07:52 +01:00
parent 980d3ff161
commit 7d64e423c3
14 changed files with 213 additions and 173 deletions

View File

@@ -7,6 +7,13 @@
Layout = "~/Pages/Layouts/_Layout.cshtml"; Layout = "~/Pages/Layouts/_Layout.cshtml";
} }
@section Styles
{
<style type="text/css">
</style>
}
<h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4"> <h4 class="d-flex justify-content-between align-items-center w-100 font-weight-bold py-1 mb-4">
<span> <span>
<span class="text-muted font-weight-light">@switch (@ViewData["Type"]) <span class="text-muted font-weight-light">@switch (@ViewData["Type"])
@@ -21,7 +28,7 @@
<i>Dobavnice</i> <i>Dobavnice</i>
break; break;
case 3: case 3:
<i>Naročila kupcev</i> <i>Naročila ponudbe/kupcev</i>
break; break;
case 4: case 4:
<i>Kooperacije</i> <i>Kooperacije</i>
@@ -34,6 +41,8 @@
</span> </span>
</h4> </h4>
<div class="card">
<div class="card-header">
<div class="row"> <div class="row">
<div class="col-12 mb-2 text-right"> <div class="col-12 mb-2 text-right">
<form method="get"> <form method="get">
@@ -58,11 +67,9 @@
</form> </form>
</div> </div>
</div> </div>
</div>
<div class="card"> <div class="card-body" style="max-height:65vh; overflow-y:auto;">
<table class="table card-table table-hover custom-table">
<table class="table card-table table-hover">
<thead> <thead>
<tr> <tr>
<th style="width: 200px;">#</th> <th style="width: 200px;">#</th>
@@ -128,6 +135,7 @@
} }
</tbody> </tbody>
</table> </table>
</div>
<div class="card-footer py-3 text-right"> <div class="card-footer py-3 text-right">
<a asp-page="Create" asp-route-type="@ViewData["Type"]" class="btn btn-primary">@switch (@ViewData["Type"]) <a asp-page="Create" asp-route-type="@ViewData["Type"]" class="btn btn-primary">@switch (@ViewData["Type"])

View File

@@ -19,7 +19,7 @@
<div class="col-6"> <div class="col-6">
<div class="card"> <div class="card">
<h6 class="card-header"> <h6 class="card-header">
Povezovanje excel z pozicijo Povezovanje @Model.FileName z pozicijo
</h6> </h6>
<div class="card-body"> <div class="card-body">
<input type="hidden" asp-for="IdProjectPart" /> <input type="hidden" asp-for="IdProjectPart" />

View File

@@ -47,6 +47,7 @@ namespace EveryThing.Pages.Projects
[BindProperty] [BindProperty]
public string SelectedItems { get; set; } public string SelectedItems { get; set; }
public IActionResult OnGet(int idProject, int idProjectPart, string fileName) public IActionResult OnGet(int idProject, int idProjectPart, string fileName)
{ {
var user = _userManager.GetUserAsync(User).Result; var user = _userManager.GetUserAsync(User).Result;
@@ -67,9 +68,9 @@ namespace EveryThing.Pages.Projects
ViewData["ProjectPartItems"] = new SelectList(tmpList, "Name", "Display"); ViewData["ProjectPartItems"] = new SelectList(tmpList, "Name", "Display");
ExcelItems = new List<ExcelItem>(); ExcelItems = new List<ExcelItem>();
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads"); var path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "TempExcelImport", fileName);
var xlWorkbook = new XLWorkbook(Path.Combine(path, fileName)); var xlWorkbook = new XLWorkbook(path);
//ONLY FIRST LIST //ONLY FIRST LIST
var worksheet = xlWorkbook.Worksheet(1); var worksheet = xlWorkbook.Worksheet(1);
@@ -120,9 +121,9 @@ namespace EveryThing.Pages.Projects
}); });
} }
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads"); var path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "TempExcelImport", FileName);
var xlWorkbook = new XLWorkbook(Path.Combine(path, FileName)); var xlWorkbook = new XLWorkbook(path);
//ONLY FIRST LIST //ONLY FIRST LIST
var worksheet = xlWorkbook.Worksheet(1); var worksheet = xlWorkbook.Worksheet(1);
@@ -157,8 +158,7 @@ namespace EveryThing.Pages.Projects
string value = row.Cell(excelItem.CellIndex).Value.ToString(); string value = row.Cell(excelItem.CellIndex).Value.ToString();
if (excelItem.Name == "IdItemFk" if (excelItem.Name is "IdItemFk" or "IdMaterialFk")
|| excelItem.Name == "IdMaterialFk")
{ {
var completableItem = _context.CodeTableItems.FirstOrDefault(x => x.Title == value && x.Active == true); var completableItem = _context.CodeTableItems.FirstOrDefault(x => x.Title == value && x.Active == true);
if (completableItem == null) if (completableItem == null)
@@ -179,6 +179,31 @@ namespace EveryThing.Pages.Projects
else else
newPosition.IdMaterialFk = completableItem.IdItem; newPosition.IdMaterialFk = completableItem.IdItem;
} }
else if (excelItem.Name is "IdMaterialSupplierFk")
{
var tmpPartner = _context.CodeTablePartners.FirstOrDefault(x => x.Title == value && x.Active == true);
if (tmpPartner == null)
{
//Add new if not exists
tmpPartner = new CodeTablePartner()
{
Active = true,
IdCompanyFk = user.IdCompanyFk,
Title = value,
Supplier = true,
IdCountryFk = _context.CodeTableCountries.First(x => x.Code == "SI").IdCountry,
City = "",
Street = "",
HouseNumber = "",
PostNumber = 0,
Post = "",
};
_context.CodeTablePartners.Add(tmpPartner);
await _context.SaveChangesAsync();
}
newPosition.IdMaterialSupplierFk = tmpPartner.IdPartner;
}
else else
{ {
var propertyInfo = newPosition.GetType().GetProperties().First(x => x.Name == excelItem.Name); var propertyInfo = newPosition.GetType().GetProperties().First(x => x.Name == excelItem.Name);
@@ -191,6 +216,7 @@ namespace EveryThing.Pages.Projects
i++; i++;
} }
System.IO.File.Delete(path);
return RedirectToPage("./Edit", new {id = IdProject}); return RedirectToPage("./Edit", new {id = IdProject});
} }

View File

@@ -104,21 +104,26 @@ namespace EveryThing.Pages.Projects
{ {
return Page();//TODO return error return Page();//TODO return error
} }
string path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads"); var path = Path.Combine(_hostingEnvironment.WebRootPath, "Uploads", "TempExcelImport");
if (!Directory.Exists(path)) if (!Directory.Exists(path))
{ {
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
else
List<string> uploadedFiles = new List<string>(); {
//Pocistimo mapo
foreach (var fileInfo in new DirectoryInfo(path).GetFiles("*.*"))
{
fileInfo.Delete();
}
}
var postedFile = postedFiles[0]; var postedFile = postedFiles[0];
string fileName = Guid.NewGuid().ToString().Replace("-", "_") + Path.GetExtension(postedFile.FileName); var fileName = postedFile.FileName;//Guid.NewGuid().ToString().Replace("-", "_") + Path.GetExtension(postedFile.FileName);
using (FileStream stream = new FileStream(Path.Combine(path, fileName), FileMode.Create)) await using (var stream = new FileStream(Path.Combine(path, fileName), FileMode.Create))
{ {
postedFile.CopyTo(stream); await postedFile.CopyToAsync(stream);
uploadedFiles.Add(fileName);
} }
return RedirectToPage("./CreatePartItemImportExcel", new { idProject = idProject, idProjectPart = idProjectPart, fileName = fileName}); return RedirectToPage("./CreatePartItemImportExcel", new { idProject = idProject, idProjectPart = idProjectPart, fileName = fileName});
} }

View File

@@ -48,11 +48,11 @@
</div> </div>
<div class="card"> <div class="card">
<h6 class="card-header"> <h6 class="card-header">
Seznam projektov Seznam projektov
</h6> </h6>
<div class="card-body" style="max-height:65vh; overflow-y:auto;">
<table class="table card-table table-hover"> <table class="table card-table table-hover">
<thead> <thead>
<tr> <tr>
@@ -122,6 +122,7 @@
} }
</tbody> </tbody>
</table> </table>
</div>
<div class="card-footer py-3 text-right"> <div class="card-footer py-3 text-right">
<a asp-page="Create" class="btn btn-primary">Vnos projekta</a> <a asp-page="Create" class="btn btn-primary">Vnos projekta</a>