-
Notifications
You must be signed in to change notification settings - Fork 0
/
profileCreateConfirmation.aspx.cs
107 lines (95 loc) · 3.16 KB
/
profileCreateConfirmation.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class profileCreateConfirmation : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["admin"] == null)
{
Response.Redirect("home.aspx");
}
if (!IsPostBack)
{
if (Session["CreateSession"] != null)
{
SetControlValues(Page);
}
}
}
protected void btnCreate_Click(object sender, EventArgs e)
{
Registrant registrant = new Registrant();
registrant.Active = 1;
PopulateObject(registrant);
Address address = new Address();
PopulateObject(address);
Caretaker caretaker = new Caretaker();
PopulateObject(caretaker);
int newRegID = RegistrantsDB.AddRegistrant(registrant);
address.RegistrantID = newRegID;
caretaker.RegistrantID = newRegID;
int addressID = AddressDB.AddAddress(address);
int caretakerID = CaretakerDB.AddCaretaker(caretaker);
Response.Redirect("profileCreateImages.aspx?RegistrantID=" + newRegID +
"&Origin=Create");
}
protected void btnBack_Click(object sender, EventArgs e)
{
Response.Redirect("profileCreateEContact.aspx");
}
protected void SetControlValues(Control Parent)
{
if (Parent is Label)
{
if (Session[Parent.ID] != null)
{
if (Parent.ID.Substring(0, 3) == "txt")
{
((Label)Parent).Text = Session[Parent.ID].ToString();
}
else if (Parent.ID.Substring(0, 3) == "ddl")
{
((Label)Parent).Text = Formatting.GetDDLValue(Convert.ToInt32(Session[Parent.ID].ToString()), Parent.ID.Substring(3));
}
}
}
else
{
foreach (Control c in Parent.Controls)
{
SetControlValues(c);
}
}
}
protected void PopulateObject(Object obj)
{
PropertyInfo[] objPropInfo = obj.GetType().GetProperties();
foreach (PropertyInfo propInfo in objPropInfo)
{
if (Session["txt" + propInfo.Name.ToString()] != null)
{
if (propInfo.PropertyType.ToString() == "System.String")
{
propInfo.SetValue(obj, Session["txt" + propInfo.Name.ToString()].ToString());
}
else if (propInfo.PropertyType.ToString() == "System.Int32")
{
int txtValue = Convert.ToInt32(Session["txt" + propInfo.Name.ToString()].ToString());
propInfo.SetValue(obj, txtValue);
}
}
else if (Session["ddl" + propInfo.Name.ToString()] != null)
{
int indexValue = Convert.ToInt32(Session["ddl" + propInfo.Name.ToString()].ToString());
string ddlName = propInfo.Name.ToString();
string ddlValue = Formatting.GetDDLValue(indexValue, ddlName);
propInfo.SetValue(obj, ddlValue);
}
}
}
}