Отчеты_поручитель
This commit is contained in:
@@ -52,7 +52,7 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuarantorViewModel? ReadElement(GuarantorSearchModel model)
|
public GuarantorViewModel? ReadElement(GuarantorSearchModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ServiceStationBusinessLogic.OfficePackage;
|
using DocumentFormat.OpenXml.Drawing;
|
||||||
|
using ServiceStationBusinessLogic.OfficePackage;
|
||||||
using ServiceStationBusinessLogic.OfficePackage.HelperModels;
|
using ServiceStationBusinessLogic.OfficePackage.HelperModels;
|
||||||
using ServiceStationContracts.BindingModels;
|
using ServiceStationContracts.BindingModels;
|
||||||
using ServiceStationContracts.BusinessLogicsContracts;
|
using ServiceStationContracts.BusinessLogicsContracts;
|
||||||
@@ -19,16 +20,18 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
private readonly ISparePartStorage _sparepartStorage;
|
private readonly ISparePartStorage _sparepartStorage;
|
||||||
private readonly IRepairStorage _repairStorage;
|
private readonly IRepairStorage _repairStorage;
|
||||||
private readonly ITechnicalWorkStorage _techWorkStorage;
|
private readonly ITechnicalWorkStorage _techWorkStorage;
|
||||||
|
private readonly IWorkStorage _workStorage;
|
||||||
private readonly AbstractSaveToExcelGuarantor _saveToExcel;
|
private readonly AbstractSaveToExcelGuarantor _saveToExcel;
|
||||||
private readonly AbstractSaveToWordGuarantor _saveToWord;
|
private readonly AbstractSaveToWordGuarantor _saveToWord;
|
||||||
private readonly AbstractSaveToPdfGuarantor _saveToPdf;
|
private readonly AbstractSaveToPdfGuarantor _saveToPdf;
|
||||||
|
|
||||||
public GuarantorReportLogic(IDefectStorage defectStorage, ISparePartStorage sparepartStorage, IRepairStorage repairStorage, ITechnicalWorkStorage techWorkStorage, AbstractSaveToExcelGuarantor saveToExcel, AbstractSaveToPdfGuarantor saveToPdf, AbstractSaveToWordGuarantor saveToWord)
|
public GuarantorReportLogic(IDefectStorage defectStorage, ISparePartStorage sparepartStorage, IRepairStorage repairStorage, ITechnicalWorkStorage techWorkStorage, AbstractSaveToExcelGuarantor saveToExcel, AbstractSaveToPdfGuarantor saveToPdf, AbstractSaveToWordGuarantor saveToWord, IWorkStorage workStorage)
|
||||||
{
|
{
|
||||||
_defectStorage = defectStorage;
|
_defectStorage = defectStorage;
|
||||||
_sparepartStorage = sparepartStorage;
|
_sparepartStorage = sparepartStorage;
|
||||||
_repairStorage = repairStorage;
|
_repairStorage = repairStorage;
|
||||||
_techWorkStorage = techWorkStorage;
|
_techWorkStorage = techWorkStorage;
|
||||||
|
_workStorage = workStorage;
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
_saveToPdf = saveToPdf;
|
_saveToPdf = saveToPdf;
|
||||||
@@ -40,8 +43,6 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
List<ReportDefectsViewModel> allList = new List<ReportDefectsViewModel>();
|
List<ReportDefectsViewModel> allList = new List<ReportDefectsViewModel>();
|
||||||
|
|
||||||
double price = 0;
|
|
||||||
|
|
||||||
var defects = _defectStorage.GetFullList();
|
var defects = _defectStorage.GetFullList();
|
||||||
List<SparePartViewModel> spareparts = new List<SparePartViewModel>();
|
List<SparePartViewModel> spareparts = new List<SparePartViewModel>();
|
||||||
foreach (var sparepartId in Ids)
|
foreach (var sparepartId in Ids)
|
||||||
@@ -58,6 +59,7 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
foreach (var sparepart in spareparts)
|
foreach (var sparepart in spareparts)
|
||||||
{
|
{
|
||||||
|
double price = 0;
|
||||||
var rec = new ReportDefectsViewModel
|
var rec = new ReportDefectsViewModel
|
||||||
{
|
{
|
||||||
SparePartName = sparepart.SparePartName,
|
SparePartName = sparepart.SparePartName,
|
||||||
@@ -65,18 +67,22 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
};
|
};
|
||||||
foreach (var defect in defects)
|
foreach (var defect in defects)
|
||||||
{
|
{
|
||||||
var repair = _repairStorage.GetElement(new RepairSearchModel
|
var repair = new RepairViewModel();
|
||||||
|
if (defect.RepairId.HasValue)
|
||||||
{
|
{
|
||||||
Id = defect.RepairId,
|
repair = _repairStorage.GetElement(new RepairSearchModel
|
||||||
});
|
|
||||||
foreach (var repSpareParts in repair.RepairSpareParts.Values)
|
|
||||||
{
|
|
||||||
if (repSpareParts.Id == sparepart.Id)
|
|
||||||
{
|
{
|
||||||
rec.DefectsInfo.Add(new(defect.DefectType, defect.DefectPrice));
|
Id = defect.RepairId,
|
||||||
price += defect.DefectPrice;
|
});
|
||||||
|
foreach (var repSpareParts in repair.RepairSpareParts.Values)
|
||||||
|
{
|
||||||
|
if (repSpareParts.Id == sparepart.Id)
|
||||||
|
{
|
||||||
|
rec.DefectsInfo.Add(new(defect.DefectType, defect.DefectPrice));
|
||||||
|
price += defect.DefectPrice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rec.FullPrice = price;
|
rec.FullPrice = price;
|
||||||
allList.Add(rec);
|
allList.Add(rec);
|
||||||
@@ -84,7 +90,7 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
return allList;
|
return allList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportSparePartsViewModel> GetSpareParts(ReportGuarantorBindingModel model)
|
public List<ReportSparePartsViewModel> GetSpareParts(PdfReportBindingModel model)
|
||||||
{
|
{
|
||||||
List<ReportSparePartsViewModel> allList = new List<ReportSparePartsViewModel>();
|
List<ReportSparePartsViewModel> allList = new List<ReportSparePartsViewModel>();
|
||||||
|
|
||||||
@@ -95,6 +101,9 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
GuarantorId = model.GuarantorId,
|
GuarantorId = model.GuarantorId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
List<WorkViewModel> workList = _workStorage.GetFullList();
|
||||||
|
List<(WorkViewModel, int)> works = new();
|
||||||
|
|
||||||
foreach (var repair in repairList)
|
foreach (var repair in repairList)
|
||||||
{
|
{
|
||||||
foreach (var sparepart in repair.RepairSpareParts.Values)
|
foreach (var sparepart in repair.RepairSpareParts.Values)
|
||||||
@@ -107,23 +116,44 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
RepairStartDate = repair.RepairStartDate,
|
RepairStartDate = repair.RepairStartDate,
|
||||||
RepairPrice = repair.RepairPrice,
|
RepairPrice = repair.RepairPrice,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
foreach (var work in workList)
|
||||||
|
{
|
||||||
|
if (work.WorkSpareParts.ContainsKey(sparepart.Id))
|
||||||
|
{
|
||||||
|
int contains = 0;
|
||||||
|
foreach (var workk in works)
|
||||||
|
{
|
||||||
|
var sparepartt = _sparepartStorage.GetElement(new SparePartSearchModel { Id = workk.Item2 });
|
||||||
|
if (workk.Item2 == sparepart.Id && workk.Item1.WorkName == work.WorkName)
|
||||||
|
{
|
||||||
|
contains++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (contains == 0)
|
||||||
|
{
|
||||||
|
works.Add(new(work, sparepart.Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TechnicalWorkViewModel> techWorkList = _techWorkStorage.GetFilteredList(new TechnicalWorkSearchModel
|
foreach (var work in works)
|
||||||
{
|
{
|
||||||
DateFrom = model.DateFrom,
|
if (work.Item1.TechnicalWorkId.HasValue)
|
||||||
DateTo = model.DateTo,
|
|
||||||
});
|
|
||||||
|
|
||||||
foreach (var techWork in techWorkList)
|
|
||||||
{
|
|
||||||
allList.Add(new ReportSparePartsViewModel
|
|
||||||
{
|
{
|
||||||
WorkType = techWork.WorkType,
|
var techWork = _techWorkStorage.GetElement(new TechnicalWorkSearchModel { Id = work.Item1.TechnicalWorkId });
|
||||||
TechnicalWorkDate = techWork.DateStartWork,
|
var sparepart = _sparepartStorage.GetElement(new SparePartSearchModel { Id = work.Item2 });
|
||||||
TechnicalWorkPrice = techWork.WorkPrice,
|
allList.Add(new ReportSparePartsViewModel
|
||||||
});
|
{
|
||||||
|
SparePartName = sparepart.SparePartName,
|
||||||
|
SparePartPrice = sparepart.SparePartPrice,
|
||||||
|
WorkType = techWork.WorkType,
|
||||||
|
TechnicalWorkDate = techWork.DateStartWork,
|
||||||
|
TechnicalWorkPrice = techWork.WorkPrice,
|
||||||
|
});;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return allList;
|
return allList;
|
||||||
}
|
}
|
||||||
@@ -132,7 +162,7 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
_saveToWord.CreateDoc(new WordInfoGuarantor
|
_saveToWord.CreateDoc(new WordInfoGuarantor
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileStream = model.FileStream,
|
||||||
Title = "Список неисправностей",
|
Title = "Список неисправностей",
|
||||||
DefectsBySparePart = GetDefects(model.Ids!)
|
DefectsBySparePart = GetDefects(model.Ids!)
|
||||||
});
|
});
|
||||||
@@ -142,13 +172,13 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
_saveToExcel.CreateReport(new ExcelInfoGuarantor
|
_saveToExcel.CreateReport(new ExcelInfoGuarantor
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileStream = model.FileStream,
|
||||||
Title = "Список работ",
|
Title = "Список работ",
|
||||||
DefectsBySparePart = GetDefects(model.Ids!)
|
DefectsBySparePart = GetDefects(model.Ids!)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveSparePartsToPdfFile(ReportGuarantorBindingModel model)
|
public void SaveSparePartsToPdfFile(PdfReportBindingModel model)
|
||||||
{
|
{
|
||||||
if (model.DateFrom == null)
|
if (model.DateFrom == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +47,6 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("Delete operation failed");
|
_logger.LogWarning("Delete operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,20 +83,16 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update(RepairBindingModel model)
|
public bool Update(RepairBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
|
||||||
|
|
||||||
if (_repairStorage.Update(model) == null)
|
if (_repairStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Update operation failed");
|
_logger.LogWarning("Update operation failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,15 +113,13 @@ namespace ServiceStationBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
_logger.LogInformation("AddSparePartToRepair find. Id:{Id}", element.Id);
|
_logger.LogInformation("AddSparePartToRepair find. Id:{Id}", element.Id);
|
||||||
|
|
||||||
foreach (int sparepart in spareparts)
|
element.RepairSpareParts.Clear();
|
||||||
{
|
foreach (int sparepart in spareparts)
|
||||||
if (!element.RepairSpareParts.Keys.Contains(sparepart))
|
{
|
||||||
{
|
element.RepairSpareParts.Add(sparepart, new SparePartViewModel() { Id = sparepart });
|
||||||
element.RepairSpareParts.Add(sparepart, new SparePartViewModel() { Id = sparepart });
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_repairStorage.Update(new RepairBindingModel()
|
_repairStorage.Update(new RepairBindingModel()
|
||||||
{
|
{
|
||||||
Id = element.Id,
|
Id = element.Id,
|
||||||
RepairName = element.RepairName,
|
RepairName = element.RepairName,
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace ServiceStationBusinessLogic.MailWorker
|
|||||||
objMailMessage.Body = info.Text;
|
objMailMessage.Body = info.Text;
|
||||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||||
Attachment attachment = new Attachment(Directory.GetCurrentDirectory().Replace("ServiceStationRestApi", "ServiceStationExecutorApp") + "\\Reports\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
Attachment attachment = new Attachment(Directory.GetCurrentDirectory() + "\\Reports\\pdffile.pdf", new ContentType(MediaTypeNames.Application.Pdf));
|
||||||
objMailMessage.Attachments.Add(attachment);
|
objMailMessage.Attachments.Add(attachment);
|
||||||
|
|
||||||
objSmtpClient.UseDefaultCredentials = false;
|
objSmtpClient.UseDefaultCredentials = false;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace ServiceStationBusinessLogic.OfficePackage.HelperModels
|
|||||||
public class ExcelInfoGuarantor
|
public class ExcelInfoGuarantor
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public Stream FileStream { get; set; } = new MemoryStream();
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
public List<ReportDefectsViewModel> DefectsBySparePart { get; set; } = new();
|
public List<ReportDefectsViewModel> DefectsBySparePart { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace ServiceStationBusinessLogic.OfficePackage.HelperModels
|
|||||||
public class WordInfoGuarantor
|
public class WordInfoGuarantor
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public Stream FileStream { get; set; } = new MemoryStream();
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
public List<ReportDefectsViewModel> DefectsBySparePart { get; set; } = new();
|
public List<ReportDefectsViewModel> DefectsBySparePart { get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ namespace ServiceStationBusinessLogic.OfficePackage.Implements
|
|||||||
|
|
||||||
protected override void CreateExcel(ExcelInfoGuarantor info)
|
protected override void CreateExcel(ExcelInfoGuarantor info)
|
||||||
{
|
{
|
||||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileStream, SpreadsheetDocumentType.Workbook);
|
||||||
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
var workbookpart = _spreadsheetDocument.AddWorkbookPart();
|
||||||
workbookpart.Workbook = new Workbook();
|
workbookpart.Workbook = new Workbook();
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace ServiceStationBusinessLogic.OfficePackage.Implements
|
|||||||
|
|
||||||
protected override void CreateWord(WordInfoGuarantor info)
|
protected override void CreateWord(WordInfoGuarantor info)
|
||||||
{
|
{
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
_wordDocument = WordprocessingDocument.Create(info.FileStream, WordprocessingDocumentType.Document);
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
mainPart.Document = new Document();
|
mainPart.Document = new Document();
|
||||||
_docBody = mainPart.Document.AppendChild(new Body());
|
_docBody = mainPart.Document.AppendChild(new Body());
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace ServiceStationContracts.BindingModels
|
|||||||
|
|
||||||
public int ExecutorId { get; set; }
|
public int ExecutorId { get; set; }
|
||||||
|
|
||||||
|
public int GuarantorId { get; set; }
|
||||||
|
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
|
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace ServiceStationContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public class ReportGuarantorBindingModel
|
public class ReportGuarantorBindingModel
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public Stream FileStream { get; set; } = new MemoryStream();
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
public int GuarantorId { get; set; }
|
public int GuarantorId { get; set; }
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ namespace ServiceStationContracts.BusinessLogicsContracts
|
|||||||
public interface IGuarantorReportLogic
|
public interface IGuarantorReportLogic
|
||||||
{
|
{
|
||||||
List<ReportDefectsViewModel> GetDefects(List<int> Ids);
|
List<ReportDefectsViewModel> GetDefects(List<int> Ids);
|
||||||
List<ReportSparePartsViewModel> GetSpareParts(ReportGuarantorBindingModel model);
|
List<ReportSparePartsViewModel> GetSpareParts(PdfReportBindingModel model);
|
||||||
|
|
||||||
void SaveDefectsToWordFile(ReportGuarantorBindingModel model);
|
void SaveDefectsToWordFile(ReportGuarantorBindingModel model);
|
||||||
|
|
||||||
void SaveDefectsToExcelFile(ReportGuarantorBindingModel model);
|
void SaveDefectsToExcelFile(ReportGuarantorBindingModel model);
|
||||||
|
|
||||||
void SaveSparePartsToPdfFile(ReportGuarantorBindingModel model);
|
void SaveSparePartsToPdfFile(PdfReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using ServiceStationContracts.BindingModels;
|
|||||||
using ServiceStationContracts.BusinessLogicsContracts;
|
using ServiceStationContracts.BusinessLogicsContracts;
|
||||||
using ServiceStationContracts.SearchModels;
|
using ServiceStationContracts.SearchModels;
|
||||||
using ServiceStationContracts.ViewModels;
|
using ServiceStationContracts.ViewModels;
|
||||||
|
using ServiceStationDatabaseImplement.Models;
|
||||||
using ServiceStationGuarantorApp.Models;
|
using ServiceStationGuarantorApp.Models;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices.ComTypes;
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
@@ -217,7 +218,7 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
List<ReportSparePartsViewModel> spareparts;
|
List<ReportSparePartsViewModel> spareparts;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
spareparts = _report.GetSpareParts(new ReportGuarantorBindingModel
|
spareparts = _report.GetSpareParts(new PdfReportBindingModel
|
||||||
{
|
{
|
||||||
GuarantorId = APIGuarantor.Guarantor.Id,
|
GuarantorId = APIGuarantor.Guarantor.Id,
|
||||||
DateFrom = dateFrom,
|
DateFrom = dateFrom,
|
||||||
@@ -305,11 +306,11 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
{
|
{
|
||||||
return RedirectToAction("Enter");
|
return RedirectToAction("Enter");
|
||||||
}
|
}
|
||||||
return View();
|
return View(APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateRepair(string repairName, double repairPrice)
|
public void CreateRepair(string repairName, double repairPrice, int[] sparepart)
|
||||||
{
|
{
|
||||||
if (APIGuarantor.Guarantor == null)
|
if (APIGuarantor.Guarantor == null)
|
||||||
{
|
{
|
||||||
@@ -321,7 +322,11 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
RepairName = repairName,
|
RepairName = repairName,
|
||||||
RepairPrice = repairPrice
|
RepairPrice = repairPrice
|
||||||
});
|
});
|
||||||
Response.Redirect("ListRepairs");
|
APIGuarantor.PostRequest("api/main/addspareparttorepair", Tuple.Create(
|
||||||
|
new RepairSearchModel() { RepairName = repairName },
|
||||||
|
sparepart
|
||||||
|
));
|
||||||
|
Response.Redirect("ListRepairs");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult UpdateRepair()
|
public IActionResult UpdateRepair()
|
||||||
@@ -332,11 +337,11 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
return RedirectToAction("Enter");
|
return RedirectToAction("Enter");
|
||||||
}
|
}
|
||||||
ViewBag.Repairs = APIGuarantor.GetRequest<List<RepairViewModel>>($"api/main/getrepairlist?guarantorId={APIGuarantor.Guarantor.Id}");
|
ViewBag.Repairs = APIGuarantor.GetRequest<List<RepairViewModel>>($"api/main/getrepairlist?guarantorId={APIGuarantor.Guarantor.Id}");
|
||||||
return View();
|
return View(APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void UpdateRepair(int repair, string RepairName, double RepairPrice)
|
public void UpdateRepair(int repair, string RepairName, double RepairPrice, int[] sparepart)
|
||||||
{
|
{
|
||||||
if (APIGuarantor.Guarantor == null)
|
if (APIGuarantor.Guarantor == null)
|
||||||
{
|
{
|
||||||
@@ -357,7 +362,11 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
RepairName = RepairName,
|
RepairName = RepairName,
|
||||||
RepairPrice = RepairPrice
|
RepairPrice = RepairPrice
|
||||||
});
|
});
|
||||||
Response.Redirect("ListRepairs");
|
APIGuarantor.PostRequest("api/main/addspareparttorepair", Tuple.Create(
|
||||||
|
new RepairSearchModel() { Id = repair },
|
||||||
|
sparepart
|
||||||
|
));
|
||||||
|
Response.Redirect("ListRepairs");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult DeleteRepair()
|
public IActionResult DeleteRepair()
|
||||||
@@ -592,7 +601,7 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void ListDefectSparePartToFile(int[] Ids, string type)
|
public IActionResult ListDefectSparePartToFile(int[] Ids, string type)
|
||||||
{
|
{
|
||||||
if (APIGuarantor.Guarantor == null)
|
if (APIGuarantor.Guarantor == null)
|
||||||
{
|
{
|
||||||
@@ -616,21 +625,29 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
|
|
||||||
if (type == "docx")
|
if (type == "docx")
|
||||||
{
|
{
|
||||||
APIGuarantor.PostRequest("api/report/createguarantorreporttoword", new ReportGuarantorBindingModel
|
using (var stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
Ids = res,
|
_report.SaveDefectsToWordFile(new ReportGuarantorBindingModel
|
||||||
FileName = Directory.GetCurrentDirectory() + "\\Reports\\wordfile.docx"
|
{
|
||||||
});
|
FileStream = stream,
|
||||||
Response.Redirect("GetWordFile");
|
Ids = res
|
||||||
|
});
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "wordfile.docx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
APIGuarantor.PostRequest("api/report/createguarantorreporttoexcel", new ReportGuarantorBindingModel
|
using (var stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
Ids = res,
|
_report.SaveDefectsToExcelFile(new ReportGuarantorBindingModel
|
||||||
FileName = Directory.GetCurrentDirectory() + "\\Reports\\excelfile.xlsx"
|
{
|
||||||
});
|
FileStream = stream,
|
||||||
Response.Redirect("GetExcelFile");
|
Ids = res
|
||||||
|
});
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "excelfile.xlsx");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,14 +671,20 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
{
|
{
|
||||||
throw new Exception("Email пуст");
|
throw new Exception("Email пуст");
|
||||||
}
|
}
|
||||||
APIGuarantor.PostRequest("api/report/createguarantorreporttopdf", new ReportGuarantorBindingModel
|
APIGuarantor.PostRequest("api/report/createguarantorreporttopdf", new PdfReportBindingModel
|
||||||
{
|
{
|
||||||
FileName = Directory.GetCurrentDirectory() + "\\Reports\\pdffile.pdf",
|
FileName = Directory.GetCurrentDirectory().Replace("ServiceStationGuarantorApp", "ServiceStationRestApi") + "\\Reports\\pdffile.pdf",
|
||||||
DateFrom = dateFrom,
|
DateFrom = dateFrom,
|
||||||
DateTo = dateTo,
|
DateTo = dateTo,
|
||||||
GuarantorId = APIGuarantor.Guarantor.Id,
|
GuarantorId = APIGuarantor.Guarantor.Id,
|
||||||
});
|
});
|
||||||
Response.Redirect("GetPdfFile");
|
APIGuarantor.PostRequest("api/report/sendpdftomail", new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
MailAddress = guarantorEmail,
|
||||||
|
Subject = "Отчет по запчастям",
|
||||||
|
Text = "Отчет по запчастям с " + dateFrom.ToShortDateString() + " по " + dateTo.ToShortDateString()
|
||||||
|
});
|
||||||
|
Response.Redirect("ListSparePartsToPdf");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActionResult BindingRepairToDefects()
|
public IActionResult BindingRepairToDefects()
|
||||||
@@ -686,6 +709,7 @@ namespace ServiceStationGuarantorApp.Controllers
|
|||||||
Id = defect,
|
Id = defect,
|
||||||
RepairId = repair
|
RepairId = repair
|
||||||
});
|
});
|
||||||
|
Response.Redirect("BindingRepairToDefects");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
ServiceStation/ServiceStationGuarantorApp/Reports/pdffile.pdf
Normal file
BIN
ServiceStation/ServiceStationGuarantorApp/Reports/pdffile.pdf
Normal file
Binary file not shown.
@@ -31,6 +31,22 @@
|
|||||||
<th scope="col" class="fs-5">Цена</th>
|
<th scope="col" class="fs-5">Цена</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr style="height: 75px">
|
||||||
|
<td>
|
||||||
|
<input type="checkbox" class="form-check-input" name="Ids[]" value="@item.Id" id="@item.Id">
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.SparePartName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.SparePartPrice)
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div class="d-flex justify-content-center">
|
<div class="d-flex justify-content-center">
|
||||||
|
|||||||
@@ -13,22 +13,22 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="form-group pb-3">
|
<div class="form-group pb-3">
|
||||||
<label>Номер телефона</label>
|
<label>Номер телефона</label>
|
||||||
<input type="text" name="number" class="form-control" placeholder="Введите номер телефона" />
|
<input type="text" name="number" value="@Model.GuarantorNumber" class="form-control" placeholder="Введите номер телефона" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group pb-3">
|
<div class="form-group pb-3">
|
||||||
<label>Электронная почта</label>
|
<label>Электронная почта</label>
|
||||||
<input type="text" name="email" class="form-control" placeholder="Введите электронную почту" />
|
<input type="text" name="email" value="@Model.GuarantorEmail" class="form-control" placeholder="Введите электронную почту" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group pb-3">
|
<div class="form-group pb-3">
|
||||||
<label>ФИО</label>
|
<label>ФИО</label>
|
||||||
<input type="text" name="FIO" class="form-control" placeholder="Введите ФИО" />
|
<input type="text" name="FIO" value="@Model.GuarantorFIO" class="form-control" placeholder="Введите ФИО" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group pb-3">
|
<div class="form-group pb-3">
|
||||||
<label>Пароль</label>
|
<label>Пароль</label>
|
||||||
<input type="text" name="password" class="form-control" placeholder="Введите пароль" />
|
<input type="text" name="password" value="@Model.GuarantorPassword" class="form-control" placeholder="Введите пароль" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group d-flex justify-content-center">
|
<div class="form-group d-flex justify-content-center">
|
||||||
|
|||||||
@@ -83,11 +83,11 @@ namespace ServiceStationRestApi.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateGuarantorReportToPdf(ReportGuarantorBindingModel model)
|
public void CreateGuarantorReportToPdf(PdfReportBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_guarantorReportLogic.SaveSparePartsToPdfFile(new ReportGuarantorBindingModel
|
_guarantorReportLogic.SaveSparePartsToPdfFile(new PdfReportBindingModel
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
DateFrom = model.DateFrom,
|
DateFrom = model.DateFrom,
|
||||||
|
|||||||
BIN
ServiceStation/ServiceStationRestApi/Reports/pdffile.pdf
Normal file
BIN
ServiceStation/ServiceStationRestApi/Reports/pdffile.pdf
Normal file
Binary file not shown.
@@ -17,4 +17,8 @@
|
|||||||
<ProjectReference Include="..\ServiceStationDatabaseImplement\ServiceStationDatabaseImplement.csproj" />
|
<ProjectReference Include="..\ServiceStationDatabaseImplement\ServiceStationDatabaseImplement.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Reports\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user