Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                double price = ((SubscriptionListItem)subscriptionList.SelectedItem).Price;

                if (CurrentUser.CanBuy(price))
                {
                    if (subscriptionList.SelectedIndex == 0)
                    {
                        videoStore.ResetSubscription(CurrentUser.UserID);
                    }
                    else
                    {
                        videoStore.UpdateSubscription(((SubscriptionListItem)subscriptionList.SelectedItem).ID, CurrentUser.UserID);
                    }

                    AppUpdate.ToBuyMovie(price);
                    AppUpdate.UpdateServices();
                    AppUpdate.ChangeButton();

                    ForcedUpdateSubscripion(((SubscriptionListItem)subscriptionList.SelectedItem).ID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                DialogWindowBuySubscription.IsOpen = false;
            }
        }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (!CurrentUser.Authorized)
     {
         AppUpdate.LogonDialogOpen();
         AppUpdate.GoLibrary = false;
     }
     else
     {
         DialogWindowWatchMovie.IsOpen = true;
     }
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         _videoStore.AddMoney(CurrentUser.UserID);
         AppUpdate.UpdateCashValue();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     try
     {
         AppUpdate.ToBuyMovie(Convert.ToDouble(watchPriceValue.Text));
         _videoStore.LessMoney(CurrentUser.UserID, Convert.ToDouble(watchPriceValue.Text));
         DialogWindowWatchMovie.IsOpen = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (CurrentUser.CanBuy(movieModel.Price))
         {
             _videoStore.ToBuyMovie(movieModel.MovieID, CurrentUser.UserID, movieModel.Price);
             AppUpdate.ToBuyMovie(movieModel.Price);
             AppUpdate.ChangeButton();
             ResetButtons(true);
             DialogWindowBuy.IsOpen = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        /// <summary>
        /// Авторизация после успешной регистарции
        /// </summary>
        /// <param name="login"></param>
        /// <param name="password"></param>
        void LoginAfterRegistration(string login, string password)
        {
            try
            {
                var user = videoStore.GetUser(login, password).FirstOrDefault();

                if (user == null)
                {
                    errorMassageTextBox.Text       = "Неверный логин или пароль";
                    errorMassageTextBox.Visibility = Visibility.Visible;
                    return;
                }
                else
                {
                    CurrentUser.SetUserInfo(user.UserID, user.UserName, user.UserSurname, user.UserMiddleName, user.CardBalance, user.CardNumber, user.RegisterDate);

                    userInfoName.Text    = $"{CurrentUser.UserSurname} {CurrentUser.UserName} {CurrentUser.UserMiddlename}";
                    userInfoBalance.Text = CurrentUser.CardBalance.ToString();
                    userInfo.Visibility  = Visibility.Visible;

                    loginButton.Visibility  = Visibility.Collapsed;
                    logoutButton.Visibility = Visibility.Visible;

                    userInfoPage = new UserInfoPage(videoStore);

                    AppUpdate.Update();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                ClearLoginFormValues();
                HideErrors();
            }
        }
Example #7
0
 private void subscriptionList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (CurrentUser.Authorized && !((SubscriptionListItem)subscriptionList.SelectedItem).IsActive)
         {
             priceTextBox.Text = ((SubscriptionListItem)subscriptionList.SelectedItem).Price.ToString();
             DialogWindowBuySubscription.IsOpen = true;
         }
         else if (((SubscriptionListItem)subscriptionList.SelectedItem).IsActive)
         {
             return;
         }
         else
         {
             AppUpdate.GoLibrary = false;
             AppUpdate.LogonDialogOpen();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        /// <summary>
        /// Авторизация
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var user = videoStore.GetUser(loginNameTextBox.Text, loginPasswordBox.Password).FirstOrDefault();

                if (user == null)
                {
                    errorMassageTextBox.Text       = "Неверный логин или пароль";
                    errorMassageTextBox.Visibility = Visibility.Visible;
                    return;
                }
                else
                {
                    CurrentUser.SetUserInfo(user.UserID, user.UserName, user.UserSurname, user.UserMiddleName, user.CardBalance, user.CardNumber, user.RegisterDate);

                    userInfoName.Text    = $"{CurrentUser.UserSurname} {CurrentUser.UserName} {CurrentUser.UserMiddlename}";
                    userInfoBalance.Text = CurrentUser.CardBalance.ToString();
                    userInfo.Visibility  = Visibility.Visible;

                    loginButton.Visibility  = Visibility.Collapsed;
                    logoutButton.Visibility = Visibility.Visible;

                    DialogWindowLogin.IsOpen = false;

                    ClearLoginFormValues();
                    userInfoPage = new UserInfoPage(videoStore);

                    AppUpdate.Update();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }