private void modalitàPagamentoToolStripMenuItem_Click(object sender, EventArgs e) { ModalitaPagamento mp = new ModalitaPagamento(); mp.MdiParent = this; mp.Show(); }
public void WriteReportLines(IXLWorksheet ws, Tuple <int, List <PaymentsReportModel>, PaymentsReportInputModel> reportData) { int writingRow = reportData.Item1; List <PaymentsReportModel> paymentsReportModel = reportData.Item2; PaymentsReportInputModel input = reportData.Item3; foreach (var p in paymentsReportModel) { var tabellaPagamento = new ModalitaPagamento().List; var paymentMethod = tabellaPagamento .Where(x => x.Codice == p.ModalitaPagamento) .Select(x => x.Nome) .FirstOrDefault(); ws.Cell(writingRow, 1).SetValue(p.NumeroFattura); ws.Cell(writingRow, 2).SetValue(p.DataFattura); ws.Cell(writingRow, 3).SetValue(paymentMethod); ws.Cell(writingRow, 4).SetValue(p.IstitutoFinanziario); ws.Cell(writingRow, 5).SetValue(p.IBAN); ws.Cell(writingRow, 6).SetValue(p.TRNCode); if (p.DataScadenzaPagamento != DateTime.MinValue) { ws.Cell(writingRow, 7).SetValue(p.DataScadenzaPagamento.ToString("dd/MM/yyyy")); } if (p.PaymentDate != DateTime.MinValue) { ws.Cell(writingRow, 8).SetValue(p.PaymentDate.ToString("dd/MM/yyyy")); } ws.Cell(writingRow, 9).SetValue(p.ImportoPagamento); ws.Range("A" + writingRow + ":I" + writingRow).Style.Border.BottomBorder = XLBorderStyleValues.Thin; writingRow++; } writingRow++; var due = paymentsReportModel .Select(x => x.ImportoPagamento) .Sum(); var paid = paymentsReportModel .Where(x => x.PaymentDate != DateTime.MinValue) .Select(x => x.ImportoPagamento) .Sum(); var difference = paymentsReportModel .Where(x => x.PaymentDate == DateTime.MinValue) .Select(x => x.ImportoPagamento) .Sum(); ws.Cell(writingRow, 1).RichText .AddText("Totale fatture:") .SetBold(); ws.Cell(writingRow, 2).SetValue(due); ws.Cell(writingRow + 1, 1).RichText .AddText("Totale pagato:") .SetBold(); ws.Cell(writingRow + 1, 2).SetValue(paid); ws.Cell(writingRow + 2, 1).RichText .AddText("Residuo:") .SetBold(); ws.Cell(writingRow + 2, 2).SetValue(difference); var colA = ws.Column("A"); colA.AdjustToContents(); var colBD = ws.Columns("B:D"); colBD.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; colBD.AdjustToContents(); var colE = ws.Column("E"); colE.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; colE.AdjustToContents(); var colF = ws.Column("F"); colF.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; colF.AdjustToContents(); var colG = ws.Column("G"); colG.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; colG.AdjustToContents(); var colH = ws.Column("H"); colH.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center; colH.AdjustToContents(); var colI = ws.Column("I"); colI.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right; colI.AdjustToContents(); var rangeValues = ws.Range("B1:B4"); rangeValues.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left; }