private void Register_Click(object sender, RoutedEventArgs e)
 {
     //TODO:fix it
     if (Pass.Password == ConfPass.Password)
     {
         if (FR.FR_Imp.GetFR().CheckIfGuestExists(User.Text) ||
             FR.FR_Imp.GetFR().CheckIfHostExists(User.Text))
         {
             MessageBox.Show("There is already an account by that name!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         if (User.Text.ToLower() == "admin")
         {
             MessageBox.Show("Invalid username!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         int key = Configuration.GuestKey;
         FR_Imp.GetFR().WriteGuestToFile(User.Text, Pass.Password, key);
         MessageBox.Show("You have been registered!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information);
         this.Hide();
         var createWin = new GuestMenu(User.Text, key);
         createWin.Closed += (s, args) => Close();
         createWin.Show();
         return;
     }
     //TODO: לעשות שאי שיוון בי הטקסטבוקסים יותרע בתווית
     MessageBox.Show("Password and confirmation must match!", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
 }
        private void LoadGuestRequests()
        {
            GuestRequestStack.Children.Clear();
            GuestRequestStack.Children.Add(Resources["GuestTitlesBar"] as Grid);

            List <BE.GuestRequest> list = new List <BE.GuestRequest>();

            try
            {
                var li = from i in CreateAccount.myBL.getHostingUnitByHost()
                         where i.Key.HostKey == FR_Imp.GetFR().GetHostKey(LoginPage.UserName)
                         select new { Hostingunits = i };
                foreach (var i in li)
                {
                    foreach (var stuff in i.Hostingunits)
                    {
                        list.AddRange(CreateAccount.myBL.GetMatchingGuestRequests(stuff));
                    }
                }

                var toRemDup = from j in list
                               select j;
                list = toRemDup.Distinct(new BE.GuestRequestComparer()).ToList();


                try
                {
                    var order = from i in CreateAccount.myBL.GetAllOrders()
                                select i;
                    foreach (var i in order)
                    {
                        list.RemoveAll(s => s.GuestRequestKey == i.GuestRequestKey);
                    }
                }
                catch (Exceptions.NoItemsException)
                {
                }

                foreach (var i in list)
                {
                    GuestRequestStack.Children.Add(new HostsGuestRequestUC(this, i, host));
                }
            }
            catch (Exceptions.NoItemsException)
            {
            }
        }
        private void Refresh()
        {
            HostingUnitStack.Children.Clear();
            HostingUnitStack.Children.Add(Resources["TitlesBar"] as Grid);
            try
            {
                var li = from i in CreateAccount.myBL.getHostingUnitByHost()
                         where i.Key.HostKey == FR_Imp.GetFR().GetHostKey(LoginPage.UserName)
                         select new { Hostingunits = i };

                foreach (var i in li)
                {
                    foreach (var item in i.Hostingunits)
                    {
                        HostingUnitStack.Children.Add(new HostingUnitUC(this, item));
                    }
                }
            }
            catch (Exceptions.NoItemsException)
            {
                return;
            }
        }
        private void LoadOrders()
        {
            OrderStack.Children.Clear();
            OrderStack.Children.Add(Resources["OrderTitlesBar"] as Grid);

            List <BE.Order> list = new List <BE.Order>();

            try
            {
                var imp = from i in CreateAccount.myBL.getHostingUnitByHost()
                          where i.Key.HostKey == FR_Imp.GetFR().GetHostKey(LoginPage.UserName)
                          select i;
                IEnumerable <BE.Order> ppp = new List <BE.Order>();

                foreach (var i in imp)
                {
                    foreach (var li in i)
                    {
                        ppp = from j in CreateAccount.myBL.GetAllOrders()
                              where li.HostingUnitKey == j.HostingUnitKey
                              select j;
                    }
                }


                list = ppp.Distinct(new BE.OrderComparer()).ToList();

                foreach (var i in list)
                {
                    OrderStack.Children.Add(new HostOrderUC(i));
                }
            }
            catch (Exceptions.NoItemsException)
            {
            }
        }
Example #5
0
 private void MenuItem_Click(object sender, RoutedEventArgs e)
 {
     FR_Imp.GetFR().RemoveGuestFromFile(Name.Content as string);
 }
Example #6
0
 public AdminGuestUC(string username)
 {
     InitializeComponent();
     Key.Content  = FR_Imp.GetFR().GetGuestKey(username);
     Name.Content = username;
 }