Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data.SqlClient;
- namespace Coursework
- {
- public partial class Registration : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (Page.IsPostBack == true)
- {
- successLabel.Text = ("Your submission is now being stored in our database");
- }
- }
- protected void parentRadBtn_CheckedChanged(object sender, EventArgs e)
- {
- if (parentRadBtn.Checked = true)
- {
- firstNameBox.Text = string.Empty;
- surnameBox.Text = string.Empty;
- dayDobList.Text = string.Empty;
- monthDobList.Text = string.Empty;
- yearDobList.Text = string.Empty;
- genderList.Text = string.Empty;
- postcodeBox.Text = string.Empty;
- teleBox.Text = string.Empty;
- emailBox.Text = string.Empty;
- userBox.Text = string.Empty;
- passwordBox.Text = string.Empty;
- genderList.Enabled = false;
- dayDobList.Enabled = false;
- monthDobList.Enabled = false;
- yearDobList.Enabled = false;
- surnameBox.Enabled = true;
- postcodeBox.Enabled = true;
- teleBox.Enabled = true;
- emailBox.Enabled = true;
- successLabel.Text = ("");
- }
- }
- protected void passwordBox_TextChanged(object sender, EventArgs e)
- {
- }
- protected void childRadBtn_CheckedChanged(object sender, EventArgs e)
- {
- if (childRadBtn.Checked = true)
- {
- firstNameBox.Text = string.Empty;
- surnameBox.Text = string.Empty;
- dayDobList.Text = string.Empty;
- monthDobList.Text = string.Empty;
- yearDobList.Text = string.Empty;
- genderList.Text = string.Empty;
- postcodeBox.Text = string.Empty;
- teleBox.Text = string.Empty;
- emailBox.Text = string.Empty;
- userBox.Text = string.Empty;
- passwordBox.Text = string.Empty;
- genderList.Enabled = true;
- dayDobList.Enabled = true;
- monthDobList.Enabled = true;
- yearDobList.Enabled = true;
- surnameBox.Enabled = false;
- postcodeBox.Enabled = false;
- teleBox.Enabled = false;
- emailBox.Enabled = false;
- successLabel.Text = ("");
- }
- }
- protected void submitBtn_Click(object sender, EventArgs e)
- {
- SqlConnection connect = new SqlConnection("Data Source=THEBEAST;Initial Catalog=newregDB;Integrated Security=True;Pooling=False");
- {
- if (parentRadBtn.Checked = true)
- {
- SqlCommand pa = new SqlCommand("INSERT INTO parent(parentID, firstname, surname, postcode, telephone, email, password) VALUES (@parentID, @firstname, @surname, @postcode, @telephone, @email, @password)", connect);
- pa.Parameters.AddWithValue("@parentID", userBox.Text);
- pa.Parameters.AddWithValue("@firstname", firstNameBox.Text);
- pa.Parameters.AddWithValue("@surname", surnameBox.Text);
- pa.Parameters.AddWithValue("@postcode", postcodeBox.Text);
- pa.Parameters.AddWithValue("@telephone", teleBox.Text);
- pa.Parameters.AddWithValue("@email", emailBox.Text);
- pa.Parameters.AddWithValue("@password", passwordBox.Text);
- connect.Open();
- pa.ExecuteNonQuery();
- connect.Close();
- if (IsPostBack)
- {
- userBox.Text = "";
- firstNameBox.Text = "";
- surnameBox.Text = "";
- postcodeBox.Text = "";
- teleBox.Text = "";
- emailBox.Text = "";
- passwordBox.Text = "";
- }
- if (childRadBtn.Checked = true)
- {
- SqlCommand ca = new SqlCommand("INSERT INTO children(childID, firstname, dob, gender, password) VALUES (@childID, @firstname, @dob, @gender, @password)", connect);
- ca.Parameters.AddWithValue("@childID", userBox.Text);
- ca.Parameters.AddWithValue("@firstname", firstNameBox.Text);
- ca.Parameters.AddWithValue("@dob", dayDobList.Text + monthDobList.Text + yearDobList.Text);
- ca.Parameters.AddWithValue("@gender", genderList.Text);
- ca.Parameters.AddWithValue("@password", passwordBox.Text);
- connect.Open();
- ca.ExecuteNonQuery();
- connect.Close();
- if (IsPostBack)
- {
- userBox.Text = "";
- firstNameBox.Text = "";
- dayDobList.Text = "";
- monthDobList.Text = "";
- yearDobList.Text = "";
- genderList.Text = "";
- passwordBox.Text = "";
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement