-
Notifications
You must be signed in to change notification settings - Fork 0
/
RelatorioManutencao.aspx.cs
131 lines (114 loc) · 4.18 KB
/
RelatorioManutencao.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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 iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
namespace SlnArCond
{
public partial class RelatorioManutencao : System.Web.UI.Page
{
DateTime Data1;
DateTime Data2;
protected void Page_Load(object sender, EventArgs e)
{
List<pFuncionario> Lp = Session["Login"] as List<pFuncionario>;
if (Lp == null)
{
Response.Redirect("Login.aspx");
}
else if (Lp[0].Cargo == "Atendente")
{
Msg("Você não tem autorização");
}
else if (Lp[0].Cargo == "Gerente")
{
Msg("Você não tem autorização");
}
else if (Lp[0].Cargo == "Administrador")
{
Geral.Visible = true;
}
}
private void Msg(string Aviso)
{
Response.Write("<script>alert('" + Aviso + "');</script>");
}
protected void btnBuscarData_Click(object sender, EventArgs e)
{
if (txtData1.Text == string.Empty)
{
Msg("Selecione a data!");
return;
}
else if (txtData2.Text == string.Empty)
{
Msg("Selecione a data!");
return;
}
else
{
Data1 = Convert.ToDateTime(txtData1.Text);
Data2 = Convert.ToDateTime(txtData2.Text);
mManuAr M = new mManuAr();
List<pDataManu> LC = M.RelatorioManutencaoData(Data1, Data2);
gdvManu.DataSource = LC;
gdvManu.DataBind();
//Codigo = Codigo + gdvListaPecas.Rows.Count;
//txtTotalVenda.Text = Convert.ToString(Codigo);
//for (int i = 0; i < LC.Count; i++)
//{
// Valor = Valor + LC[i].ValorTotal;
//}
//txtTotalValor.Text = Convert.ToString(Valor);
RelManu.Visible = true;
lblHed.Text = ("Inicial - " + Data1.ToString("dd/MM/yyyy") + " Final - " + Data2.ToString("dd/MM/yyyy"));
}
}
protected void btnBuscarStatus_Click(object sender, EventArgs e)
{
mManuAr M = new mManuAr();
List<pDataManu> LC = M.RelatorioManutencaoStatus(ddlStatus.Text);
gdvManu.DataSource = LC;
gdvManu.DataBind();
lblHed.Text = ("Status da manutenção : " + ddlStatus.Text);
RelManu.Visible = true;
}
protected void btnPdf_Click(object sender, EventArgs e)
{
Msg("PDF gerado com sucesso!");
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Relatorio.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
RelManu.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4.Rotate(), 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfPage page = new pdfPage();
pdfWriter.PageEvent = page;
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
Response.Write(pdfDoc);
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
txtData1.Text = Calendar1.SelectedDate.ToString("dd/MM/yyyy");
}
protected void Calendar2_SelectionChanged(object sender, EventArgs e)
{
txtData2.Text = Calendar2.SelectedDate.ToString("dd/MM/yyyy");
}
}
}