protected void SignUp_Click(object sender, EventArgs e) { SampleDataContext context = new SampleDataContext(); List <User> uList = context.Users.Where(u => u.UserID == UserIDTxt.Text).ToList(); if (uList.Count <= 0) { String fname = FnameTxt.Text; String lname = LnameTxt.Text; String uid = UserIDTxt.Text; String email = EmailTxt.Text; DateTime bday = DateTime.Parse(TextBoxDOB.Text); String gender = GenderButtonList.SelectedValue; String pass = PassTxt.Text; int age = new DateTime((DateTime.Now - Convert.ToDateTime(bday)).Ticks).Year; User user = new User() { FirstName = fname, LastName = lname, UserID = uid, BirthDate = bday, Age = age, Gender = gender, Password = pass, Type = "User", Email = email }; context.Users.InsertOnSubmit(user); context.SubmitChanges(); String specialist = DropDownListSpecialist.SelectedValue; int experience = Int32.Parse(ExperienceTxt.Text); Doctor doc = new Doctor() { DocID = user.id, Specialist = specialist, Experience = experience }; context.Doctors.InsertOnSubmit(doc); context.SubmitChanges(); ResultText.Visible = true; NameTaken.Visible = false; } else { NameTaken.Visible = true; ResultText.Visible = false; } }
protected void UpdateProfile_Click(object sender, EventArgs e) { SampleDataContext context = new SampleDataContext(); User user = (User)Session["user"]; String fname = FnameTxt.Text; String lname = LnameTxt.Text; String email = EmailTxt.Text; DateTime bday = DateTime.Parse(TextBoxDOB.Text); String gender = GenderButtonList.SelectedValue; int age = DateTime.Now.Year - bday.Year; var userToUpdate = (from u in context.Users where u.UserID == user.UserID select u).First(); userToUpdate.FirstName = fname; userToUpdate.LastName = lname; userToUpdate.Email = email; userToUpdate.BirthDate = bday; userToUpdate.Gender = gender; userToUpdate.Age = age; context.SubmitChanges(); ResultText.Visible = true; SessionInfoUpdate(user.UserID, user.Password); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = Int32.Parse(GridView1.Rows[e.RowIndex].Cells[0].Text); SampleDataContext sContext = new SampleDataContext(); var user = sContext.Users.FirstOrDefault(s => s.id == id); if (user != null) { sContext.Users.DeleteOnSubmit(user); sContext.SubmitChanges(); } loadUser(); }
protected void ChangePassBtn_Click(object sender, EventArgs e) { SampleDataContext context = new SampleDataContext(); User user = (User)Session["user"]; if (changepassTxt.Text == user.Password) { var userToUpdate = (from u in context.Users where u.UserID == user.UserID select u).First(); userToUpdate.Password = PassTxt.Text; context.SubmitChanges(); ChangePassText.Visible = true; SessionInfoUpdate(user.UserID, userToUpdate.Password); } else { wrongpassTxt.Visible = false; } }