示例#1
0
 private void wbBrowser_Navigated(object sender, NavigationEventArgs e)
 {
     if (e.Uri.ToString().StartsWith("https://www.facebook.com/connect/login_success.html"))
     {
         AccessToken    = e.Uri.Fragment.Split('&')[0].Replace("#access_token=", "");
         facebookClient = new FacebookClient(AccessToken);
         dynamic me = facebookClient.Get("Me");
         MessageBox.Show($"Đăng nhập Facebook thành công {me.name}");
         Uri  uriPhoto = new Uri("https://graph.facebook.com/" + me.id.ToString() + "/picture/");
         User user     = new User();
         user.Email      = $"{me.id.ToString()}@facebook.com";
         user.Password   = "******";
         user.isRemember = 0;
         if (UserDatabase.Insert(user.Email, user.Password, user.isRemember))
         {
             ProfileDatabase.InsertFaceBook(user.Email, me.name.ToString(), Helpers.ConvertImageToBinary(new System.Windows.Media.Imaging.BitmapImage(uriPhoto)));
         }
         else
         {
         }
         MainControl m = new MainControl(user, AccessToken);
         m.Show();
         Window.GetWindow(this).Hide();
     }
 }
示例#2
0
        private void updateStateDorm(object sender, string msg, int state)
        {
            Button   button = sender as Button;
            BookDorm dorm   = button.DataContext as BookDorm;

            if (BookDatabase.UpdateDormWhenBook(dorm.EmailOwner, dorm.EmailUser, dorm.IdDorm, state))
            {
                if (BookDatabase.DeleteDormWhenBook(dorm.EmailOwner, dorm.EmailUser, dorm.IdDorm))
                {
                    Helpers.MakeConfirmMessage(Window.GetWindow(this), $"The Dorm has been {msg} to { dorm.EmailUser}", "Notify");
                    int count = DormDatabase.GetCount(dorm.IdDorm) + 1;
                    DormDatabase.UpdateCountDorm(dorm.IdDorm, count);
                    MainControl mainControl = (MainControl)Window.GetWindow(this);
                    mainControl.MainHomeLayout.Children.Clear();
                    mainControl.MainHomeLayout.VerticalAlignment   = VerticalAlignment.Top;
                    mainControl.MainHomeLayout.HorizontalAlignment = HorizontalAlignment.Left;
                    mainControl.MainHomeLayout.Width  = 1150;
                    mainControl.MainHomeLayout.Height = 720;
                    mainControl.MainHomeLayout.Children.Add(new MyDorm(mainControl.user));
                }
                else
                {
                    Helpers.MakeErrorMessage(Window.GetWindow(this), $"Failed {msg} to {dorm.EmailUser}", "Error");
                }
            }
        }
示例#3
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            Button           button = sender as Button;
            Dorm             dorm   = button.DataContext as Dorm;
            MessageBoxResult result = MessageBox.Show("Would you like to delete this dorm?", "Notify", MessageBoxButton.YesNo);

            switch (result)
            {
            case MessageBoxResult.Yes:
                if (DormDatabase.Delete(dorm.Id))
                {
                    BookDatabase.DeleteByIdDorm(dorm.Id);
                    OwnerDormDatabase.DeleteByDormId(dorm.Id);
                    LikeDatabase.DeleteById(dorm.Id);
                    CommentDatabase.DeleteByIdDorm(dorm.Id);
                    MainControl mainControl = (MainControl)Window.GetWindow(this);
                    mainControl.MainHomeLayout.Children.Clear();
                    mainControl.MainHomeLayout.VerticalAlignment   = VerticalAlignment.Top;
                    mainControl.MainHomeLayout.HorizontalAlignment = HorizontalAlignment.Left;
                    mainControl.MainHomeLayout.Width  = 1150;
                    mainControl.MainHomeLayout.Height = 720;
                    mainControl.MainHomeLayout.Children.Add(new MyDorm(mainControl.user));
                }
                break;
            }
        }
示例#4
0
        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            MainControl mainControl = (MainControl)Window.GetWindow(this);

            mainControl.MainHomeLayout.Children.Clear();
            mainControl.MainHomeLayout.VerticalAlignment   = VerticalAlignment.Top;
            mainControl.MainHomeLayout.HorizontalAlignment = HorizontalAlignment.Left;
            mainControl.MainHomeLayout.Width  = 1150;
            mainControl.MainHomeLayout.Height = 690;
            mainControl.MainHomeLayout.Children.Add(new MyDorm(user));
        }
