Exemple #1
0
        /// <summary>
        /// The method that modifies a customer based on the input fields.
        /// </summary>
        /// <param name="window">The window to close if successful.</param>
        private void AcceptMethod(IClosable window)
        {
            if (IsValidData())
            {
                try
                {
                    selectedCustomer.Name    = enteredName;
                    selectedCustomer.Address = enteredAddress;
                    selectedCustomer.City    = enteredCity;
                    selectedCustomer.State   = SelectedState.StateCode;
                    selectedCustomer.ZipCode = enteredZipCode;

                    MMABooksEntity.dbcontext.SaveChanges();
                    Messenger.Default.Send(new NotificationMessage("Reload"));

                    if (window != null)
                    {
                        window.Close();
                    }
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    ex.Entries.Single().Reload();

                    if (MMABooksEntity.dbcontext.Entry(selectedCustomer).State == System.Data.EntityState.Detached)
                    {
                        MessageBox.Show("Another user has deleted that customer.", "Concurrency Error");
                        window.Close();
                    }
                    else
                    {
                        MessageBox.Show("Another user has updated that customer.", "Concurrency Error");
                        selectedCustomer = (from customer in MMABooksEntity.dbcontext.Customers
                                            where customer.CustomerID == selectedCustomer.CustomerID
                                            select customer).Single();
                        EnteredName    = selectedCustomer.Name;
                        EnteredAddress = selectedCustomer.Address;
                        EnteredCity    = selectedCustomer.City;
                        EnteredZipCode = selectedCustomer.ZipCode;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
            else
            {
                MessageBox.Show("Invalid data.", "Error");
            }
        }
 public void UpdateMethod(IClosable window)
 {
     try
     {
         if (window != null)
         {
             var updatedMember = new MessageMember(enteredFName, enteredLName, enteredEmail, "Update")
             {
                 FirstName = enteredFName,
                 LastName  = enteredLName,
                 Email     = enteredEmail
             };
             Messenger.Default.Send(updatedMember);
             window.Close();
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Fields must be under 25 characters.", "Entry Error");
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Fields cannot be empty.", "Entry Error");
     }
     catch (FormatException)
     {
         MessageBox.Show("Must be a valid e-mail address.", "Entry Error");
     }
 }
Exemple #3
0
        private void Enter(IClosable win)
        {
            if (IsCheckedRegistration)
            {
                if (FirstRegistrationPassword != SecondRegistrationPassword)
                {
                    MessageBox.Show("Hesla sa musia zhodovať");
                }
                MessageBox.Show("Registracia bola úspešná");
            }

            if (IsCheckedLogin)
            {
                MessageBox.Show("Prihlasenie boo úspešné");
                ChatSerivce.Nick = LoginNick;
                MainWindow mainWin = new MainWindow();
                mainWin.Show();


                if (win != null)
                {
                    win.Close();
                }
            }
        }
        /// <summary>
        /// Method that contains code to open Maintenance window
        /// and close Add window.
        /// </summary>

        private void BackToMaintenance(IClosable window)
        {
            var mainWindow = new MembershipMaintenance();

            mainWindow.Show();
            window.Close();
        }
 private void CancelExecute(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
 private void CloseWindow(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
Exemple #7
0
 /// <summary>
 /// Sends a valid member to the Main VM to replace at the selected index with, then closes the change window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void UpdateMethod(IClosable window)
 {
     try
     {
         if (window != null)
         {
             // sends "Update" message to MainViewModel.ReceiveMember(MessageMember m)
             var changeViewModelMessage = new MessageMember(EnteredFName, EnteredLName, EnteredEmail, "Update");
             Messenger.Default.Send(changeViewModelMessage);
             window.Close();
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Fields must be under 25 characters.", "Entry Error");
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Fields cannot be empty.", "Entry Error");
     }
     catch (FormatException)
     {
         MessageBox.Show("Must be a valid e-mail address.", "Entry Error");
     }
 }
 private void CloseAddDialog(IClosable obj)
 {
     if (obj != null)
     {
         obj.Close();
     }
 }
        public override async void AddEntity(IClosable window)
        {
            try
            {
                base.IsLoading = true;
                AddEntityCommand.RaiseCanExecuteChanged();
                _mapper.Map(EntityViewModel, _questionnaire);
                await _client.GetSyncTable <Questionnaire>().InsertAsync(_questionnaire);

                await _client.SyncAsync();

                foreach (var questionViewModel in EntityViewModel.QuestionViewModels)
                {
                    await questionViewModel.Save();
                }

                _list.AddEntity(_questionnaire);
                window?.Close();
                await _client.SyncAsync();
            }
            finally
            {
                base.IsLoading = false;
            }
        }
Exemple #10
0
 public void CancelAction(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="window"></param>
 public void ExitAction(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
        private void SaveExecute(IClosable window)
        {
            var leaveToAdd = new LeaveToAdd
            {
                UserId      = (int)SelectedUserId,
                LeaveTypeId = (int)SelectedLeaveTypeId,
                StartDate   = (DateTime)StartDate,
                EndDate     = (DateTime)EndDate,
                Comment     = Comment
            };

            try
            {
                _leaveService.AddLeave(leaveToAdd);

                Messenger.Default.Send <LeaveToAdd>(leaveToAdd);



                if (window != null)
                {
                    window.Close();
                }
            }
            catch (LeaveException exc)
            {
                CustomMessageBox.CustomMessageBox.Show(exc.Message, "Błąd");
            }
        }
Exemple #13
0
        /// <summary>
        /// The method that adds a new customer based on the input fields to the database.
        /// </summary>
        /// <param name="window">The window to close if successful.</param>
        private void AcceptMethod(IClosable window)
        {
            if (IsValidData())
            {
                try
                {
                    Customer adding = new Customer();
                    adding.Name    = enteredName;
                    adding.Address = enteredAddress;
                    adding.City    = enteredCity;
                    adding.State   = SelectedState.StateCode;
                    adding.ZipCode = enteredZipCode;

                    MMABooksEntity.dbcontext.Customers.Add(adding);
                    MMABooksEntity.dbcontext.SaveChanges();

                    if (window != null)
                    {
                        window.Close();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString());
                }
            }
            else
            {
                MessageBox.Show("Invalid data.", "Error");
            }
        }
Exemple #14
0
 /// <summary>
 /// The method that closes the add window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 private void CancelMethod(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
Exemple #15
0
        /// <summary>
        /// Modify the selected category in a window
        /// </summary>
        /// <param name="window">The window where the modification take place</param>
        public void Modify(IClosable window)
        {
            // check if the categoryname was modified
            if (SelectedCategory.IsNameModified())
            {
                // make sure there is no category with the same name already in database
                if (CategoryExists(SelectedCategory.Category.CategoryName))
                {
                    windowService.UserMessage("Létezik már ilyen névvel kategória, kérem adjon meg másik nevet!");
                    return;
                }
            }

            // try to modify, if any changes was made
            if (SelectedCategory.IsModified())
            {
                if (Modify())
                {
                    windowService.UserMessage("A kategória sikeresen módosításra került!");
                    IsModified = true;
                }
                else
                {
                    windowService.UserMessage("A kategóriát nem sikerül módosítani!");
                }
            }
            else
            {
                windowService.UserMessage("Nem történt módosítás.");
            }

            // close the window anyway
            window.Close();
        }
Exemple #16
0
        private async void Login(IClosable window)
        {
            IsLoading = true;
            try
            {
                await _msClient.LoginAsync(Username, Password);

                var newWindow = new MainWindow();
                newWindow.Show();
                window?.Close();
            }
            catch (MobileServiceInvalidOperationException e)
            {
                Debug.Write(e);
                MessageBox.Show(e.Response.ReasonPhrase.Equals("Unauthorized")
                    ? "Het gebruikersnaam of wachtwoord is fout, probeer het opnieuw."
                    : "Er is iets fout gegaan bij het inloggen, probeer het opnieuw.");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message.Equals("Er is een fout opgetreden bij het verzenden van het aanvraag.")
                    ? e.InnerException.Message
                    : "Er is iets fout gegaan bij het inloggen, probeer het opnieuw.");
            }

            IsLoading = false;
        }
Exemple #17
0
 /// <summary>
 /// Sends a valid member to the Main VM to add to the list, then closes the window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void SaveMethod(IClosable window)
 {
     try
     {
         if (window != null)
         {
             // (Missing) -> Send a valid member
             Messenger.Default.Send(new MessageMember(EnteredFName, EnteredLName, EnteredEmail, "Add"));
             ResetInputFields();
             window.Close();
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Fields must be under 25 characters.", "Entry Error");
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Fields cannot be empty.", "Entry Error");
     }
     catch (FormatException)
     {
         MessageBox.Show("Must be a valid e-mail address.", "Entry Error");
     }
 }
        private void SaveExecute(IClosable window)
        {
            var userToAdd = new UserToAdd
            {
                Login                = this.Login,
                FirstName            = this.FirstName,
                LastName             = this.LastName,
                Password             = this.Password,
                PasswordConfirmation = this.PasswordConfirmation,
                RoleId               = (int)this.SelectedRoleId
            };

            try
            {
                _userService.AddUser(userToAdd);

                Messenger.Default.Send <UserToAdd>(userToAdd);

                if (window != null)
                {
                    window.Close();
                }
            }
            catch (UserException exc)
            {
                CustomMessageBox.CustomMessageBox.Show(exc.Message, "Błąd");
            }
        }
 /// <summary>
 /// Closes the application.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void ExitMethod(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
 }
        public void AcceptMethod(IClosable window)
        {
            if (Name != null && City != null && Address != null && SelectedState != null && Zipcode != null)
            {
                try
                {
                    var state = (from cust in MMABooksClass.context.Customers
                                 where cust.State1.StateName == SelectedState.StateName
                                 select cust.State).FirstOrDefault();

                    Customer customer = new Customer();
                    customer.Name    = Name;
                    customer.Address = Address;
                    customer.City    = City;
                    customer.State   = state;
                    customer.ZipCode = Zipcode;

                    MMABooksClass.context.Customers.Add(customer);
                    MMABooksClass.context.SaveChanges();
                    MessageBox.Show(customer.CustomerID.ToString(), "Customer Added ID");
                    Messenger.Default.Send(new MessageMember(customer, "Add"));

                    Name          = "";
                    Address       = "";
                    City          = "";
                    SelectedState = null;
                    Zipcode       = "";

                    if (window != null)
                    {
                        window.Close();
                    }
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    ex.Entries.Single().Reload();
                    if (MMABooksClass.context.Entry(selectedstate).State == EntityState.Detached)
                    {
                        MessageBox.Show("Another user has deleted " + "that customer.", "Concurrency Error");
                    }
                    else
                    {
                        MessageBox.Show("Another user has updated " + "that customer.", "Concurrency Error");
                    }
                }
                catch (NullReferenceException)
                {
                    MessageBox.Show("Null reference", "Error");
                }
                catch (Exception)
                {
                    MessageBox.Show("Error", "Error");
                }
            }
            else
            {
                MessageBox.Show("ERROR: NULL DATA");
            }
        }
Exemple #21
0
 /// <summary>
 /// Sends out a message to initiate closing the change window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void DeleteMethod(IClosable window)
 {
     if (window != null)
     {
         Messenger.Default.Send(new NotificationMessage("Delete"));
         window.Close();
     }
 }
 private void CloseDialog(object parameter)
 {
     if (parameter != null)
     {
         IClosable window = parameter as IClosable;
         window.Close();
     }
 }
Exemple #23
0
 public void CancelMethod(IClosable window)
 {
     if (window != null)
     {
         window.Close();
     }
     ResetProperties();
 }
Exemple #24
0
 private void ShowLoginView(IClosable window)
 {
     if (window != null)
     {
         ShowLoginWindow();
         window.Close();
     }
 }
Exemple #25
0
 private void ShowRegisterView(IClosable window)
 {
     if (window != null)
     {
         ShowRegisterWindow();
         window.Close();
     }
 }
Exemple #26
0
 private void Logout(IClosable window)
 {
     if (window != null)
     {
         Authenticator.LogOut();
         window.Close();
     }
 }
Exemple #27
0
 /// <summary>
 /// Closes the window.
 /// </summary>
 /// <param name="window">The window to close.</param>
 public void CancelMethod(IClosable window)
 {
     if (window != null)
     {
         ResetInputFields();
         window.Close();
     }
 }
Exemple #28
0
 private void ExitWindow(IClosable window)
 {
     if (window != null)
     {
         window.Close();
         ResetFields();
     }
 }
Exemple #29
0
 private void Cancel(IClosable window)
 {
     if (window != null)
     {
         ShowProfileWindow(Authenticator.CurrentUser.PharmacyID);
         window.Close();
     }
 }
Exemple #30
0
 private void Save(IClosable window)
 {
     if (window != null)
     {
         window.DialogResult = true;
         window.Close();
     }
 }