-
Notifications
You must be signed in to change notification settings - Fork 2
/
DonateClothes.aspx.cs
61 lines (58 loc) · 2.04 KB
/
DonateClothes.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;
namespace Serving_Hands
{
public partial class DonateClothes : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
GetOrganizationName();
}
}
Models.ClothesSlip cs = new Models.ClothesSlip();
protected void Button1_Click(object sender, EventArgs e)
{
Models.Clothes c = new Models.Clothes();
c.clothes = TextBox1.Text;
c.organization = DropDownList2.Text;
c.date = TextBox2.Text;
c.Add(c);
}
private void GetOrganizationName()
{
DropDownList2.Items.Clear();
foreach (var item in cs.GetOrganization())
{
DropDownList2.Items.Add(Convert.ToString(item.Organization));
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Models.ClothesSlip s = new Models.ClothesSlip();
s.noOfclothes = TextBox1.Text;
s.Organization = DropDownList2.Text;
s.date = TextBox2.Text;
s.Recipt(s);
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
pdfDoc.Open();
htmlparser.Parse(s.Recipt(s));
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Slip_" + s.date + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
}
}