示例#5
0
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            Button      button      = sender as Button;
            Dorm        dorm        = button.DataContext as Dorm;
            MainControl mainControl = (MainControl)Window.GetWindow(this);

            mainControl.MainHomeLayout.Children.Clear();
            mainControl.MainHomeLayout.VerticalAlignment   = VerticalAlignment.Top;
            mainControl.MainHomeLayout.HorizontalAlignment = HorizontalAlignment.Left;
            mainControl.MainHomeLayout.Width  = 1150;
            mainControl.MainHomeLayout.Height = 720;
            mainControl.MainHomeLayout.Children.Add(new PostDorm(mainControl.user, dorm));
        }
        private void listViewDormBook_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            BookDorm    dormB       = listViewDormBook.SelectedItem as BookDorm;
            Dorm        dorm        = DormDatabase.Get(dormB.IdDorm);
            MainControl mainControl = (MainControl)Window.GetWindow(this);

            mainControl.MainHomeLayout.Children.Clear();
            TransitioningContentSlide.OnApplyTemplate();
            mainControl.MainHomeLayout.VerticalAlignment   = VerticalAlignment.Top;
            mainControl.MainHomeLayout.HorizontalAlignment = HorizontalAlignment.Left;
            mainControl.MainHomeLayout.Width  = 1150;
            mainControl.MainHomeLayout.Height = 720;
            mainControl.MainHomeLayout.Children.Add(new ShowDorm(dorm, BookDatabase.GetOwnerByIdDorm(dorm.Id), 2));
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            User user = UserDatabase.CheckAccountAreadyInApp();

            if (user != null)
            {
                MainControl m = new MainControl(user, "");
                m.Show();
                Window.GetWindow(this).Hide();
            }
            else
            {
            }
        }
示例#8
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            User user = new User(tbEmail.Text.Trim(), tbPassword.Password.Trim(), Helpers.ConverCheckedToInt(cbRememberPass));

            if (UserDatabase.CheckAccount(user.Email, user.Password))
            {
                UserDatabase.Update(user, user.Email);
                MainControl m = new MainControl(user, AccessToken);
                Window.GetWindow(this).Hide();
                m.Show();
            }
            else
            {
                Helpers.MakeErrorMessage(Window.GetWindow(this), "Error join app", "Error");
            }
        }
示例#9
0
 private void btnComment_Click(object sender, RoutedEventArgs e)
 {
     if (user.Email.Equals(owner.Email))
     {
         Helpers.MakeErrorMessage(Window.GetWindow(this), "You are owner so can't rating", "Error");
     }
     else
     {
         if (BookDatabase.GetEmailBookDorm(owner.Email, dorm.Id).Equals(user.Email))
         {
             ValueRating = ratingBar.Value;
             Comment     = tbComment.Text.Trim();
             if (ValueRating == 0)
             {
                 Helpers.MakeErrorMessage(Window.GetWindow(this), "You must rating dorm ", "Error");
             }
             else
             {
                 if (CommentDatabase.Insert(owner.Email, dorm.Id, user.Email, Comment, ValueRating))
                 {
                     Helpers.MakeConfirmMessage(Window.GetWindow(this), "Thanks you bro", "Notify");
                     if (CommentDatabase.GetAvgRating(owner.Email, dorm.Id) != -1)
                     {
                         DormDatabase.UpdateRating(dorm.Id, CommentDatabase.GetAvgRating(owner.Email, dorm.Id));
                         dorm.Quality = (dorm.Quality + ValueRating) / DormDatabase.GetCount(dorm.Id);
                         MainControl mainControl = (MainControl)Window.GetWindow(this);
                         mainControl.MainHomeLayout.Children.Clear();
                         mainControl.MainHomeLayout.VerticalAlignment   = VerticalAlignment.Top;
                         mainControl.MainHomeLayout.HorizontalAlignment = HorizontalAlignment.Left;
                         mainControl.MainHomeLayout.Width  = 1150;
                         mainControl.MainHomeLayout.Height = 720;
                         mainControl.MainHomeLayout.Children.Add(new ShowDorm(dorm, user, 1));
                     }
                 }
                 else
                 {
                     Helpers.MakeErrorMessage(Window.GetWindow(this), "You already rating this dorm", "Error");
                 }
             }
         }
         else
         {
             Helpers.MakeErrorMessage(Window.GetWindow(this), "You can't comment because you have never book this dorm", "Error");
         }
     }
 }
示例#10
0
        private void btnCanel_Click(object sender, RoutedEventArgs e)
        {
            Button           button      = sender as Button;
            BookDorm         dormB       = button.DataContext as BookDorm;
            Dorm             dorm        = DormDatabase.Get(dormB.IdDorm);
            MainControl      mainControl = (MainControl)Window.GetWindow(this);
            MessageBoxResult result      = MessageBox.Show("Would you like to cancel booking this dorm?", "Notify", MessageBoxButton.YesNo);

            switch (result)
            {
            case MessageBoxResult.Yes:
                if (BookDatabase.DeleteDormWhenBookUser(mainControl.user.Email, dorm.Id))
                {
                    mainControl.MainHomeLayout.Children.Clear();
                    mainControl.MainHomeLayout.VerticalAlignment   = VerticalAlignment.Top;
                    mainControl.MainHomeLayout.HorizontalAlignment = HorizontalAlignment.Left;
                    mainControl.MainHomeLayout.Width  = 1150;
                    mainControl.MainHomeLayout.Height = 720;
                    mainControl.MainHomeLayout.Children.Add(new MyDorm(mainControl.user));
                }
                break;
            }
        }