MoveAllViews
This commit is contained in:
parent
bdd5f28535
commit
da20060b05
@ -23,7 +23,10 @@ namespace DatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login)) { return null; }
|
if (!model.Id.HasValue && string.IsNullOrEmpty(model.Login)) { return null; }
|
||||||
using var context = new FactoryGoWorkDatabase();
|
using var context = new FactoryGoWorkDatabase();
|
||||||
return context.Implementers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && x.Login.Equals(model.Login) && x.Password.Equals(model.Password)))?.GetViewModel; ;
|
if (!string.IsNullOrEmpty(model.Login) && string.IsNullOrEmpty(model.Password))
|
||||||
|
return context.Implementers.FirstOrDefault(x => x.Login == model.Login)?.GetViewModel;
|
||||||
|
else
|
||||||
|
return context.Implementers.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id) || (!string.IsNullOrEmpty(model.Login) && !string.IsNullOrEmpty(model.Password) && x.Login.Equals(model.Login) && x.Password.Equals(model.Password)))?.GetViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
public List<ImplementerViewModel> GetFilteredList(ImplementerSearchModel model)
|
||||||
|
77
Course/ImplementerApp/Controllers/DetailController.cs
Normal file
77
Course/ImplementerApp/Controllers/DetailController.cs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ImplementerApp.Controllers
|
||||||
|
{
|
||||||
|
public class DetailController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<DetailController> _logger;
|
||||||
|
private readonly ImplementerData _data;
|
||||||
|
public DetailController(ILogger<DetailController> logger, ImplementerData data)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
private bool IsLoggedIn { get { return UserImplementer.user != null; } }
|
||||||
|
private int UserId { get { return UserImplementer.user!.Id; } }
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult IndexDetail()
|
||||||
|
{
|
||||||
|
if (UserImplementer.user != null)
|
||||||
|
{
|
||||||
|
var list = _data.GetDetails(UserImplementer.user.Id);
|
||||||
|
if (list != null)
|
||||||
|
return View(list);
|
||||||
|
return View(new List<DetailViewModel>());
|
||||||
|
}
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void IndexDetail(int id)
|
||||||
|
{
|
||||||
|
if (UserImplementer.user != null)
|
||||||
|
{
|
||||||
|
_data.DeleteDetail(id);
|
||||||
|
}
|
||||||
|
Response.Redirect("IndexDetail");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateDetail(int id)
|
||||||
|
{
|
||||||
|
if (id != 0)
|
||||||
|
{
|
||||||
|
var value = _data.GetDetail(id);
|
||||||
|
if (value != null)
|
||||||
|
return View(value);
|
||||||
|
}
|
||||||
|
return View(new DetailViewModel());
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateDetail(DetailBindingModel model)
|
||||||
|
{
|
||||||
|
if (model.Id == 0)
|
||||||
|
{
|
||||||
|
model.DateCreate = DateTime.Now;
|
||||||
|
model.UserId = UserImplementer.user!.Id;
|
||||||
|
if (_data.CreateDetail(model))
|
||||||
|
return RedirectToAction("IndexDetail");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_data.UpdateDetail(model))
|
||||||
|
return RedirectToAction("IndexDetail");
|
||||||
|
}
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,8 @@ namespace ImplementerApp.Controllers
|
|||||||
}
|
}
|
||||||
private bool IsLoggedIn { get { return UserImplementer.user != null; } }
|
private bool IsLoggedIn { get { return UserImplementer.user != null; } }
|
||||||
private int UserId { get { return UserImplementer.user!.Id; } }
|
private int UserId { get { return UserImplementer.user!.Id; } }
|
||||||
|
|
||||||
|
|
||||||
public IActionResult IndexNonReg()
|
public IActionResult IndexNonReg()
|
||||||
{
|
{
|
||||||
if (!IsLoggedIn)
|
if (!IsLoggedIn)
|
||||||
@ -49,6 +51,7 @@ namespace ImplementerApp.Controllers
|
|||||||
UserImplementer.user = user;
|
UserImplementer.user = user;
|
||||||
Response.Redirect("Index");
|
Response.Redirect("Index");
|
||||||
}
|
}
|
||||||
|
Response.Redirect("Enter");
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult Register()
|
public IActionResult Register()
|
||||||
@ -69,178 +72,6 @@ namespace ImplementerApp.Controllers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public IActionResult IndexDetail()
|
|
||||||
{
|
|
||||||
if (UserImplementer.user != null)
|
|
||||||
{
|
|
||||||
var list = _data.GetDetails(UserImplementer.user.Id);
|
|
||||||
if (list != null)
|
|
||||||
return View(list);
|
|
||||||
return View(new List<DetailViewModel>());
|
|
||||||
}
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void IndexDetail(int id)
|
|
||||||
{
|
|
||||||
if (UserImplementer.user != null)
|
|
||||||
{
|
|
||||||
_data.DeleteDetail(id);
|
|
||||||
}
|
|
||||||
Response.Redirect("IndexDetail");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult CreateDetail(int id)
|
|
||||||
{
|
|
||||||
if (id != 0)
|
|
||||||
{
|
|
||||||
var value = _data.GetDetail(id);
|
|
||||||
if (value != null)
|
|
||||||
return View(value);
|
|
||||||
}
|
|
||||||
return View(new DetailViewModel());
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult CreateDetail(DetailBindingModel model)
|
|
||||||
{
|
|
||||||
if (model.Id == 0)
|
|
||||||
{
|
|
||||||
model.DateCreate = DateTime.Now;
|
|
||||||
model.UserId = UserImplementer.user!.Id;
|
|
||||||
if (_data.CreateDetail(model))
|
|
||||||
return RedirectToAction("IndexDetail");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_data.UpdateDetail(model))
|
|
||||||
return RedirectToAction("IndexDetail");
|
|
||||||
}
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult IndexProduct()
|
|
||||||
{
|
|
||||||
if (IsLoggedIn) {
|
|
||||||
var products = _data.GetProducts(UserImplementer.user!.Id);
|
|
||||||
return View(products);
|
|
||||||
}
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult IndexProduct(int id)
|
|
||||||
{
|
|
||||||
_data.DeleteProduct(id);
|
|
||||||
return RedirectToAction("IndexProduct");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult CreateProduct(int id)
|
|
||||||
{
|
|
||||||
var details = _data.GetDetails(UserImplementer.user!.Id);
|
|
||||||
ViewBag.AllDetails = details;
|
|
||||||
if (id != 0)
|
|
||||||
{
|
|
||||||
var value = _data.GetProduct(id);
|
|
||||||
if (value != null)
|
|
||||||
return View(value);
|
|
||||||
}
|
|
||||||
return View(new ProductViewModel());
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult CreateProduct(int id, string title, int[] detailIds, int[] counts)
|
|
||||||
{
|
|
||||||
ProductBindingModel model = new ProductBindingModel();
|
|
||||||
model.Id = id;
|
|
||||||
model.Name = title;
|
|
||||||
model.UserId = UserImplementer.user!.Id;
|
|
||||||
var details = _data.GetDetails(UserImplementer.user!.Id);
|
|
||||||
double sum = 0;
|
|
||||||
for (int i = 0; i < detailIds.Length; i++)
|
|
||||||
{
|
|
||||||
var detail = details!.FirstOrDefault(x => x.Id == detailIds[i])!;
|
|
||||||
if (counts[i] <= 0)
|
|
||||||
continue;
|
|
||||||
model.ProductDetails[detailIds[i]] = (detail, counts[i]);
|
|
||||||
sum += detail.Cost * counts[i];
|
|
||||||
}
|
|
||||||
if (model.ProductDetails.Count == 0)
|
|
||||||
return RedirectToAction("IndexProduct");
|
|
||||||
model.Cost = sum;
|
|
||||||
if (id != 0)
|
|
||||||
{
|
|
||||||
_data.UpdateProduct(model);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_data.CreateProduct(model);
|
|
||||||
}
|
|
||||||
return RedirectToAction("IndexProduct");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult IndexProduction()
|
|
||||||
{
|
|
||||||
if (UserImplementer.user != null)
|
|
||||||
{
|
|
||||||
var productions = _data.GetProductions(UserImplementer.user.Id);
|
|
||||||
return View(productions);
|
|
||||||
}
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult IndexProduction(int id)
|
|
||||||
{
|
|
||||||
_data.DeleteProduction(id);
|
|
||||||
return RedirectToAction("IndexProduction");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult CreateProduction(int id)
|
|
||||||
{
|
|
||||||
var details = _data.GetDetails(UserImplementer.user!.Id);
|
|
||||||
ViewBag.AllDetails = details;
|
|
||||||
if (id != 0)
|
|
||||||
{
|
|
||||||
var value = _data.GetProduction(id);
|
|
||||||
if (value != null)
|
|
||||||
return View(value);
|
|
||||||
}
|
|
||||||
return View(new ProductionViewModel());
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult CreateProduction(int id, string title, int[] detailIds)
|
|
||||||
{
|
|
||||||
ProductionBindingModel model = new ProductionBindingModel();
|
|
||||||
model.Id = id;
|
|
||||||
model.Name = title;
|
|
||||||
model.UserId = UserImplementer.user!.Id;
|
|
||||||
var details = _data.GetDetails(UserImplementer.user!.Id);
|
|
||||||
double sum = 0;
|
|
||||||
for (int i = 0; i < detailIds.Length; i++)
|
|
||||||
{
|
|
||||||
var detail = details!.FirstOrDefault(x => x.Id == detailIds[i])!;
|
|
||||||
model.ProductionDetails[detailIds[i]] = detail;
|
|
||||||
sum += detail.Cost;
|
|
||||||
}
|
|
||||||
model.Cost = sum;
|
|
||||||
bool changed = false;
|
|
||||||
if (model.ProductionDetails.Count > 0)
|
|
||||||
{
|
|
||||||
if (id != 0)
|
|
||||||
{
|
|
||||||
changed = _data.UpdateProduction(model);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
changed = _data.CreateProduction(model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (changed)
|
|
||||||
return RedirectToAction("IndexProduction");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ViewBag.AllDetails = details;
|
|
||||||
return View(model);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult Privacy()
|
public IActionResult Privacy()
|
||||||
{
|
{
|
||||||
if (IsLoggedIn)
|
if (IsLoggedIn)
|
||||||
@ -259,158 +90,11 @@ namespace ImplementerApp.Controllers
|
|||||||
}
|
}
|
||||||
return View(user);
|
return View(user);
|
||||||
}
|
}
|
||||||
[HttpGet]
|
|
||||||
public IActionResult DetailTimeChoose()
|
|
||||||
{
|
|
||||||
if (!IsLoggedIn)
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult SendReport(DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
|
|
||||||
return Ok();
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
if (!IsLoggedIn)
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
|
|
||||||
|
|
||||||
HttpContext.Session.SetString("StartDate", startDate.ToString());
|
|
||||||
HttpContext.Session.SetString("EndDate", endDate.ToString());
|
|
||||||
|
|
||||||
return RedirectToAction("DetailTimeReport");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult DetailTimeReport()
|
|
||||||
{
|
|
||||||
var startDateStr = HttpContext.Session.GetString("StartDate");
|
|
||||||
var endDateStr = HttpContext.Session.GetString("EndDate");
|
|
||||||
var startDate = DateTime.Parse(startDateStr);
|
|
||||||
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
|
||||||
|
|
||||||
var values = _data.GetTimeReport(startDate, endDate, UserId);
|
|
||||||
|
|
||||||
ViewBag.StartDate = startDate;
|
|
||||||
ViewBag.EndDate = endDate;
|
|
||||||
|
|
||||||
return View(values);
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public void DetailTimeMail()
|
|
||||||
{
|
|
||||||
var startDateStr = HttpContext.Session.GetString("StartDate");
|
|
||||||
var endDateStr = HttpContext.Session.GetString("EndDate");
|
|
||||||
var startDate = DateTime.Parse(startDateStr);
|
|
||||||
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
|
||||||
using (MemoryStream memoryStream = new MemoryStream()) {
|
|
||||||
_data.SendMailReport(startDate, endDate, UserId, memoryStream);
|
|
||||||
}
|
|
||||||
Response.Redirect("DetailTimeReport");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult DetailWorkshopChoose()
|
|
||||||
{
|
|
||||||
if (!IsLoggedIn)
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
var details = _data.GetDetails(UserId);
|
|
||||||
return View(details);
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult DetailWorkshopChoose(List<int> selectedItems, string reportType)
|
|
||||||
{
|
|
||||||
string value = string.Join("/", selectedItems);
|
|
||||||
HttpContext.Session.SetString("Details", value);
|
|
||||||
if (reportType.Equals("default"))
|
|
||||||
return RedirectToAction("DetailWorkshopReport");
|
|
||||||
else if (reportType.Equals("excel"))
|
|
||||||
return RedirectToAction("ExcelGenerate");
|
|
||||||
else
|
|
||||||
return RedirectToAction("WordGenerate");
|
|
||||||
}
|
|
||||||
public async Task<IActionResult> ExcelGenerate()
|
|
||||||
{
|
|
||||||
var value = HttpContext.Session.GetString("Details");
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
_data.SaveReportExcel(rawReports, memoryStream);
|
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
|
||||||
var outputStream = new MemoryStream();
|
|
||||||
await memoryStream.CopyToAsync(outputStream);
|
|
||||||
outputStream.Seek(0, SeekOrigin.Begin);
|
|
||||||
return File(outputStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ReportExcel.xlsx");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return RedirectToAction("DetailWorkshopChoose");
|
|
||||||
}
|
|
||||||
public async Task<IActionResult> WordGenerate()
|
|
||||||
{
|
|
||||||
var value = HttpContext.Session.GetString("Details");
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
|
||||||
using (MemoryStream memoryStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
_data.SaveReportWord(rawReports, memoryStream);
|
|
||||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
|
||||||
var outputStream = new MemoryStream();
|
|
||||||
await memoryStream.CopyToAsync(outputStream);
|
|
||||||
outputStream.Seek(0, SeekOrigin.Begin);
|
|
||||||
return File(outputStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ReportWord.docx");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return RedirectToAction("DetailWorkshopChoose");
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult DetailWorkshopReport()
|
|
||||||
{
|
|
||||||
var value = HttpContext.Session.GetString("Details");
|
|
||||||
if (value != null)
|
|
||||||
{
|
|
||||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
|
||||||
var reports = _data.GetWorkshopReports(rawReports);
|
|
||||||
return View(reports);
|
|
||||||
}
|
|
||||||
return View(new List<DetailWorkshopReportViewModel>());
|
|
||||||
}
|
|
||||||
public IActionResult ReportsMenu()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
[HttpGet]
|
|
||||||
public IActionResult ProductMachineAdd(int id)
|
|
||||||
{
|
|
||||||
if (!IsLoggedIn)
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
var product = _data.GetProduct(id);
|
|
||||||
ViewBag.Product = product;
|
|
||||||
var machines = _data.GetMachines();
|
|
||||||
return View(machines);
|
|
||||||
}
|
|
||||||
[HttpPost]
|
|
||||||
public IActionResult ProductMachineAdd(int productId, int machineId)
|
|
||||||
{
|
|
||||||
if (!IsLoggedIn)
|
|
||||||
return RedirectToAction("IndexNonReg");
|
|
||||||
var product = _data.GetProduct(productId);
|
|
||||||
if (product == null)
|
|
||||||
return RedirectToAction("Index");
|
|
||||||
ProductBindingModel productBinding = new() { Id = productId, Cost = product.Cost, Name = product.Name, UserId = product.UserId, ProductDetails = product.DetailProducts, MachineId = machineId };
|
|
||||||
_data.UpdateProduct(productBinding);
|
|
||||||
return RedirectToAction("IndexProduct");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
public IActionResult Error()
|
public IActionResult Error()
|
||||||
{
|
{
|
||||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
return View();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
118
Course/ImplementerApp/Controllers/ProductController.cs
Normal file
118
Course/ImplementerApp/Controllers/ProductController.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ImplementerApp.Controllers
|
||||||
|
{
|
||||||
|
public class ProductController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<ProductController> _logger;
|
||||||
|
private readonly ImplementerData _data;
|
||||||
|
public ProductController(ILogger<ProductController> logger, ImplementerData data)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
private bool IsLoggedIn { get { return UserImplementer.user != null; } }
|
||||||
|
private int UserId { get { return UserImplementer.user!.Id; } }
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult IndexProduct()
|
||||||
|
{
|
||||||
|
if (IsLoggedIn)
|
||||||
|
{
|
||||||
|
var products = _data.GetProducts(UserImplementer.user!.Id);
|
||||||
|
return View(products);
|
||||||
|
}
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult IndexProduct(int id)
|
||||||
|
{
|
||||||
|
_data.DeleteProduct(id);
|
||||||
|
return RedirectToAction("IndexProduct");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateProduct(int id)
|
||||||
|
{
|
||||||
|
var details = _data.GetDetails(UserImplementer.user!.Id);
|
||||||
|
ViewBag.AllDetails = details;
|
||||||
|
if (id != 0)
|
||||||
|
{
|
||||||
|
var value = _data.GetProduct(id);
|
||||||
|
if (value != null)
|
||||||
|
return View(value);
|
||||||
|
}
|
||||||
|
return View(new ProductViewModel());
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateProduct(int id, string title, int[] detailIds, int[] counts)
|
||||||
|
{
|
||||||
|
ProductBindingModel model = new ProductBindingModel();
|
||||||
|
model.Id = id;
|
||||||
|
model.Name = title;
|
||||||
|
model.UserId = UserImplementer.user!.Id;
|
||||||
|
var details = _data.GetDetails(UserImplementer.user!.Id);
|
||||||
|
double sum = 0;
|
||||||
|
for (int i = 0; i < detailIds.Length; i++)
|
||||||
|
{
|
||||||
|
var detail = details!.FirstOrDefault(x => x.Id == detailIds[i])!;
|
||||||
|
if (counts[i] <= 0)
|
||||||
|
continue;
|
||||||
|
model.ProductDetails[detailIds[i]] = (detail, counts[i]);
|
||||||
|
sum += detail.Cost * counts[i];
|
||||||
|
}
|
||||||
|
if (model.ProductDetails.Count == 0)
|
||||||
|
return RedirectToAction("IndexProduct");
|
||||||
|
model.Cost = sum;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (id != 0)
|
||||||
|
{
|
||||||
|
_data.UpdateProduct(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_data.CreateProduct(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
ViewBag.ErrorMessage = "Такое название изделия уже существует";
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
return RedirectToAction("IndexProduct");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult ProductMachineAdd(int id)
|
||||||
|
{
|
||||||
|
if (!IsLoggedIn)
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
var product = _data.GetProduct(id);
|
||||||
|
ViewBag.Product = product;
|
||||||
|
var machines = _data.GetMachines();
|
||||||
|
return View(machines);
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult ProductMachineAdd(int productId, int machineId)
|
||||||
|
{
|
||||||
|
if (!IsLoggedIn)
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
var product = _data.GetProduct(productId);
|
||||||
|
if (product == null)
|
||||||
|
return RedirectToAction("Index");
|
||||||
|
ProductBindingModel productBinding = new() { Id = productId, Cost = product.Cost, Name = product.Name, UserId = product.UserId, ProductDetails = product.DetailProducts, MachineId = machineId };
|
||||||
|
_data.UpdateProduct(productBinding);
|
||||||
|
return RedirectToAction("IndexProduct");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
Course/ImplementerApp/Controllers/ProductionController.cs
Normal file
93
Course/ImplementerApp/Controllers/ProductionController.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using Contracts.BindingModels;
|
||||||
|
using Contracts.ViewModels;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ImplementerApp.Controllers
|
||||||
|
{
|
||||||
|
public class ProductionController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<ProductionController> _logger;
|
||||||
|
private readonly ImplementerData _data;
|
||||||
|
public ProductionController(ILogger<ProductionController> logger, ImplementerData data)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
private bool IsLoggedIn { get { return UserImplementer.user != null; } }
|
||||||
|
private int UserId { get { return UserImplementer.user!.Id; } }
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult IndexProduction()
|
||||||
|
{
|
||||||
|
if (UserImplementer.user != null)
|
||||||
|
{
|
||||||
|
var productions = _data.GetProductions(UserImplementer.user.Id);
|
||||||
|
return View(productions);
|
||||||
|
}
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult IndexProduction(int id)
|
||||||
|
{
|
||||||
|
_data.DeleteProduction(id);
|
||||||
|
return RedirectToAction("IndexProduction");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult CreateProduction(int id)
|
||||||
|
{
|
||||||
|
var details = _data.GetDetails(UserImplementer.user!.Id);
|
||||||
|
ViewBag.AllDetails = details;
|
||||||
|
if (id != 0)
|
||||||
|
{
|
||||||
|
var value = _data.GetProduction(id);
|
||||||
|
if (value != null)
|
||||||
|
return View(value);
|
||||||
|
}
|
||||||
|
return View(new ProductionViewModel());
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult CreateProduction(int id, string title, int[] detailIds)
|
||||||
|
{
|
||||||
|
ProductionBindingModel model = new ProductionBindingModel();
|
||||||
|
model.Id = id;
|
||||||
|
model.Name = title;
|
||||||
|
model.UserId = UserImplementer.user!.Id;
|
||||||
|
var details = _data.GetDetails(UserImplementer.user!.Id);
|
||||||
|
double sum = 0;
|
||||||
|
for (int i = 0; i < detailIds.Length; i++)
|
||||||
|
{
|
||||||
|
var detail = details!.FirstOrDefault(x => x.Id == detailIds[i])!;
|
||||||
|
model.ProductionDetails[detailIds[i]] = detail;
|
||||||
|
sum += detail.Cost;
|
||||||
|
}
|
||||||
|
model.Cost = sum;
|
||||||
|
bool changed = false;
|
||||||
|
if (model.ProductionDetails.Count > 0)
|
||||||
|
{
|
||||||
|
if (id != 0)
|
||||||
|
{
|
||||||
|
changed = _data.UpdateProduction(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
changed = _data.CreateProduction(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changed)
|
||||||
|
return RedirectToAction("IndexProduction");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ViewBag.AllDetails = details;
|
||||||
|
return View(model);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
153
Course/ImplementerApp/Controllers/ReportController.cs
Normal file
153
Course/ImplementerApp/Controllers/ReportController.cs
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
using Contracts.ViewModels;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ImplementerApp.Controllers
|
||||||
|
{
|
||||||
|
public class ReportController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<ReportController> _logger;
|
||||||
|
private readonly ImplementerData _data;
|
||||||
|
public ReportController(ILogger<ReportController> logger, ImplementerData data)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_data = data;
|
||||||
|
}
|
||||||
|
private bool IsLoggedIn { get { return UserImplementer.user != null; } }
|
||||||
|
private int UserId { get { return UserImplementer.user!.Id; } }
|
||||||
|
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DetailTimeChoose()
|
||||||
|
{
|
||||||
|
if (!IsLoggedIn)
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult SendReport(DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
|
||||||
|
return Ok();
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult TimeReportWeb(DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
if (!IsLoggedIn)
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
|
||||||
|
|
||||||
|
HttpContext.Session.SetString("StartDate", startDate.ToString());
|
||||||
|
HttpContext.Session.SetString("EndDate", endDate.ToString());
|
||||||
|
|
||||||
|
return RedirectToAction("DetailTimeReport");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DetailTimeReport()
|
||||||
|
{
|
||||||
|
var startDateStr = HttpContext.Session.GetString("StartDate");
|
||||||
|
var endDateStr = HttpContext.Session.GetString("EndDate");
|
||||||
|
var startDate = DateTime.Parse(startDateStr);
|
||||||
|
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
||||||
|
|
||||||
|
var values = _data.GetTimeReport(startDate, endDate, UserId);
|
||||||
|
|
||||||
|
ViewBag.StartDate = startDate;
|
||||||
|
ViewBag.EndDate = endDate;
|
||||||
|
|
||||||
|
return View(values);
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void DetailTimeMail()
|
||||||
|
{
|
||||||
|
var startDateStr = HttpContext.Session.GetString("StartDate");
|
||||||
|
var endDateStr = HttpContext.Session.GetString("EndDate");
|
||||||
|
var startDate = DateTime.Parse(startDateStr);
|
||||||
|
var endDate = DateTime.Parse(endDateStr).AddDays(1);
|
||||||
|
using (MemoryStream memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
_data.SendMailReport(startDate, endDate, UserId, memoryStream);
|
||||||
|
}
|
||||||
|
Response.Redirect("DetailTimeReport");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DetailWorkshopChoose()
|
||||||
|
{
|
||||||
|
if (!IsLoggedIn)
|
||||||
|
return RedirectToAction("IndexNonReg");
|
||||||
|
var details = _data.GetDetails(UserId);
|
||||||
|
return View(details);
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult DetailWorkshopChoose(List<int> selectedItems, string reportType)
|
||||||
|
{
|
||||||
|
string value = string.Join("/", selectedItems);
|
||||||
|
HttpContext.Session.SetString("Details", value);
|
||||||
|
if (reportType.Equals("default"))
|
||||||
|
return RedirectToAction("DetailWorkshopReport");
|
||||||
|
else if (reportType.Equals("excel"))
|
||||||
|
return RedirectToAction("ExcelGenerate");
|
||||||
|
else
|
||||||
|
return RedirectToAction("WordGenerate");
|
||||||
|
}
|
||||||
|
public async Task<IActionResult> ExcelGenerate()
|
||||||
|
{
|
||||||
|
var value = HttpContext.Session.GetString("Details");
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||||
|
using (MemoryStream memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
_data.SaveReportExcel(rawReports, memoryStream);
|
||||||
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
var outputStream = new MemoryStream();
|
||||||
|
await memoryStream.CopyToAsync(outputStream);
|
||||||
|
outputStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return File(outputStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "ReportExcel.xlsx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RedirectToAction("DetailWorkshopChoose");
|
||||||
|
}
|
||||||
|
public async Task<IActionResult> WordGenerate()
|
||||||
|
{
|
||||||
|
var value = HttpContext.Session.GetString("Details");
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||||
|
using (MemoryStream memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
_data.SaveReportWord(rawReports, memoryStream);
|
||||||
|
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
var outputStream = new MemoryStream();
|
||||||
|
await memoryStream.CopyToAsync(outputStream);
|
||||||
|
outputStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return File(outputStream, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "ReportWord.docx");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return RedirectToAction("DetailWorkshopChoose");
|
||||||
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult DetailWorkshopReport()
|
||||||
|
{
|
||||||
|
var value = HttpContext.Session.GetString("Details");
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||||
|
var reports = _data.GetWorkshopReports(rawReports);
|
||||||
|
return View(reports);
|
||||||
|
}
|
||||||
|
return View(new List<DetailWorkshopReportViewModel>());
|
||||||
|
}
|
||||||
|
public IActionResult ReportsMenu()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -64,6 +64,10 @@ namespace ImplementerApp
|
|||||||
{
|
{
|
||||||
return _implementerLogic.Update(model);
|
return _implementerLogic.Update(model);
|
||||||
}
|
}
|
||||||
|
public bool CheckLogin(string login)
|
||||||
|
{
|
||||||
|
return _implementerLogic.ReadElement(new() { Login = login }) == null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<DetailViewModel>? GetDetails(int userId)
|
public List<DetailViewModel>? GetDetails(int userId)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Деталь</h2>
|
<h2 class="display-4">Деталь</h2>
|
||||||
</div>
|
</div>
|
||||||
<form id="detailForm" method="post">
|
<form id="detailForm" asp-controller="Detail" method="post">
|
||||||
<input type="text" name="id" id="id" value="@Model.Id" hidden="hidden" />
|
<input type="text" name="id" id="id" value="@Model.Id" hidden="hidden" />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<div class="col-4">Название:</div>
|
@ -18,7 +18,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="CreateDetail" asp-route-id="0">Создать деталь</a>
|
<a asp-action="CreateDetail" asp-controller="Detail" asp-route-id="0">Создать деталь</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -54,10 +54,10 @@
|
|||||||
@Html.DisplayFor(modelItem => item.Cost)
|
@Html.DisplayFor(modelItem => item.Cost)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="CreateDetail" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
<a asp-action="CreateDetail" asp-controller="Detail" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post">
|
<form asp-controller="Detail" method="post">
|
||||||
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden"/>
|
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden"/>
|
||||||
<input type="submit" class="btn btn-danger" value="Удалить"/>
|
<input type="submit" class="btn btn-danger" value="Удалить"/>
|
||||||
</form>
|
</form>
|
@ -5,7 +5,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Вход в приложение</h2>
|
<h2 class="display-4">Вход в приложение</h2>
|
||||||
</div>
|
</div>
|
||||||
<form method="post">
|
<form asp-controller="Home" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Логин:</div>
|
<div class="col-4">Логин:</div>
|
||||||
<div class="col-8"><input type="text" name="login" /></div>
|
<div class="col-8"><input type="text" name="login" /></div>
|
||||||
|
@ -5,12 +5,11 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h1 class="display-4">Главное меню</h1>
|
<h1 class="display-4">Главное меню</h1>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexDetail">Детали</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Detail" asp-action="IndexDetail">Детали</a>
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexProduct">Изделия</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Product" asp-action="IndexProduct">Изделия</a>
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexProduction">Производства</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Production" asp-action="IndexProduction">Производства</a>
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ReportsMenu">Меню отчетов</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Report" asp-action="ReportsMenu">Меню отчетов</a>
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выйти</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выйти</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Личные данные</h2>
|
<h2 class="display-4">Личные данные</h2>
|
||||||
</div>
|
</div>
|
||||||
<form id="clientForm" method="post">
|
<form id="clientForm" asp-controller="Home" method="post">
|
||||||
<input type="text" name="id" id="id" value="@Model.Id" hidden="hidden"/>
|
<input type="text" name="id" id="id" value="@Model.Id" hidden="hidden"/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Логин:</div>
|
<div class="col-4">Логин:</div>
|
||||||
@ -28,9 +28,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">ФИО:</div>
|
<div class="col-4">Имя:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<input type="text" name="fio" id="fio" value="@Model.Name" />
|
<input type="text" name="name" id="name" value="@Model.Name" />
|
||||||
<span id="fioError" class="text-danger"></span>
|
<span id="fioError" class="text-danger"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -47,7 +47,7 @@
|
|||||||
var login = $('#login').val();
|
var login = $('#login').val();
|
||||||
var email = $('#email').val();
|
var email = $('#email').val();
|
||||||
var password = $('#password').val();
|
var password = $('#password').val();
|
||||||
var fio = $('#fio').val();
|
var fio = $('#name').val();
|
||||||
var isValid = true;
|
var isValid = true;
|
||||||
|
|
||||||
$('#loginError').text('');
|
$('#loginError').text('');
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Регистрация</h2>
|
<h2 class="display-4">Регистрация</h2>
|
||||||
</div>
|
</div>
|
||||||
<form id="registerForm" method="post">
|
<form id="registerForm" asp-controller="Home" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Имя:</div>
|
<div class="col-4">Имя:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
@ -50,6 +50,26 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
$('#login').blur(function () {
|
||||||
|
var login = $('#login').val();
|
||||||
|
if (login.length >= 5 && login.length <= 50) {
|
||||||
|
$.ajax({
|
||||||
|
url: '@Url.Action("CheckLoginUnique", "YourController")',
|
||||||
|
type: 'POST',
|
||||||
|
data: { login: login },
|
||||||
|
success: function (response) {
|
||||||
|
if (!response.isUnique) {
|
||||||
|
$('#loginError').text('Логин уже используется.');
|
||||||
|
} else {
|
||||||
|
$('#loginError').text('');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function () {
|
||||||
|
$('#loginError').text('Ошибка при проверке уникальности логина.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
$('#registerForm').submit(function(event) {
|
$('#registerForm').submit(function(event) {
|
||||||
var name = $('#name').val();
|
var name = $('#name').val();
|
||||||
var login = $('#login').val();
|
var login = $('#login').val();
|
||||||
@ -77,7 +97,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Валидация почты
|
// Валидация почты
|
||||||
var emailPattern = /^[a-zA-Z0-9._-]+@@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
||||||
if (!emailPattern.test(email)) {
|
if (!emailPattern.test(email)) {
|
||||||
$('#emailError').text('Неверный формат почты.');
|
$('#emailError').text('Неверный формат почты.');
|
||||||
isValid = false;
|
isValid = false;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Создание изделия</h2>
|
<h2 class="display-4">Создание изделия</h2>
|
||||||
</div>
|
</div>
|
||||||
<form id="productForm" method="post">
|
<form id="productForm" asp-controller="Product" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<div class="col-4">Название:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
@ -18,7 +18,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="CreateProduct" asp-route-id="0">Создать изделие</a>
|
<a asp-action="CreateProduct" asp-controller="Product" asp-route-id="0">Создать изделие</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -63,13 +63,13 @@
|
|||||||
@Html.DisplayFor(modelItem => item.MachineName)
|
@Html.DisplayFor(modelItem => item.MachineName)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="ProductMachineAdd" asp-route-id="@item.Id" class="btn btn-primary">Привязать станок</a>
|
<a asp-action="ProductMachineAdd" asp-controller="Product" asp-route-id="@item.Id" class="btn btn-primary">Привязать станок</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="CreateProduct" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
<a asp-action="CreateProduct" asp-controller="Product" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post">
|
<form method="post" asp-controller="Product">
|
||||||
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
|
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
|
||||||
<input type="submit" class="btn btn-danger" value="Удалить" />
|
<input type="submit" class="btn btn-danger" value="Удалить" />
|
||||||
</form>
|
</form>
|
@ -19,7 +19,7 @@
|
|||||||
<div class="card mb-4">
|
<div class="card mb-4">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">@machine.Title</h5>
|
<h5 class="card-title">@machine.Title</h5>
|
||||||
<form asp-action="ProductMachineAdd" method="post">
|
<form asp-action="ProductMachineAdd" asp-controller="Product" method="post">
|
||||||
<input type="hidden" name="productId" value="@ViewBag.Product.Id"/>
|
<input type="hidden" name="productId" value="@ViewBag.Product.Id"/>
|
||||||
<input type="hidden" name="machineId" value="@machine.Id" />
|
<input type="hidden" name="machineId" value="@machine.Id" />
|
||||||
<button type="submit" class="btn btn-primary">Выбрать</button>
|
<button type="submit" class="btn btn-primary">Выбрать</button>
|
@ -9,7 +9,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Создание производства</h2>
|
<h2 class="display-4">Создание производства</h2>
|
||||||
</div>
|
</div>
|
||||||
<form id="productionForm" method="post">
|
<form id="productionForm" asp-controller="Production" method="post">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-4">Название:</div>
|
<div class="col-4">Название:</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
@ -18,7 +18,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
<p>
|
<p>
|
||||||
<a asp-action="CreateProduction" asp-route-id="0">Создать производство</a>
|
<a asp-action="CreateProduction" asp-controller="Production" asp-route-id="0">Создать производство</a>
|
||||||
</p>
|
</p>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -54,10 +54,10 @@
|
|||||||
@Html.DisplayFor(modelItem => item.Cost)
|
@Html.DisplayFor(modelItem => item.Cost)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a asp-action="CreateProduction" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
<a asp-action="CreateProduction" asp-controller="Production" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form method="post">
|
<form asp-controller="Production" method="post">
|
||||||
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
|
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
|
||||||
<input type="submit" class="btn btn-danger" value="Удалить" />
|
<input type="submit" class="btn btn-danger" value="Удалить" />
|
||||||
</form>
|
</form>
|
@ -5,7 +5,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Создание отчета</h2>
|
<h2 class="display-4">Создание отчета</h2>
|
||||||
</div>
|
</div>
|
||||||
<form id="TimeReportWeb" method="post">
|
<form id="TimeReportWeb" asp-controller="Report" method="post">
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-4 text-right">
|
<div class="col-4 text-right">
|
||||||
<label for="startDate">Дата начала:</label>
|
<label for="startDate">Дата начала:</label>
|
||||||
@ -74,8 +74,8 @@
|
|||||||
if (validateDates()) {
|
if (validateDates()) {
|
||||||
var formData = $('#TimeReportWeb').serialize();
|
var formData = $('#TimeReportWeb').serialize();
|
||||||
|
|
||||||
$.post('/Home/TimeReportWeb', formData, function (response) {
|
$.post('/Report/TimeReportWeb', formData, function (response) {
|
||||||
window.location.href = '/Home/DetailTimeReport';
|
window.location.href = '/Report/DetailTimeReport';
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
alert('Произошла ошибка при создании отчета.');
|
alert('Произошла ошибка при создании отчета.');
|
||||||
});
|
});
|
@ -10,7 +10,7 @@
|
|||||||
<h1 class="display-4">Список деталей в диапазоне времени</h1>
|
<h1 class="display-4">Список деталей в диапазоне времени</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form asp-action="DetailTimeMail" method="post">
|
<form asp-action="DetailTimeMail" asp-controller="Report" method="post">
|
||||||
<button type="submit" class="btn btn-primary">Отправить отчет на почту</button>
|
<button type="submit" class="btn btn-primary">Отправить отчет на почту</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
<h2>Выберите детали для отчета</h2>
|
<h2>Выберите детали для отчета</h2>
|
||||||
|
|
||||||
<form asp-controller="Home" asp-action="DetailWorkshopChoose" method="post" onsubmit="return validateForm()">
|
<form asp-controller="Report" asp-action="DetailWorkshopChoose" method="post" onsubmit="return validateForm()">
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
@ -5,7 +5,7 @@
|
|||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h1 class="display-4">Меню создания отчетов</h1>
|
<h1 class="display-4">Меню создания отчетов</h1>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="DetailWorkshopChoose">Отчет деталь-цех</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Report" asp-action="DetailWorkshopChoose">Отчет деталь-цех</a>
|
||||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="DetailTimeChoose">Отчет по деталям по датам</a>
|
<a class="nav-link text-dark" asp-area="" asp-controller="Report" asp-action="DetailTimeChoose">Отчет по деталям по датам</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -17,7 +17,9 @@
|
|||||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<img src="~/images/Work-transformed.png" width="150" height="150" alt="Логотип">
|
<img src="~/images/Work-transformed.png" width="150" height="150" alt="Логотип">
|
||||||
<a asp-controller="Home" asp-action="Index">Приложение "Завод "Иди работать". Исполнитель"</a>
|
<a asp-controller="Home" asp-action="Index" class="custom-link">
|
||||||
|
<h1>Приложение "Завод "Иди работать". Исполнитель"</h1>
|
||||||
|
</a>
|
||||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Privacy">@ViewData["Name"]</a>
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Privacy">@ViewData["Name"]</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -16,3 +16,13 @@ html {
|
|||||||
body {
|
body {
|
||||||
margin-bottom: 60px;
|
margin-bottom: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-link {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-link:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user