Compare commits

..

2 Commits

7 changed files with 526 additions and 406 deletions

View File

@ -1,5 +1,6 @@
using LawFirmBusinessLogic.OfficePackages.HelperEnums; using LawFirmBusinessLogic.OfficePackages.HelperEnums;
using LawFirmBusinessLogic.OfficePackages.HelperModels; using LawFirmBusinessLogic.OfficePackages.HelperModels;
using System.Runtime.CompilerServices;
namespace LawFirmBusinessLogic.OfficePackages namespace LawFirmBusinessLogic.OfficePackages
{ {
@ -19,44 +20,66 @@ namespace LawFirmBusinessLogic.OfficePackages
Text = info.Title, Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title StyleInfo = ExcelStyleInfoType.Title
}); });
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 2,
Text = "Клиент",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = 2,
Text = "Дата консультации",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = 2,
Text = "Цена консультации",
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
MergeCells(new ExcelMergeParameters MergeCells(new ExcelMergeParameters
{ {
CellFromName = "A1", CellFromName = "A1",
CellToName = "C1" CellToName = "C1"
}); });
uint rowIndex = 2; uint rowIndex = 4;
foreach (var ch in info.ClientsConsultation)
foreach (var vl in info.ClientsConsultation)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = ch.ClientFIO, Text = vl.ClientFIO,
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
foreach (var consultation in ch.Consultations) foreach (var cons in vl.Consultations)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "B", ColumnName = "B",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = consultation.Cost.ToString(), Text = cons.ConsultationDate.ToShortDateString(),
StyleInfo = StyleInfo =
ExcelStyleInfoType.TextWithBroder ExcelStyleInfoType.Text
}); });
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "C", ColumnName = "C",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = consultation.ConsultationDate.ToString(), Text = cons.Cost.ToString(),
StyleInfo = StyleInfo =
ExcelStyleInfoType.TextWithBroder ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
}
} }
}
SaveExcel(info); SaveExcel(info);
} }
/// <summary> /// <summary>

View File

@ -89,8 +89,7 @@ namespace LawFirmBusinessLogic.OfficePackages.Implements
var cellFormatStyle = new CellFormat() var cellFormatStyle = new CellFormat()
{ {
NumberFormatId = 0U, NumberFormatId = 0U,
FontId FontId = 0U,
= 0U,
FillId = 0U, FillId = 0U,
BorderId = 0U BorderId = 0U
}; };
@ -99,8 +98,7 @@ namespace LawFirmBusinessLogic.OfficePackages.Implements
var cellFormatFont = new CellFormat() var cellFormatFont = new CellFormat()
{ {
NumberFormatId = 0U, NumberFormatId = 0U,
FontId = FontId = 0U,
0U,
FillId = 0U, FillId = 0U,
BorderId = 0U, BorderId = 0U,
FormatId = 0U, FormatId = 0U,
@ -119,8 +117,7 @@ namespace LawFirmBusinessLogic.OfficePackages.Implements
var cellFormatTitle = new CellFormat() var cellFormatTitle = new CellFormat()
{ {
NumberFormatId = 0U, NumberFormatId = 0U,
FontId FontId = 1U,
= 1U,
FillId = 0U, FillId = 0U,
BorderId = 0U, BorderId = 0U,
FormatId = 0U, FormatId = 0U,
@ -298,7 +295,7 @@ namespace LawFirmBusinessLogic.OfficePackages.Implements
} }
// вставляем новый текст // вставляем новый текст
_shareStringPart.SharedStringTable.AppendChild(new _shareStringPart.SharedStringTable.AppendChild(new
SharedStringItem(new DocumentFormat.OpenXml.Drawing.Text(excelParams.Text))); SharedStringItem(new Text(excelParams.Text)));
_shareStringPart.SharedStringTable.Save(); _shareStringPart.SharedStringTable.Save();
cell.CellValue = new cell.CellValue = new
CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count( CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count(

View File

@ -11,9 +11,9 @@ namespace LawFirmDatabaseImplement
{ {
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
//optionsBuilder.UseSqlServer(@"Data Source=ZIRAEL\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=ZIRAEL\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=PC-Anna\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); //optionsBuilder.UseSqlServer(@"Data Source=PC-Anna\SQLEXPRESS;Initial Catalog=LawFirmDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }

View File

@ -52,7 +52,7 @@ namespace LawFirmExecutorApp.Controllers
[HttpGet] [HttpGet]
public IActionResult UpdateClient() public IActionResult UpdateClient()
{ {
ViewBag.Clients = APIClient.GetRequest<List<ClientViewModel>>($"api/client/getclientlist?guarantorid={APIClient.Executor.Id}"); ViewBag.Clients = APIClient.GetRequest<List<ClientViewModel>>($"api/client/getclientlist?executorid={APIClient.Executor.Id}");
return View(); return View();
} }
[HttpPost] [HttpPost]
@ -73,5 +73,64 @@ namespace LawFirmExecutorApp.Controllers
}); });
Response.Redirect("/Home/Clients"); Response.Redirect("/Home/Clients");
} }
[HttpGet]
public IActionResult GetFile()
{
ViewBag.Clients = APIClient.GetRequest<List<ClientViewModel>>($"api/client/getclientlist?executorid={APIClient.Executor.Id}");
return View();
}
[HttpPost]
public void GetFile(int clientId, string type)
{
if (APIClient.Executor == null)
{
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
}
if (clientId == 0)
{
throw new Exception("Выберите клиента");
}
if (string.IsNullOrEmpty(type))
{
throw new Exception("Неверный тип отчета");
}
if (type == "docx")
{
APIClient.PostRequest("api/ReportExecutor/SaveClientsWordFile", new ReportBindingModel
{
ClientId = clientId,
ExecutorId = APIClient.Executor.Id,
FileName = "E:\\reports\\wordfileTest.docx"
});
Response.Redirect("GetWordFile");
}
else
{
APIClient.PostRequest("api/ReportExecutor/SaveClientsExcelFile", new ReportBindingModel
{
ClientId = clientId,
ExecutorId = APIClient.Executor.Id,
FileName = "E:\\reports\\excelfileTest.xlsx"
});
Response.Redirect("GetExcelFile");
}
}
[HttpGet]
public IActionResult GetWordFile()
{
return new PhysicalFileResult("E:\\reports\\wordclientsreport.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
}
public IActionResult GetExcelFile()
{
return new PhysicalFileResult("E:\\reports\\excelclientsreport.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
} }
} }

View File

@ -0,0 +1,31 @@
@using LawFirmContracts.ViewModels;
@{
ViewData["Title"] = "Слушания по клиентам";
}
<div class="text-center">
<h2 class="display-4">Создать списки слушаний по клиентам</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Клиент:</div>
<div class="col-8">
<select id="clientId" name="clientId" class="form-control" asp-items="@(new SelectList(@ViewBag.Clients,"Id", "FIO"))"></select>
</div>
</div>
<div class="file-format">
<label class="form-label">Выберите формат файла:</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" value="docx" id="docx">
<label class="form-check-label" for="docx">Word-файл</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx" checked>
<label class="form-check-label" for="xlsx">Excel-файл</label>
</div>
</div>
<div class="d-flex justify-content-center">
<button type="submit" class="btn btn-block btn-outline-dark w-100">Создать</button>
</div>
</form>

View File

@ -69,5 +69,12 @@
} }
</tbody> </tbody>
</table> </table>
<tr>
<td>
<form action="/Client/GetFile">
<button type="submit" class="btn btn-danger">Получить docx/xlsx файл</button>
</form>
</td>
</tr>
} }
</div> </div>

View File

@ -34,6 +34,9 @@
<li class="nav-item"> <li class="nav-item">
<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>
</li> </li>
<li class="nav-item">
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Report">Отчеты</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a> <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
</li> </li>