Пример #1
0
        private async void Login_Clicked(object sender, RoutedEventArgs e)
        {
            UserInfo.UserName = UserName.Text;
            UserInfo.Password = Password.Password;
            //登陆验证模块
            JObject logIn = await API.GetAPI().Login(UserInfo.UserName, UserInfo.Password);

            if ((bool)logIn["state"])
            {
                //登陆成功后
                UserInfo.IsLogged       = true;
                errorMessage.Text       = "";
                Login_Button.Visibility = Visibility.Collapsed;
                NavMenuPrimaryListView.IsItemClickEnabled = true;
                NavMenuBottomListView.IsItemClickEnabled  = true;
                UserInfo.IsLogged = true;
                UserInfoState.Hide();
                matchesVM.AllMatches.Clear();
                JObject Matches = new JObject();
                Matches = await API.GetAPI().queryAllMatchesAsync();

                if ((bool)Matches["state"])
                {
                    foreach (var match in Matches["pingpong"])
                    {
                        matchesVM.AllMatches.Add(new Matches("pingpong", match["title"].ToString(), match["date"].ToString(), match["matchType"].ToString(),
                                                             match["matchLastTime"].ToString(), match["place"].ToString(), match["placeContain"].ToString(), match["sectionPerDay"].ToString(), match["seed"].ToString()));
                    }

                    foreach (var match in Matches["badminton"])
                    {
                        matchesVM.AllMatches.Add(new Matches("badminton", match["title"].ToString(), match["date"].ToString(), match["matchType"].ToString(),
                                                             match["matchLastTime"].ToString(), match["place"].ToString(), match["placeContain"].ToString(), match["sectionPerDay"].ToString(), match["seed"].ToString()));
                    }

                    foreach (var match in Matches["tennis"])
                    {
                        matchesVM.AllMatches.Add(new Matches("tennis", match["title"].ToString(), match["date"].ToString(), match["matchType"].ToString(),
                                                             match["matchLastTime"].ToString(), match["place"].ToString(), match["placeContain"].ToString(), match["sectionPerDay"].ToString(), match["seed"].ToString()));
                    }

                    ContentFrame.Navigate(typeof(Home));
                    TileService.UpdateTileItem();
                }
                else
                {
                    //await new MessageDialog("").ShowAsync();
                }
            }
            else
            {
                //登陆失败后
                errorMessage.Text = (string)logIn["errormessage"];
            }
        }
Пример #2
0
 private void Exit_Clicked(object sender, RoutedEventArgs e)
 {
     UserInfo.UserName       = "";
     UserInfo.Password       = "";
     UserInfo.IsLogged       = false;
     UserName.Text           = "";
     Password.Password       = "";
     Login_Button.Visibility = Visibility.Visible;
     UserInfoState.Hide();
     errorMessage.Text = "";
     ContentFrame.Navigate(typeof(Home));
     BattleVM.GetBattleVM().AllBattles.Clear();
     AthleteVM.GetAthleteVM().AllAthletes.Clear();
     MatchesVM.GetMatchesVM().AllMatches.Clear();
     ResultVM.GetResultVM().AllResults.Clear();
     NavMenuPrimaryListView.IsItemClickEnabled = false;
     NavMenuBottomListView.IsItemClickEnabled  = false;
     NavMenuMatchListView.Visibility           = Visibility.Collapsed;
     NavMenuMatchInfoListView.Visibility       = Visibility.Collapsed;
     API.GetAPI().SignOut();
 }