//TODO: Method to add column header void AddColumnHeader(string[] customColumn, rptOBRPayroll rpt) { var xrCell = new DevExpress.XtraReports.UI.XRTableCell(); foreach (var i in customColumn) { xrCell = new DevExpress.XtraReports.UI.XRTableCell() { Text = i, Name = i }; xrCell.ExpressionBindings.AddRange(new DevExpress.XtraReports.UI.ExpressionBinding[] { new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", $"[{i}]") }); rpt.tblRowPayrollDetailHeader.Cells.Add(xrCell); } // rpt.tblRowPayrollDetailHeader.Cells.AddRange(new[] { new DevExpress.XtraReports.UI.XRTableCell() { Text = "TOTAL", }, new DevExpress.XtraReports.UI.XRTableCell() { Text = "Signature", }, }); }
void AddPageTotalColumn(string[] customColumn, XRTableCell xrCell, rptOBRPayroll rpt) { foreach (var i in customColumn) { xrCell = new DevExpress.XtraReports.UI.XRTableCell() { // Text = payrollDetails.AsEnumerable().Sum(x => x.Field<decimal>(i)).ToString("Php #,##.#0"), Name = "colPageTotal" + i, WidthF = 150 }; CalculatePageTotalValue(xrCell, i); rpt.tblPageTotalRow.Cells.Add(xrCell); } var pageTotalCell = new DevExpress.XtraReports.UI.XRTableCell() { // Text = ds.Tables["PayrollDetails"].AsEnumerable().Sum(x => x.Field<decimal>("Total")).ToString("Php #,##.#0"), Name = "pageTotal", }; CalculatePageTotalValue(pageTotalCell, "Total"); rpt.tblPageTotalRow.Cells.Add(pageTotalCell); rpt.tblPageTotalRow.Cells.Add(new XRTableCell()); rpt.colPageTotal.WidthF = rpt.tblRowPayrollDetails.Cells[0].WidthF + rpt.tblRowPayrollDetails.Cells[1].WidthF + rpt.tblRowPayrollDetails.Cells[2].WidthF; }
void AddGrandTotalColumn(string[] customColumn, XRTableCell xrCell, rptOBRPayroll rpt) { foreach (var i in customColumn) { xrCell = new DevExpress.XtraReports.UI.XRTableCell() { Name = "colGrandTotal" + i, WidthF = 150 }; xrCell.PrintOnPage += (s, e) => { var cell = s as XRTableCell; cell.Visible = (e.PageCount - 1) == e.PageIndex; cell.Text = oBRPayrollViewModels.Where(x => x.ColumnName == i).Sum(m => m.Value) ?.ToString("n2"); }; rpt.tblGrandTotalRow.Cells.Add(xrCell); //Total } xrCell = new DevExpress.XtraReports.UI.XRTableCell() { // Name = "colGrandTotal", }; xrCell.PrintOnPage += (s, e) => { var cell = s as XRTableCell; cell.Visible = (e.PageCount - 1) == e.PageIndex; cell.Text = oBRPayrollViewModels.Where(x => x.ColumnName == "Total").Sum(m => m.Value)?.ToString("n2"); }; rpt.tblGrandTotalRow.Cells.Add(xrCell); xrCell = new XRTableCell() { Name = "colSigGrandTotal", }; xrCell.PrintOnPage += (s, e) => { var cell = s as XRTableCell; cell.Visible = (e.PageCount - 1) == e.PageIndex; }; rpt.tblGrandTotalRow.Cells.Add(xrCell); rpt.colGrandTotalLabel.WidthF = rpt.colPageTotal.WidthF; }
void AddColumnHeaderDetails(string[] customColumn, rptOBRPayroll rpt) { var xrCell = new DevExpress.XtraReports.UI.XRTableCell(); foreach (var i in customColumn) { xrCell = new DevExpress.XtraReports.UI.XRTableCell() { Text = i, Name = i, TextFormatString = "{0:#,##.0#}", WidthF = 150 }; xrCell.ExpressionBindings.AddRange(new DevExpress.XtraReports.UI.ExpressionBinding[] { new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", $"[{i}]") }); AddPageTotalValue(xrCell, i); rpt.tblRowPayrollDetails.Cells.Add(xrCell); } var totalCell = new DevExpress.XtraReports.UI.XRTableCell() { Text = "TOTAL", Name = "colTotal", TextFormatString = "{0:#,##.0#}" }; totalCell.ExpressionBindings.AddRange(new ExpressionBindingCollection() { new ExpressionBinding("BeforePrint", "Text", $"[Total]") }); rpt.tblRowPayrollDetails.Cells.Add(totalCell); AddPageTotalValue(totalCell, "Total"); rpt.tblRowPayrollDetails.Cells.Add(new XRTableCell() { Name = "colSig" }); }
private void BtnPreview_Click(object sender, EventArgs e) { oBRPayrollViewModels = new List <OBRPayrollViewModel>(); var res = new UnitOfWork().PayrollsRepo.Find(m => m.Id == obId); var xrCell = new XRTableCell(); var rpt = new rptOBRPayroll(res?.Obligations.ResponsibilityCenter + " - " + res?.ControlNo); if (res.Obligations.ORDetails.Any(x => x.Appropriations.AccountName.ToLower().Contains("casual"))) { rpt.xrLblPurpose.BackColor = Color.Pink; } var customColumn = res?.ColumnTitle1?.Split(','); //Start TODO: adding Header columns if (customColumn != null) { //End TODO: adding Header columns AddColumnHeader(customColumn, rpt); //Start TODO: add row columns of payroll details AddColumnHeaderDetails(customColumn, rpt); //End TODO: add row columns of payroll details //TODO: Initialize DataSet and DataTable this.InitializePayrollDataset(res, customColumn); rpt.DataSource = ds; //TODO: ReRender column width for (var i = 0; i <= rpt.tblRowPayrollDetailHeader.Cells.Count - 1; i++) { rpt.tblRowPayrollDetailHeader.Cells[i].WidthF = rpt.tblRowPayrollDetails.Cells[i].WidthF; } //rpt.tblPageTotal.WidthF = rpt.tblRowPayrollDetailHeader.WidthF - rpt.tblRowPayrollDetails.Cells["colSig"].WidthF; //TODO: RENDERING PAGE TOTAL this.AddPageTotalColumn(customColumn, xrCell, rpt); //TODO: RENDERING GRAND TOTAL AddGrandTotalColumn(customColumn, xrCell, rpt); } StaticSettings staticSettings = new StaticSettings(); if (staticSettings.Offices.IsDivision != true) { foreach (XRControl control in rpt.AllControls <XRControl>().Where(x => x.Tag == "Division")) { control.Visible = false; } rpt.grpDiv.Visible = false; rpt.grpDept.Visible = true; } else { rpt.grpDiv.Visible = true; rpt.grpDept.Visible = false; } // rpt.CreateDocument(); //xRTableCell.PrintOnPage -= printOnPageEventArgs; frmReportViewer frm = new frmReportViewer(rpt); frm.ShowDialog(); }