private void btnPreview_Click(object sender, EventArgs e) { if (OBGridView.GetFocusedRow() is Obligations item) { item = new UnitOfWork().ObligationsRepo.Find(m => m.Id == item.Id); var rpt = new rptObligationRequestPreview() { DataSource = new List <Obligations>() { item } }; if (item.Offices.IsDivision == true) { rpt.lblDivisionChief.Visible = true; rpt.lblDivisionChiefPos.Visible = true; rpt.lblDivisionChief.ExpressionBindings.Clear(); rpt.lblDivisionChiefPos.ExpressionBindings.Clear(); rpt.lblDepartmentChief.ExpressionBindings.Clear(); rpt.lblDepartmentChiefPosition.ExpressionBindings.Clear(); rpt.lblDivisionChief.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Offices].[Chief]")); rpt.lblDivisionChiefPos.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Offices].[ChiefPosition]")); if (string.IsNullOrEmpty(item.OBRApprovedBy)) { rpt.lblDepartmentChief.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Offices].[UnderOfOffice].[Chief]")); rpt.lblDepartmentChiefPosition.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Offices].[UnderOfOffice].[ChiefPosition]")); } else { rpt.lblDepartmentChief.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[OBRApprovedBy]")); rpt.lblDepartmentChiefPosition.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[OBRApprovedByPos]")); } } else { foreach (XRControl control in rpt.AllControls <XRControl>().Where(x => x.Tag == "division")) { control.Visible = false; } rpt.lblDepartmentChief.ExpressionBindings.Clear(); rpt.lblDepartmentChiefPosition.ExpressionBindings.Clear(); rpt.lblDepartmentChief.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Offices].[Chief]")); rpt.lblDepartmentChiefPosition.ExpressionBindings.Add(new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Offices].[ChiefPosition]")); } frmReportViewer frm = new frmReportViewer(rpt); frm.ShowDialog(); } }
private void btnDVPreview_Click(object sender, EventArgs e) { if (OBGridView.GetFocusedRow() is Obligations item) { var rpt = new rptDV() { DataSource = new List <DvReportViewModel>() { new DvReportViewModel(item.Id) } }; //if (new StaticSettings().Offices.IsDivision != true) //{ // foreach (XRControl control in rpt.AllControls<XRControl>().Where(x => x.Tag == "Division")) // { // control.Visible = false; // } //} frmReportViewer frm = new frmReportViewer(rpt); frm.ShowDialog(); } }