public void ChangeShop()
 {
     if (CanChange)
     {
         try
         {
             logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, "Change Shop is clicked.");
             if (Channel.Instance.shopProxy.UpdateShop(CurrentShop))
             {
                 Window.Close();
             }
             else
             {
                 MessageBox.Show("Name is already exists!");
             }
         }
         catch
         {
             logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
         }
     }
     else
     {
         MessageBox.Show("Fields cannot be empty! Please, fill them.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     ContentHandler.Refresh();
 }
        public void AddShop()
        {
            Context context = new Context(NewShop);

            if (!context.ChackValidation())
            {
                return;
            }
            logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, CurrentUser.Name + " has clicked add Shop.");
            try
            {
                if (Channel.Instance.shopProxy.AddShop(NewShop))
                {
                    Window.Close();
                }
                else
                {
                    MessageBox.Show("Shop already exists");
                }
            }
            catch
            {
                logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
                MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ContentHandler.Refresh();
        }
        public void Change()
        {
            Context context = new Context(CurrentUser);

            if (context.ChackValidation())
            {
                try
                {
                    logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, "Change Information is clicked.");
                    if (Channel.Instance.userProxy.Update(CurrentUser))
                    {
                        Window.Close();
                    }
                    else
                    {
                        MessageBox.Show("Falied");
                    }
                }
                catch
                {
                    logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
                    MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Please, fiil all fields!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ContentHandler.Refresh();
        }
Ejemplo n.º 4
0
        public void AddUser()
        {
            Channel.Instance.logProxy.LogMessage(Enums.LOGTYPE.INFO, "Add new user is clicked.");

            //Strategy pattern for validation of user
            Context context = new Context(NewUser);

            if (context.ChackValidation())
            {
                try
                {
                    if (!Admin)
                    {
                        NewUser.Type = TYPE.USER;
                    }
                    else
                    {
                        NewUser.Type = TYPE.ADMIN;
                    }
                    if (Channel.Instance.userProxy.Add(NewUser))
                    {
                        MessageBox.Show("Successfully added user " + NewUser.Name);
                        logHandler.LogManagerLogging(LOGTYPE.INFO, "Successfully added user " + NewUser.Name);
                        Window.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username \"" + NewUser.Username + "\" already exists, try another one..");
                    }
                }
                catch
                {
                    logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
                    MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                MessageBox.Show("Please, fiil all fields!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            ContentHandler.Refresh();
        }
Ejemplo n.º 5
0
        public void ExecuteChangeTelephone(object o = null)
        {
            Context context = new Context(CurrentTelephone);

            if (!context.ChackValidation())
            {
                return;
            }
            if (o == null)
            {
                if (CanChangeTelephone)
                {
                    try
                    {
                        logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, "Change Telephone is clicked.");
                        CommandHandler.Instance.undoCommands[CommandHandler.Instance.undoCommands.Count - 1] = ChangeThisTelephoneCommand;

                        if (!Channel.Instance.telephoneProxy.UpdateTelephone(CurrentTelephone))
                        {
                            if (MessageBox.Show("Telephone is deleted or modified. Do you want to overwrite changes?", "Conflict", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                            {
                                logHandler.LogManagerLogging(Enums.LOGTYPE.WARN, "Telephone is modified.");
                                Channel.Instance.telephoneProxy.UpdateNewTelephone(CurrentTelephone);
                                ((ShopTelephone)CommandHandler.Instance.undoObjects[CommandHandler.Instance.undoObjects.Count - 1]).LastModified = Channel.Instance.telephoneProxy.GetTelephone(CurrentTelephone.Name).LastModified;
                            }
                        }
                        else
                        {
                            ((ShopTelephone)CommandHandler.Instance.undoObjects[CommandHandler.Instance.undoObjects.Count - 1]).LastModified = Channel.Instance.telephoneProxy.GetTelephone(CurrentTelephone.Name).LastModified;
                        }
                        Window.Close();
                    }
                    catch
                    {
                        logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
                        MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Fields can not be empty of negative! Please, fill the content.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else
            {
                CurrentTelephone = (ShopTelephone)o;
                CommandHandler.Instance.redoObjects[CommandHandler.Instance.redoObjects.Count - 1] = Channel.Instance.telephoneProxy.GetTelephone(((ShopTelephone)o).Name);
                try
                {
                    logHandler.LogManagerLogging(Enums.LOGTYPE.INFO, "Change Telephone is clicked.");

                    if (!Channel.Instance.telephoneProxy.UpdateTelephone(CurrentTelephone))
                    {
                        if (MessageBox.Show("Telephone is deleted or modified. Do you want to overwrite changes?", "Conflict", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                        {
                            logHandler.LogManagerLogging(Enums.LOGTYPE.WARN, "Telephone is modified.");
                            Channel.Instance.telephoneProxy.UpdateNewTelephone(CurrentTelephone);
                        }
                    }
                    ((ShopTelephone)CommandHandler.Instance.redoObjects[CommandHandler.Instance.redoObjects.Count - 1]).LastModified = Channel.Instance.telephoneProxy.GetTelephone(CurrentTelephone.Name).LastModified;
                    Window.Close();
                }
                catch
                {
                    logHandler.LogManagerLogging(Enums.LOGTYPE.FATAL, "Connection failed");
                    MessageBox.Show("Connection failed", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            ContentHandler.Refresh();
        }