Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8.  
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Web;
  13. using System.Web.UI;
  14. using System.Web.UI.WebControls;
  15. using System.Data.SqlClient;
  16.  
  17. namespace Coursework
  18. {
  19. public partial class Registration : System.Web.UI.Page
  20. {
  21. protected void Page_Load(object sender, EventArgs e)
  22. {
  23. if (Page.IsPostBack == true)
  24. {
  25. successLabel.Text = ("Your submission is now being stored in our database");
  26. }
  27. }
  28.  
  29. protected void parentRadBtn_CheckedChanged(object sender, EventArgs e)
  30. {
  31. if (parentRadBtn.Checked = true)
  32. {
  33. firstNameBox.Text = string.Empty;
  34. surnameBox.Text = string.Empty;
  35. dayDobList.Text = string.Empty;
  36. monthDobList.Text = string.Empty;
  37. yearDobList.Text = string.Empty;
  38. genderList.Text = string.Empty;
  39. postcodeBox.Text = string.Empty;
  40. teleBox.Text = string.Empty;
  41. emailBox.Text = string.Empty;
  42. userBox.Text = string.Empty;
  43. passwordBox.Text = string.Empty;
  44.  
  45. genderList.Enabled = false;
  46. dayDobList.Enabled = false;
  47. monthDobList.Enabled = false;
  48. yearDobList.Enabled = false;
  49.  
  50. surnameBox.Enabled = true;
  51. postcodeBox.Enabled = true;
  52. teleBox.Enabled = true;
  53. emailBox.Enabled = true;
  54.  
  55. successLabel.Text = ("");
  56. }
  57. }
  58.  
  59. protected void passwordBox_TextChanged(object sender, EventArgs e)
  60. {
  61.  
  62. }
  63.  
  64. protected void childRadBtn_CheckedChanged(object sender, EventArgs e)
  65. {
  66. if (childRadBtn.Checked = true)
  67. {
  68. firstNameBox.Text = string.Empty;
  69. surnameBox.Text = string.Empty;
  70. dayDobList.Text = string.Empty;
  71. monthDobList.Text = string.Empty;
  72. yearDobList.Text = string.Empty;
  73. genderList.Text = string.Empty;
  74. postcodeBox.Text = string.Empty;
  75. teleBox.Text = string.Empty;
  76. emailBox.Text = string.Empty;
  77. userBox.Text = string.Empty;
  78. passwordBox.Text = string.Empty;
  79.  
  80. genderList.Enabled = true;
  81. dayDobList.Enabled = true;
  82. monthDobList.Enabled = true;
  83. yearDobList.Enabled = true;
  84.  
  85. surnameBox.Enabled = false;
  86. postcodeBox.Enabled = false;
  87. teleBox.Enabled = false;
  88. emailBox.Enabled = false;
  89.  
  90. successLabel.Text = ("");
  91. }
  92. }
  93.  
  94. protected void submitBtn_Click(object sender, EventArgs e)
  95. {
  96. SqlConnection connect = new SqlConnection("Data Source=THEBEAST;Initial Catalog=newregDB;Integrated Security=True;Pooling=False");
  97. {
  98. if (parentRadBtn.Checked = true)
  99. {
  100. SqlCommand pa = new SqlCommand("INSERT INTO parent(parentID, firstname, surname, postcode, telephone, email, password) VALUES (@parentID, @firstname, @surname, @postcode, @telephone, @email, @password)", connect);
  101. pa.Parameters.AddWithValue("@parentID", userBox.Text);
  102. pa.Parameters.AddWithValue("@firstname", firstNameBox.Text);
  103. pa.Parameters.AddWithValue("@surname", surnameBox.Text);
  104. pa.Parameters.AddWithValue("@postcode", postcodeBox.Text);
  105. pa.Parameters.AddWithValue("@telephone", teleBox.Text);
  106. pa.Parameters.AddWithValue("@email", emailBox.Text);
  107. pa.Parameters.AddWithValue("@password", passwordBox.Text);
  108.  
  109. connect.Open();
  110. pa.ExecuteNonQuery();
  111. connect.Close();
  112.  
  113. if (IsPostBack)
  114. {
  115. userBox.Text = "";
  116. firstNameBox.Text = "";
  117. surnameBox.Text = "";
  118. postcodeBox.Text = "";
  119. teleBox.Text = "";
  120. emailBox.Text = "";
  121. passwordBox.Text = "";
  122. }
  123. if (childRadBtn.Checked = true)
  124. {
  125. SqlCommand ca = new SqlCommand("INSERT INTO children(childID, firstname, dob, gender, password) VALUES (@childID, @firstname, @dob, @gender, @password)", connect);
  126. ca.Parameters.AddWithValue("@childID", userBox.Text);
  127. ca.Parameters.AddWithValue("@firstname", firstNameBox.Text);
  128. ca.Parameters.AddWithValue("@dob", dayDobList.Text + monthDobList.Text + yearDobList.Text);
  129. ca.Parameters.AddWithValue("@gender", genderList.Text);
  130. ca.Parameters.AddWithValue("@password", passwordBox.Text);
  131.  
  132. connect.Open();
  133. ca.ExecuteNonQuery();
  134. connect.Close();
  135.  
  136. if (IsPostBack)
  137. {
  138. userBox.Text = "";
  139. firstNameBox.Text = "";
  140. dayDobList.Text = "";
  141. monthDobList.Text = "";
  142. yearDobList.Text = "";
  143. genderList.Text = "";
  144. passwordBox.Text = "";
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement