protected void ButtonEdit_Click(object sender, EventArgs e) { ServiceReference1.MdlLandlord landlord = new ServiceReference1.MdlLandlord(); landlord.Email = Session["Email"].ToString().Trim(); landlord.Name = TextBoxName.Text; landlord.Contact_person = TextBoxContactAndSurname.Text; landlord.Address = TextBoxAddress.Text; landlord.PostCode = TextBoxPostCode.Text; landlord.City = TextBoxCity.Text; landlord.Country = TextBoxCountry.Text; landlord.Phone = TextBoxPhone.Text; client.EditLandlordProfile(landlord); Session["Name"] = TextBoxName.Text; Session["ContactPerson"] = TextBoxContactAndSurname.Text; Session["Address"] = TextBoxAddress.Text; Session["PostCode"] = TextBoxPostCode.Text; Session["City"] = TextBoxCity.Text; Session["Country"] = TextBoxCountry.Text; Session["Phone"] = TextBoxPhone.Text; if (client.EditLandlordProfile(landlord) == true) { LabelEditProfile.Text = "Profile was updated successfully"; } else { LabelEditProfile.Text = "Profile update failed"; } }
protected void ButtonLogin_Click(object sender, EventArgs e) { client.Login(TextBoxEmailLogin.Text, TextBoxPasswordLogin.Text); Response.Write(client.Login(TextBoxEmailLogin.Text, TextBoxPasswordLogin.Text)); if (client.Login(TextBoxEmailLogin.Text, TextBoxPasswordLogin.Text).Trim().Equals("You have successfully logged in.")) { Session["New"] = TextBoxEmailLogin.Text; if (client.GetUserType(TextBoxEmailLogin.Text).Trim().Equals("Student")) { ServiceReference1.MdlStudent student = (ServiceReference1.MdlStudent)client.GetStudentData(TextBoxEmailLogin.Text); storeStudentObjToSession(student); Response.Redirect("MainPageStudent.aspx"); } else { ServiceReference1.MdlLandlord landlord = (ServiceReference1.MdlLandlord)client.GetLandlordData(TextBoxEmailLogin.Text); storeLandlordObjToSession(landlord); Response.Redirect("MainPageLandlord.aspx"); } } else { LabelNotCorrect.Visible = true; } }
protected void ButtonEdit_Click(object sender, EventArgs e) { ServiceReference1.MdlLandlord landlord = new ServiceReference1.MdlLandlord(); landlord.Email = Session["Email"].ToString().Trim(); landlord.Name = TextBoxName.Text; landlord.Contact_person = TextBoxContactAndSurname.Text; landlord.Address = TextBoxAddress.Text; landlord.PostCode = TextBoxPostCode.Text; landlord.City = TextBoxCity.Text; landlord.Country = TextBoxCountry.Text; landlord.Phone = TextBoxPhone.Text; client.EditLandlordProfile(landlord); Session["Name"] = TextBoxName.Text; Session["ContactPerson"] = TextBoxContactAndSurname.Text; Session["Address"] = TextBoxAddress.Text; Session["PostCode"] = TextBoxPostCode.Text; Session["City"] = TextBoxCity.Text; Session["Country"] = TextBoxCountry.Text; Session["Phone"] = TextBoxPhone.Text; if(client.EditLandlordProfile(landlord) == true) { LabelEditProfile.Text = "Profile was updated successfully"; } else { LabelEditProfile.Text = "Profile update failed"; } }
private void storeLandlordObjToSession(ServiceReference1.MdlLandlord landlord) { Session["Email"] = landlord.Email.ToString(); Session["Confirmed"] = Convert.ToBoolean(landlord.Confirmed); Session["DateOfCreation"] = Convert.ToDateTime(landlord.Date_of_creation); Session["Name"] = landlord.Name.ToString(); Session["ContactPerson"] = landlord.Contact_person.ToString(); Session["Address"] = landlord.Address.ToString(); Session["PostCode"] = landlord.PostCode.ToString(); Session["City"] = landlord.City.ToString(); Session["Country"] = landlord.Country.ToString(); Session["Phone"] = landlord.Phone.ToString(); Session["Type"] = "Landlord"; }
protected void ButtonRegister_Click(object sender, EventArgs e) { if (IsPostBack) { try { if (DropDownListType.SelectedValue == "Landlord") { ServiceReference1.MdlLandlord landlord = new ServiceReference1.MdlLandlord(); landlord.Address = TextBoxAddress.Text; landlord.City = TextBoxCity.Text; landlord.Contact_person = TextBoxSurnameAndContact.Text; landlord.Country = TextBoxCountry.Text; landlord.Email = TextBoxEmail.Text; landlord.Name = TextBoxName.Text; landlord.Password = TextBoxPassword.Text; landlord.Phone = TextBoxPhone.Text; landlord.PostCode = TextBoxPostCode.Text; if (client.AddLandlord(landlord).Trim().Equals("Registration successful.")) { LabelRegistration.Text = "Registration successful."; ClearFields(); } else if (client.AddLandlord(landlord).Trim().Equals("Registration has failed due to the existing Email.")) { LabelRegistration.Text = "Registration has failed due to the existing Email."; } else { LabelRegistration.Text = "Unable to connect to database."; } } else if (DropDownListType.SelectedValue == "Student") { ServiceReference1.WcfEFlatsServiceClient client = new ServiceReference1.WcfEFlatsServiceClient(); ServiceReference1.MdlStudent student = new ServiceReference1.MdlStudent(); student.Address = TextBoxAddress.Text; student.City = TextBoxCity.Text; student.Surname = TextBoxSurnameAndContact.Text; student.Country = TextBoxCountry.Text; student.Email = TextBoxEmail.Text; student.Name = TextBoxName.Text; student.Password = TextBoxPassword.Text; student.Phone = TextBoxPhone.Text; student.PostCode = TextBoxPostCode.Text; if (client.AddStudent(student).Trim().Equals("Registration successful.")) { LabelRegistration.Text = "Registration successful."; ClearFields(); } else if (client.AddStudent(student).Trim().Equals("Registration has failed due to the existing Email.")) { LabelRegistration.Text = "Registration has failed due to the existing Email."; } else { LabelRegistration.Text = "Unable to connect to the database"; } } } catch { Response.Redirect("ErrorPage.aspx"); } } }