protected void btnRegister_Click(object sender, EventArgs ev) { if (checkValidation()) { System.Threading.Thread.Sleep(1500); using (ModelTutor obj = new ModelTutor()) { string email = txtEmail.Text.Trim(); var result = (from e in obj.tblStudents where e.Email == email select e).Count(); if (result < 1) { tblStudent newStudent = new tblStudent { Id = txtStudentId.Text.Trim(), Name = txtName.Text.Trim(), Address = txtAddress.Text.Trim(), Email = txtEmail.Text.Trim(), Password = txtPassword.Text.Trim(), Active = true }; try { obj.AddTotblStudents(newStudent); obj.SaveChanges(); Response.Redirect("~/Sucess.aspx?m=Your account has been sucessfuly registered. Login to book tutor."); } catch (Exception) { } } else { Label1.Text = "Email already exist"; } } } }
/// <summary> /// Deprecated Method for adding a new object to the tblStudents EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotblStudents(tblStudent tblStudent) { base.AddObject("tblStudents", tblStudent); }
/// <summary> /// Create a new tblStudent object. /// </summary> /// <param name="studentId">Initial value of the StudentId property.</param> /// <param name="id">Initial value of the Id property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="email">Initial value of the Email property.</param> public static tblStudent CreatetblStudent(global::System.Int32 studentId, global::System.String id, global::System.String name, global::System.String email) { tblStudent tblStudent = new tblStudent(); tblStudent.StudentId = studentId; tblStudent.Id = id; tblStudent.Name = name; tblStudent.Email = email; return tblStudent; }