private void loginButton_Click(object sender, RoutedEventArgs e) { ///Create a Regular Expression Regex regEmail = new Regex(@"^[\w!#$%&'*+\-/=?\^_`{|}~]+(\.[\w!#$%&'*+\-/=?\^_`{|}~]+)*"+ "@"+ @"((([\-\w]+\.)+[a-zA-Z]{2,4})|(([0-9]{1,3}\.){3}[0-9]{1,3}))$"); if (emailTextBox.Text.Equals("") || passwordTextBox.Password.Equals("")) { warningLabel.Content = "Please Enter a Username & Password!"; warningLabel.Visibility = Visibility.Visible; } //Validate Email Address else if (!regEmail.IsMatch(emailTextBox.Text)) { warningLabel.Content = "Please Enter a Valid Email Address"; warningLabel.Visibility = Visibility.Visible; } else { try { //Online Connection Via FreeMySqlHosting.net String myConnection = "SERVER=sql2.freemysqlhosting.net;PORT=3306;DATABASE=sql292370;UID=sql292370;password=gA4*tV5%;"; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand SelectCommand = new MySqlCommand("SELECT * FROM sql292370.Users WHERE email = '" + this.emailTextBox.Text.ToLower() + "' AND password = '******';", myConn); MySqlDataReader myReader; myConn.Open(); myReader = SelectCommand.ExecuteReader(); if (myReader.Read()) { warningLabel.Content = "Logged in Successfully!"; warningLabel.Visibility = Visibility.Visible; myConn.Close(); // Send Active User to Home Page Home myHome = new Home(); myHome.activeUserLabel.Content = emailTextBox.Text; // Navigate to Home Page this.NavigationService.Navigate(myHome); } else { warningLabel.Content = "Incorrect Username or Password!"; warningLabel.Visibility = Visibility.Visible; passwordTextBox.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
// Home button private void feHomeBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { Home myHome = new Home(); myHome.activeUserLabel.Content = activeUserLabel.Content.ToString(); this.NavigationService.Navigate(myHome); }
private void submitBtn_Click(object sender, RoutedEventArgs e) { //Get values from eventDetails page string latitude = cordLatTb.Text; string longitude = cordLongTb.Text; string eventName = eventNameTb.Text; string eventSubtitle = eventSutitleTb.Text; string email = activeUserLabel.Content.ToString(); string description = descriptionTb.Text; string startTime = ""; string endTime = ""; string eventGroup = ""; if (startTimeComboBox.SelectedIndex > -1) { startTime = startTimeComboBox.SelectedValue.ToString(); if (startTime == "00:00") { startTime = "00:01"; } } else { MessageBox.Show("Please select a start time", "Important Message"); } if (endTimeComboBox.SelectedIndex > -1) { endTime = endTimeComboBox.SelectedValue.ToString(); if (endTime == "24:00") { endTime = "23:59"; } } else { MessageBox.Show("Please select an end time", "Important Message"); } if (eventGroupComboBox.SelectedIndex > -1) { eventGroup = eventGroupComboBox.SelectedValue.ToString(); } else { MessageBox.Show("Please select a group", "Important Message"); } //Get date from datePicker and force it to yyyy-mm-dd format for mySQL string date = datePicker.SelectedDate.Value.ToString("yyyy-MM-dd"); if (latitude.Equals("") || longitude.Equals("") || eventName.Equals("") || description.Equals("") || startTime.Equals("") || endTime.Equals("") || date.Equals("") || eventSubtitle.Equals("") || eventGroup.Equals("")) { MessageBox.Show("You must fill each field to continue", "Important Message"); } else { try { //Online Connection Via FreeMySqlHosting.net //Needs to be updated to use prepared statements String myConn = "SERVER=sql2.freemysqlhosting.net;PORT=3306;DATABASE=sql292370;UID=sql292370;password=gA4*tV5%;"; String query = "INSERT INTO sql292370.Events (email, eventName, eventDescription, startTime, endTime, eventDate, latitude, longitude, eventSubtitle, eventGroup) VALUES ('" + email + "','" + eventName + "','" + description + "','" + startTime + "','" + endTime + "','" + date + "','" + latitude + "','" + longitude + "','" + eventSubtitle + "','" + eventGroup + "') ;"; MySqlConnection ConnectDatabase = new MySqlConnection(myConn); MySqlCommand InsertCommand = new MySqlCommand(query, ConnectDatabase); MySqlDataReader myReader; ConnectDatabase.Open(); myReader = InsertCommand.ExecuteReader(); ConnectDatabase.Close(); // Send Active User to Home Page Home myHome = new Home(); myHome.activeUserLabel.Content = activeUserLabel.Content.ToString(); //Navigate to Home Page this.NavigationService.Navigate(myHome); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void edHomeBtn_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { // Send Active User to Home Page Home myHome = new Home(); myHome.activeUserLabel.Content = activeUserLabel.Content.ToString(); //Navigate to Home Page this.NavigationService.Navigate(myHome); }