private void HubWindowButton_Click(object sender, RoutedEventArgs e) { HubWindow newWindow = new HubWindow(Convert.ToInt32(mainWindow.TryGetUserProperty(currentUserID, "ID"))); this.Close(); newWindow.ShowDialog(); }
private void Button_Click(object sender, RoutedEventArgs e) { if (textboxID.Text.Count() <= 6) { if (System.Text.RegularExpressions.Regex.IsMatch(textboxID.Text, @"^[\d*]*$") && int.TryParse(textboxID.Text, out int resultID)) { currentUserID = resultID; if (Convert.ToInt32(TryGetUserProperty(currentUserID, "ID")) == currentUserID) { CheckDay(); if (Convert.ToBoolean(TryGetUserProperty(currentUserID, "locked")) == false) { if (numberOfAttempts != 0) { inputArray[indexCounter] = Convert.ToInt32(((Button)sender).Content); indexCounter++; Display(displayArray, "check"); if (indexCounter == 6) { string code = String.Join("", inputArray); if (TryGetUserProperty(currentUserID, "code") == code) { Display(displayArray, "correct"); MessageBox.Show($"Welkom {TryGetUserProperty(currentUserID, "name")}"); HubWindow newWindow = new HubWindow(Convert.ToInt32(TryGetUserProperty(currentUserID, "ID"))); this.Hide(); //Mainwindow can't close else app closes newWindow.ShowDialog(); } else { numberOfAttempts--; Display(displayArray, "incorrect"); MessageBox.Show($"Incorrecte invoer\n{numberOfAttempts} poging(en) resterend."); } Array.Clear(inputArray, 0, inputArray.Length); indexCounter = 0; } } else { TrySetUserLocked(currentUserID, true); } } else { MessageBox.Show($"{TryGetUserProperty(currentUserID, "name")}, U heeft geen toegang"); } } else { MessageBox.Show($"Het verkeerde ID is ingevoerd"); } } else { MessageBox.Show($"Alleen nummers als ID invoeren A.U.B."); } } else { MessageBox.Show($"Het ID mag niet meer dan 6 cijfers lang zijn"); textboxID.Clear(); } }