private void Window_Loaded(object sender, RoutedEventArgs e) { User user = new User(); var query = (from c in db.Competitions join m in db.Members on c.airc_id equals m.airc_id join rc in db.Clubs on c.club_id equals rc.club_id where c.competition_status == "S" && c.competition_date >= currentDate && c.competition_date.Year == currentyear orderby c.competition_date ascending select new { next_competition_date = c.competition_date, c.competition_id, c.competition_name, c.competition_type, competition_venue = c.venue, Secretary = c.Member.first_name + " " + c.Member.last_name, hosting_club = c.Club.clubname, c.club_id, secretary_airc_id = m.airc_id }).Take(1); foreach (var record in query) { tbxCompetitionDate.Text = record.next_competition_date.ToString(); tbxCompetitionName.Text = record.competition_name; tbxCompetitionVenue.Text = record.competition_venue; tbxCompetitionSecretary.Text = record.Secretary; tbxHostingClub.Text = record.hosting_club; club_id = record.club_id; competition_id = record.competition_id; competition_type = record.competition_type; secretary_airc_id = record.secretary_airc_id; } if (member_role == "M") { btnAddClub.Visibility = Visibility.Collapsed; btnAddCompetition.Visibility = Visibility.Collapsed; btnListNewMembers.Visibility = Visibility.Collapsed; btnModifyMemberDetails.Visibility = Visibility.Collapsed; btnModifyMyDetails.Visibility = Visibility.Visible; btnOpenCompetition.Visibility = Visibility.Collapsed; btnViewLeaderboard.Visibility = Visibility.Visible; btnViewReports.Visibility = Visibility.Visible; btnViewScheduledCompetitions.Visibility = Visibility.Visible; btnOpenCompetition.Visibility = Visibility.Collapsed; } if (member_role == "S") { btnAddClub.Visibility = Visibility.Collapsed; btnAddCompetition.Visibility = Visibility.Visible; btnListNewMembers.Visibility = Visibility.Visible; btnModifyMemberDetails.Visibility = Visibility.Visible; btnModifyMyDetails.Visibility = Visibility.Visible; btnOpenCompetition.Visibility = Visibility.Collapsed; btnViewLeaderboard.Visibility = Visibility.Visible; btnViewReports.Visibility = Visibility.Visible; btnViewScheduledCompetitions.Visibility = Visibility.Visible; btnOpenCompetition.Visibility = Visibility.Collapsed; } if (member_role == "A") { btnAddClub.Visibility = Visibility.Visible; btnAddCompetition.Visibility = Visibility.Visible; btnListNewMembers.Visibility = Visibility.Visible; btnModifyMemberDetails.Visibility = Visibility.Visible; btnModifyMyDetails.Visibility = Visibility.Visible; btnViewLeaderboard.Visibility = Visibility.Visible; btnViewReports.Visibility = Visibility.Visible; btnViewScheduledCompetitions.Visibility = Visibility.Visible; btnOpenCompetition.Visibility = Visibility.Collapsed; } //if (tbxCompetitionDate.Text.ToString() == currentDate.ToString() ) //{ if (secretary_airc_id == airc_id) { btnOpenCompetition.Visibility = Visibility.Visible; } //} MainDashboard maindashboard = new MainDashboard(); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { string currentUser = tbxUsername.Text; string currentPassword = tbxPassword.Password; if (activeTab == "Logon") { //var query = (from c in db.Competitions // join m in db.Members on c.airc_id equals m.airc_id // join rc in db.Clubs on c.club_id equals rc.club_id // where c.competition_status == "S" && c.competition_date >= currentDate // && c.competition_date.Year == currentyear // orderby c.competition_date ascending // select new // { // next_competition_date = c.competition_date, // c.competition_id, // c.competition_name, // c.competition_type, // competition_venue = c.venue, // Secretary = c.Member.first_name + " " + c.Member.last_name, // hosting_club = c.Club.clubname // }).Take(1); var query = (from u in db.Users join m in db.Members on u.airc_id equals m.airc_id where u.username == tbxUsername.Text && u.userpassword == tbxPassword.Password select new { m.role, u.username, u.userpassword, u.airc_id }); foreach (var record in query) { //LoggedInUser = User.airc_id; MainDashboard maindashboard = new MainDashboard(); this.Hide(); close = true; maindashboard.tbxUsername.Text = record.username; maindashboard.airc_id = record.airc_id; maindashboard.member_role = record.role; maindashboard.ShowDialog(); } // By Default if we reach here that means we have an invalid username and/or password entered if (close == false) { MessageBox.Show($"Incorrect username or Password"); } } else if (activeTab == "Register") { // call Register user Class airc_id = Convert.ToInt16(tbxAIRC_ID.Text.Trim()); string role = "M"; //Role is Member string memberStatus = "N"; //Member status is "N" for new Membe RegisterUser( airc_id, currentUser, currentPassword); SaveRegistration(); RegisterMember( airc_id, club_id, memberStatus, role, tbxFirstname.Text.Trim(), tbxLastName.Text.Trim(), DRgrade.Trim(), SJgrade.Trim(), XCgrade.Trim(), tbxPhone.Text, tbxEmail.Text); // SaveRegistration(); MessageBox.Show($"Your user {currentUser} has been saved. Please login again with your username and password"); this.Close(); } }