Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Data.OleDb;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Web;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10.  
  11. public partial class Register : System.Web.UI.Page
  12. {
  13. FutureProspects site;
  14. protected void Page_Load(object sender, EventArgs e)
  15. {
  16. lblErrorReg.Text = "";
  17. if (Session["currentSite"] == null)
  18. {
  19. site = new FutureProspects();
  20. Session["currentSite"] = site;
  21. }
  22. else
  23. {
  24. site = (FutureProspects)Session["currentSite"];
  25. }
  26. }
  27.  
  28. protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  29. {
  30.  
  31. }
  32.  
  33. protected void btnRegRegister_Click(object sender, EventArgs e)
  34. {
  35. string title = dropDownRegTitle.Text;
  36. string fName = txtRegFirstName.Text;
  37. string mName = txtRegMiddleName.Text;
  38. string lName = txtRegSurname.Text;
  39. string maiden = txtRegMaidenName.Text;
  40. int day = int.Parse(txtRegDay.Text);
  41. int month = int.Parse(txtRegMonth.Text);
  42. int year = int.Parse(txtRegYear.Text);
  43. DateTime DOB = new DateTime(year, month, day);
  44. string gender = dropDownRegGender.Text;
  45. string telNum = txtRegTelNum.Text;
  46. string mobNum = txtRegMobNum.Text;
  47. string email = txtRegEmail.Text;
  48. string ID = "01";
  49. string street = txtRegStreet.Text;
  50. string town = txtRegTown.Text;
  51. string city = txtRegCity.Text;
  52. string county = txtRegCounty.Text;
  53. string country = txtRegCountry.Text;
  54. string postcode = txtRegPostcode.Text;
  55. string disabilities = txtRegDisabilities.Text;
  56. string type = "Full-Time";
  57. string password = txtRegPassword.Text;
  58. string confirmPass = txtRegConfirmPassword.Text;
  59. Address address = new Address(ID, street, town, city, county, country, postcode, type);
  60.  
  61. string message = "";
  62. string error = "";
  63.  
  64. if (password == confirmPass)
  65. {
  66. String connectionString = ConfigurationManager.ConnectionStrings["StuartRossDB"].ConnectionString;
  67. OleDbConnection connection = new OleDbConnection(connectionString);
  68. string query = "INSERT INTO Student (Title, FirstName, MiddleName, LastName, MaidenName, Gender, DateOfBirth, TelNum, MobNum, Email, Disabilities, Address, Password) VALUES('"
  69. + title + "','"
  70. + fName + "','"
  71. + mName + "','"
  72. + lName + "','"
  73. + maiden + "','"
  74. + gender + "','"
  75. + DOB + "','"
  76. + telNum + "','"
  77. + mobNum + "','"
  78. + email + "','"
  79. + disabilities + "','"
  80. + address + "','"
  81. + password + "')";
  82.  
  83. OleDbCommand command = new OleDbCommand(query, connection);
  84.  
  85. try
  86. {
  87.  
  88. connection.Open();
  89. command.ExecuteNonQuery();
  90.  
  91. }
  92. catch (Exception ex)
  93. {
  94. message = ex.ToString();
  95. }
  96.  
  97. connection.Close();
  98.  
  99.  
  100.  
  101. }
  102. else
  103. {
  104. error = "Error: Passwords Do Not Match";
  105. }
  106.  
  107. lblErrorReg.Text = error;
  108. }
  109.  
  110. protected void Button1_Click(object sender, EventArgs e)
  111. {
  112. Response.Redirect("SignIn.aspx");
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement