This commit is contained in:
Artyom_Yashin 2024-05-26 17:24:43 +04:00
commit 814321996b
5 changed files with 113 additions and 22 deletions

View File

@ -35,14 +35,14 @@ namespace BankBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { entry.CardNumber.ToString(), entry.DateCreate.ToShortDateString(), entry.ComputerName, entry.Sum.ToString(), entry.OrderStatus.ToString() },
Texts = new List<string> { entry.CardNumber.ToString(), },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
CreateParagraph(new PdfParagraph
{
Text = $"Итого: {info.OperationsRequests.Sum(x => x.Sum)}\t",
Text = "",
Style = "Normal",
ParagraphAlignment =
PdfParagraphAlignmentType.Right
@ -75,14 +75,14 @@ namespace BankBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { entry.CardNumber.ToString(), entry.DateCreate.ToShortDateString(), entry.ComputerName, entry.Sum.ToString(), entry.OrderStatus.ToString() },
Texts = new List<string> { entry.CardNumber.ToString(), },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
CreateParagraph(new PdfParagraph
{
Text = $"Итого: {info.OperationsRequests.Sum(x => x.Sum)}\t",
Text = "",
Style = "Normal",
ParagraphAlignment =
PdfParagraphAlignmentType.Right

View File

@ -16,13 +16,13 @@ namespace BankBusinessLogic.OfficePackage.Implements
{
private WordprocessingDocument? _wordDocument;
private Body? _docBody;
/// <summary>
/// Получение типа выравнивания
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
private static JustificationValues
GetJustificationValues(WordJustificationType type)
private static JustificationValues GetJustificationValues(WordJustificationType type)
{
return type switch
{
@ -31,6 +31,7 @@ namespace BankBusinessLogic.OfficePackage.Implements
_ => JustificationValues.Left,
};
}
/// <summary>
/// Настройки страницы
/// </summary>
@ -45,13 +46,13 @@ namespace BankBusinessLogic.OfficePackage.Implements
properties.AppendChild(pageSize);
return properties;
}
/// <summary>
/// Задание форматирования для абзаца
/// </summary>
/// <param name="paragraphProperties"></param>
/// <returns></returns>
private static ParagraphProperties?
CreateParagraphProperties(WordTextProperties? paragraphProperties)
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? paragraphProperties)
{
if (paragraphProperties == null)
{
@ -80,6 +81,7 @@ namespace BankBusinessLogic.OfficePackage.Implements
properties.AppendChild(paragraphMarkRunProperties);
return properties;
}
protected override void CreateWord(WordInfo info)
{
_wordDocument = WordprocessingDocument.Create(info.FileName,
@ -88,6 +90,7 @@ namespace BankBusinessLogic.OfficePackage.Implements
mainPart.Document = new Document();
_docBody = mainPart.Document.AppendChild(new Body());
}
protected override void CreateParagraph(WordParagraph paragraph)
{
if (_docBody == null || paragraph == null)
@ -117,6 +120,7 @@ namespace BankBusinessLogic.OfficePackage.Implements
}
_docBody.AppendChild(docParagraph);
}
protected override void SaveWord(WordInfo info)
{
if (_docBody == null || _wordDocument == null)
@ -126,6 +130,86 @@ namespace BankBusinessLogic.OfficePackage.Implements
_docBody.AppendChild(CreateSectionProperties());
_wordDocument.MainDocumentPart!.Document.Save();
_wordDocument.Dispose();
}
}
}
protected override void CreateTable(WordTable table)
{
if (_docBody == null || table == null)
{
return;
}
Table docTable = new Table();
TableProperties tableProps = new TableProperties(
new TableBorders(
new TopBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new BottomBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new LeftBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new RightBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideHorizontalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
},
new InsideVerticalBorder
{
Val = new EnumValue<BorderValues>(BorderValues.Single),
Size = 12
}
)
);
docTable.AppendChild(tableProps);
TableGrid tableGrid = new TableGrid();
for (int i = 0; i < table.Columns; i++)
{
tableGrid.AppendChild(new GridColumn());
}
docTable.AppendChild(tableGrid);
TableRow tableRow = new TableRow();
foreach (var text in table.Headers)
{
tableRow.AppendChild(CreateTableCell(text));
}
int height = table.RowText.Count;
int width = table.Columns;
docTable.AppendChild(tableRow);
for (int i = 0; i < height; i++)
{
tableRow = new TableRow();
for (int j = 0; j < width; j++)
{
var element = table.RowText[i][j];
tableRow.AppendChild(CreateTableCell(element));
}
docTable.AppendChild(tableRow);
}
_docBody.AppendChild(docTable);
}
private TableCell CreateTableCell(string element)
{
var tableParagraph = new Paragraph();
var run = new Run();
run.AppendChild(new Text { Text = element });
tableParagraph.AppendChild(run);
var tableCell = new TableCell();
tableCell.AppendChild(tableParagraph);
return tableCell;
}
}
}

View File

@ -451,28 +451,32 @@ namespace BankManagersClientApp.Controllers
{
return Redirect("~/Home/Enter");
}
ViewBag.Withdrawals = APIClient.GetRequest<List<WithdrawalViewModel>>($"api/withdrawal/getwithdrawallist?managerid={APIClient.Client.Id}");
ViewBag.Requests = APIClient.GetRequest<List<RequestViewModel>>($"api/request/getrequestlist");
if (request != null && withdrawal != null)
{
APIClient.GetRequest<bool>($"api/withdrawal/linkwithdrawalrequest?withdrawalid={withdrawal}&requestid={request}");
return Redirect("Withdrawals");
}
ViewBag.Withdrawals = APIClient.GetRequest<List<WithdrawalViewModel>>($"api/withdrawal/getwithdrawallist?managerid={APIClient.Client.Id}");
ViewBag.Requests = APIClient.GetRequest<List<RequestViewModel>>($"api/request/getrequestlist");
return View();
}
#endregion
#region//работа с отчётами
#region//Reports
[HttpGet]
public IActionResult RequestsListReport()
{
if (APIClient.Client == null)
{
return Redirect("~/Home/Enter");
}
return View();
ViewBag.Accounts = APIClient.GetRequest<List<AccountViewModel>>($"api/account/getaccountlist?managerid={APIClient.Client.Id}");
return View();
}
public IActionResult TransfersWithdrawalsListReport()
[HttpGet]
public IActionResult TransfersWithdrawalsListReport()
{
if (APIClient.Client == null)
{

View File

@ -5,7 +5,7 @@
}
<div class="text-center">
<h2 class="display-4">Список заяыок по счетам</h2>
<h2 class="display-4">Список заявок по счетам</h2>
</div>
<form method="post">
<div class="row">
@ -18,10 +18,13 @@
}
</select>
</div>
<asp:RadioButtonList ID="buttons" runat="server">
<asp:ListItem id="Word" name="Word" Text="Получить в формате Word" />
<asp:ListItem id="Excel" name="Excel" Text="Получить в формате Excel" />
</asp:RadioButtonList>
</div>
<div class="row">
<div class="col-9"></div>
<div class="col-1"><input type="submit" value="Получить в формате Word" class="btn btn-primary" /></div>
<div class="col-1"><input type="submit" value="Получить в формате Excel" class="btn btn-primary" /></div>
<div class="col-9" />
<div class="col-1"><input type="submit" value="Получить список" class="btn btn-primary" /></div>
</div>
</form>

View File

@ -37,18 +37,18 @@ namespace BankRestApi.Controllers
}
[HttpGet]
public WithdrawalViewModel? GetWithdrawal(int WithdrawalId)
public WithdrawalViewModel? GetWithdrawal(int withdrawalId)
{
try
{
return _logic.ReadElement(new WithdrawalSearchModel
{
Id = WithdrawalId
Id = withdrawalId
});
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения выдачи по Id={Id}", WithdrawalId);
_logger.LogError(ex, "Ошибка получения выдачи по Id={Id}", withdrawalId);
throw;
}
}