forked from HassanAfnan/DayCareWebsite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserSlip.aspx.cs
74 lines (71 loc) · 2.59 KB
/
UserSlip.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
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;
using System.Data.SqlClient;
namespace DayCareWebsite
{
public partial class UserSlip : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string em = "";
string id = "";
string fee = "";
Classes.FeeSlip fe = new Classes.FeeSlip();
if (Session["UserInfo"] == null)
{
Response.Write("<script>alert('Please login first')</script>");
Response.Redirect("login.aspx");
}
else
{
em = Session["UserInfo"].ToString();
}
Classes.Connection connection = new Classes.Connection();
connection.getConnection();
SqlCommand com = new SqlCommand("select Uid,CName,GName from UserReg where email = '"+em+"'",connection.con);
SqlDataReader rd = com.ExecuteReader();
while (rd.Read())
{
id = rd["Uid"].ToString();
fe.ChildName = rd["CName"].ToString();
fe.GardianName = rd["GName"].ToString();
}
rd.Close();
SqlCommand com1 = new SqlCommand("select Ammount from Fee where Uid = '"+id+"'",connection.con);
SqlDataReader rd1 = com1.ExecuteReader();
while (rd1.Read())
{
fee = rd1["Ammount"].ToString();
}
if(fee == "")
{
fe.Fee = "";
}
fe.Fee = fee;
fe.Date = DateTime.Now;
fe.DueDate = "10 days";
fe.Recipt(fe);
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(fe.Recipt(fe));
pdfDoc.Close();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Slip_" + fe.Date + ".pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Write(pdfDoc);
Response.End();
}
}
}