Exemple #1
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");
                }
            }
        }
Exemple #2
0
        private void initBookDorm()
        {
            try
            {
                BookDorm bookDorm = new BookDorm();
                bookDorm.EmailOwner = owner.Email;
                bookDorm.EmailUser  = user.Email;
                bookDorm.IdDorm     = dorm.Id;
                bookDorm.StateDorm  = 1;

                bookDorm = BookDatabase.GetItem(bookDorm);
                if (bookDorm.StateDorm == 0)
                {
                    spinnerBook.Visibility = Visibility.Collapsed;
                    btnBooked.Background   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2DCA73"));
                    btnBooked.IsEnabled    = true;
                }
                else if (bookDorm.StateDorm == 1)
                {
                    spinnerBook.Visibility = Visibility.Visible;
                    btnBooked.Background   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#A2D8E9"));
                    btnBooked.IsEnabled    = true;
                }
                else
                {
                    spinnerBook.Visibility = Visibility.Collapsed;
                    btnBooked.Background   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F0F0F0"));
                    btnBooked.IsCancel     = true;
                }
                lbStateBook.Content = Helpers.ConvertStateToText(bookDorm.StateDorm);
            }
            finally
            {
            }
        }
Exemple #3
0
 private void btnBooked_Click(object sender, RoutedEventArgs e)
 {
     if (user.Email.Equals(owner.Email))
     {
         Helpers.MakeErrorMessage(Window.GetWindow(this), "You are owner so can't book dorm", "Error");
     }
     else if (!BookDatabase.GetEmailBookDorm(owner.Email, dorm.Id).Equals("No"))
     {
         if (BookDatabase.GetEmailBookDorm(owner.Email, dorm.Id).Equals(user.Email))
         {
             Helpers.MakeConfirmMessage(Window.GetWindow(this), "Dorm was booked by you", "Notify");
         }
         else
         {
             Helpers.MakeErrorMessage(Window.GetWindow(this), "Dorm was booked by " + BookDatabase.GetEmailBookDorm(owner.Email, dorm.Id), "Error");
         }
     }
     else
     {
         BookDorm bookDorm = new BookDorm();
         bookDorm.EmailOwner = owner.Email;
         bookDorm.EmailUser  = user.Email;
         bookDorm.IdDorm     = dorm.Id;
         bookDorm.StateDorm  = 1;
         if (BookDatabase.Insert(bookDorm))
         {
             spinnerBook.Visibility = Visibility.Visible;
             btnBooked.Background   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#A2D8E9"));
             lbStateBook.Content    = "Booking...";
         }
         else
         {
             bookDorm = BookDatabase.GetItem(bookDorm);
             if (bookDorm.StateDorm == 0)
             {
                 spinnerBook.Visibility = Visibility.Visible;
                 btnBooked.IsEnabled    = true;
                 btnBooked.Background   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#A2D8E9"));
                 bookDorm.StateDorm     = 1;
                 BookDatabase.Update(bookDorm);
             }
             else if (bookDorm.StateDorm == 1)
             {
                 spinnerBook.Visibility = Visibility.Collapsed;
                 btnBooked.IsEnabled    = true;
                 btnBooked.Background   = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#2DCA73"));
                 bookDorm.StateDorm     = 0;
                 BookDatabase.Update(bookDorm);
             }
             lbStateBook.Content = Helpers.ConvertStateToText(bookDorm.StateDorm);
         }
     }
 }
        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 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;
            }
        }