public static string LoadQuizes(out Quiz[] items) { return LoadQuizes(out items, 0); }
public static string LoadQuizes(out Quiz[] items, int count) { List<Quiz> itemsList = new List<Quiz>(); items = null; if (con == null) return "Connection is not initialized"; try { SqlCommand command2 = null; if (count < 1) command2 = new SqlCommand("Select * from Quiz", con); else command2 = new SqlCommand("Select TOP " + count + " * from Quiz", con); SqlDataReader sdr1 = command2.ExecuteReader(); while (sdr1.Read()) { Quiz item = new Quiz(); item.ID = (int)sdr1["Quiz_ID"]; item.Description = sdr1["Description"].ToString(); itemsList.Add(item); } sdr1.Close(); } catch (Exception e) { return e.ToString(); } items = itemsList.ToArray(); if (items.Length != 1) return items.Length + " records loaded"; else return items.Length + " record loaded"; }
void SwitchMode() { if (curMode == UIMode.Login) { LoginPage loginPage = contentPanel.Children[0] as LoginPage; curUser = loginPage.login(); if (curUser != null) if (!loginPage.Wait) curMode = UIMode.QuizSelection; else return; } else if (curMode == UIMode.QuizSelection) { if (List.SelectedItem != null) { curMode = UIMode.Questionary; currentQuiz = (List.SelectedItem as ListBoxItem).Tag as Quiz; } } else if (curMode == UIMode.Questionary) { curMode = UIMode.ResultsView; } else if (curMode == UIMode.ResultsView) { curMode = UIMode.QuizSelection; } fadeout.Begin(); }