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

@@ -19,7 +19,7 @@
<div class="col-6">
<div class="card">
<h6 class="card-header">
Povezovanje excel z pozicijo
Povezovanje @Model.FileName z pozicijo
</h6>
<div class="card-body">
<input type="hidden" asp-for="IdProjectPart" />
@@ -31,10 +31,10 @@
@{
foreach (var item in Model.ExcelItems)
{
<div class="form-group">
<label class="control-label">@item.Name</label>
<select data-index="@item.CellIndex" class="form-control select-item" asp-items="ViewBag.ProjectPartItems"></select>
</div>
<div class="form-group">
<label class="control-label">@item.Name</label>
<select data-index="@item.CellIndex" class="form-control select-item" asp-items="ViewBag.ProjectPartItems"></select>
</div>
}
}
</div>

View File

@@ -47,6 +47,7 @@ namespace EveryThing.Pages.Projects
[BindProperty]
public string SelectedItems { get; set; }
public IActionResult OnGet(int idProject, int idProjectPart, string fileName)
{
var user = _userManager.GetUserAsync(User).Result;
@@ -67,9 +68,9 @@ namespace EveryThing.Pages.Projects
ViewData["ProjectPartItems"] = new SelectList(tmpList, "Name", "Display");
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
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
var worksheet = xlWorkbook.Worksheet(1);
@@ -157,8 +158,7 @@ namespace EveryThing.Pages.Projects
string value = row.Cell(excelItem.CellIndex).Value.ToString();
if (excelItem.Name == "IdItemFk"
|| excelItem.Name == "IdMaterialFk")
if (excelItem.Name is "IdItemFk" or "IdMaterialFk")
{
var completableItem = _context.CodeTableItems.FirstOrDefault(x => x.Title == value && x.Active == true);
if (completableItem == null)
@@ -178,7 +178,32 @@ namespace EveryThing.Pages.Projects
newPosition.IdItemFk = completableItem.IdItem;
else
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
{
var propertyInfo = newPosition.GetType().GetProperties().First(x => x.Name == excelItem.Name);
@@ -190,7 +215,8 @@ namespace EveryThing.Pages.Projects
await _context.SaveChangesAsync();
i++;
}
System.IO.File.Delete(path);
return RedirectToPage("./Edit", new {id = IdProject});
}

View File

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

View File

@@ -48,80 +48,81 @@
</div>
<div class="card">
<h6 class="card-header">
Seznam projektov
</h6>
<table class="table card-table table-hover">
<thead>
<tr>
<th style="width: 150px;">
@Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted)
</th>
<th style="width: 200px;">
@Html.DisplayNameFor(model => model.Project[0].Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].IdPartnerFk)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].Description)
</th>
<th style="width: 140px">
@Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString)
</th>
<th style="width: 100px">
@Html.DisplayNameFor(model => model.Project[0].Status)
</th>
<th style="width: 110px;"></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Project)
{
<tr data-idproject="@item.IdProject" data-title="@item.Title">
<td>
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
</td>
<td>
<a asp-page="Edit" asp-route-id="@item.IdProject">@Html.DisplayFor(modelItem => item.Title)</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Partner.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstDeliveryDateString)
</td>
<td>
@switch (item.Status)
{
case ProjectStatus.Finished:
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.InProduction:
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.Offer:
<span class='badge badge-default'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
default:
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
}
</td>
<td class="text-right">
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdProject" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a data-idproject="@item.IdProject" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Kopiraj projekt" data-state="secondary" href="javascript:;" onclick="copyProject(this);"><i class="far fa-copy"></i></a>
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteProject(this)" data-toggle="tooltip" data-placement="top" title="Izbriši"><i class="fas fa-times"></i></a>
</td>
<div class="card-body" style="max-height:65vh; overflow-y:auto;">
<table class="table card-table table-hover">
<thead>
<tr>
<th style="width: 150px;">
@Html.DisplayNameFor(model => model.Project[0].ProjectNumberFormatted)
</th>
<th style="width: 200px;">
@Html.DisplayNameFor(model => model.Project[0].Title)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].IdPartnerFk)
</th>
<th>
@Html.DisplayNameFor(model => model.Project[0].Description)
</th>
<th style="width: 140px">
@Html.DisplayNameFor(model => model.Project[0].FirstDeliveryDateString)
</th>
<th style="width: 100px">
@Html.DisplayNameFor(model => model.Project[0].Status)
</th>
<th style="width: 110px;"></th>
</tr>
}
</tbody>
</table>
</thead>
<tbody>
@foreach (var item in Model.Project)
{
<tr data-idproject="@item.IdProject" data-title="@item.Title">
<td>
@Html.DisplayFor(modelItem => item.ProjectNumberFormatted)
</td>
<td>
<a asp-page="Edit" asp-route-id="@item.IdProject">@Html.DisplayFor(modelItem => item.Title)</a>
</td>
<td>
@Html.DisplayFor(modelItem => item.Partner.Title)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.FirstDeliveryDateString)
</td>
<td>
@switch (item.Status)
{
case ProjectStatus.Finished:
<span class='badge badge-success'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.InProduction:
<span class='badge badge-warning'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
case ProjectStatus.Offer:
<span class='badge badge-default'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
default:
<span class='badge badge-info'>@Html.DisplayFor(modelItem => item.Status)</span>
break;
}
</td>
<td class="text-right">
<a class="btn btn-xs icon-btn btn-outline-secondary borderless" asp-page="Edit" asp-route-id="@item.IdProject" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a data-idproject="@item.IdProject" class="btn btn-xs icon-btn btn-outline-secondary borderless" data-toggle="tooltip" data-placement="top" title="Kopiraj projekt" data-state="secondary" href="javascript:;" onclick="copyProject(this);"><i class="far fa-copy"></i></a>
<a class="btn btn-xs icon-btn btn-outline-danger borderless" data-state="danger" href='javascript:;' onclick="deleteProject(this)" data-toggle="tooltip" data-placement="top" title="Izbriši"><i class="fas fa-times"></i></a>
</td>
</tr>
}
</tbody>
</table>
</div>
<div class="card-footer py-3 text-right">
<a asp-page="Create" class="btn btn-primary">Vnos projekta</a>