-
Notifications
You must be signed in to change notification settings - Fork 1
/
Default.aspx.cs
55 lines (48 loc) · 2.28 KB
/
Default.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using DevExpress.XtraPrinting;
using System.Net.Mime;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting.Shape;
using System.Drawing;
namespace WebApplication1 {
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void ASPxButton2_Click(object sender, EventArgs e) {
ReportGeneratonHelper generator = new ReportGeneratonHelper();
generator.CustomizeColumnsCollection += new CustomizeColumnsCollectionEventHandler(generator_CustomizeColumnsCollection);
generator.CustomizeColumn += new CustomizeColumnEventHandler(generator_CustomizeColumn);
XtraReport report = generator.GenerateReport(ASPxGridView1, AccessDataSource1);
generator.WritePdfToResponse(Response, "test.pdf", System.Net.Mime.DispositionTypeNames.Attachment.ToString());
}
void generator_CustomizeColumn(object source, ControlCustomizationEventArgs e) {
if(e.FieldName == "Discontinued") {
XRShape control = new XRShape();
control.SizeF = e.Owner.SizeF;
control.LocationF = new System.Drawing.PointF(0, 0);
e.Owner.Controls.Add(control);
control.Shape = new ShapeStar() { StarPointCount = 5, Concavity = 30 };
control.BeforePrint += new BeforePrintEventHandler(control_BeforePrint);
e.IsModified = true;
}
}
void control_BeforePrint(object sender, System.ComponentModel.CancelEventArgs e) {
if(Convert.ToBoolean(((XRShape)sender).Report.GetCurrentColumnValue("Discontinued")) == true)
((XRShape)sender).FillColor = Color.Yellow;
else
((XRShape)sender).FillColor = Color.White;
}
void generator_CustomizeColumnsCollection(object source, ColumnsCreationEventArgs e) {
e.ColumnsInfo[1].ColumnWidth *= 2;
e.ColumnsInfo[4].ColumnWidth += 30;
e.ColumnsInfo[3].ColumnWidth -= 30;
e.ColumnsInfo[e.ColumnsInfo.Count - 1].IsVisible = false;
}
}
}