Esempio n. 1
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var storage = IsolatedStorageSettings.ApplicationSettings;

            var languages = new List<LanguageModel>();
            languages.Add(new LanguageModel("Danish", "http://da.wikipedia.org"));
            languages.Add(new LanguageModel("English", "http://en.wikipedia.org"));
            languages.Add(new LanguageModel("Norwegian", "http://no.wikipedia.org"));
            languages.Add(new LanguageModel("Swedish", "http://sv.wikipedia.org"));

            languageListPicker.ItemsSource = languages;

            if (storage.Contains("setting_language"))
            {
                var language = storage["setting_language"] as LanguageModel;

                if (language != null)
                {
                    var listLanguage = languages.SingleOrDefault(l => l.Name == language.Name);
                    if (listLanguage != null)
                        languageListPicker.SelectedItem = listLanguage;
                }
            }
        }
        private async void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            string username = UserNameTextBox.Text;
            string password = PasswordTextBox.Password;

            //username = "******";
            //password = "******";

            try
            {
                userList = EmployeeService.GetLoggedEmployeeByUserNamePassword(username, password);

                if (userList.Count() == 1)
                {
                    Session.LoggedEmployee = userList.SingleOrDefault();
                    Session.Account_Type = userList.SingleOrDefault().ACCOUNT_TYPE;
                    Session.EmployeeID = userList.SingleOrDefault().EMP_ID;
                                      
                    MainWindow.Instance.Show();
                    ShouldClose = true;
                    this.Close();
                }
                else
                {
                    await this.ShowMessageAsync("Login Error", "Please check your username and password", MessageDialogStyle.Affirmative);
                    UserNameTextBox.Clear();
                    PasswordTextBox.Clear();
                }
            }
            catch (Exception ex)
            {
                capturedException=ex;
            }
            if (capturedException != null)
            {
                await this.ShowMessageAsync("Login Error", capturedException.Message.ToString(), MessageDialogStyle.Affirmative);
            }
        }