private void button_New_Click(object sender, RoutedEventArgs e)
        {
            User_CreateUpdate userCreate = new User_CreateUpdate("Create");

            userCreate.whereFrom = "User Management";
            userCreate.Show();
            this.Hide();
        }
        void mouseLeftButtonUp_Users(object sender, MouseEventArgs e)
        {
            string todo       = (sender as Label).Content.ToString();
            string chosenUser = (((sender as Label).Parent as StackPanel).Children[0] as Label).Content.ToString();

            if (todo == "Change Password")
            {
                User_CreateUpdate userCreate = new User_CreateUpdate("Change Password", chosenUser);
                userCreate.whereFrom = "User Management";
                userCreate.Show();
                this.Hide();
            }
            else if (todo == "Edit")
            {
                User_CreateUpdate userCreate = new User_CreateUpdate("Update", chosenUser);
                userCreate.whereFrom = "User Management";
                userCreate.Show();
                this.Hide();
            }
            else//delete
            {
                bool deletedOrNot = false;
                if (!string.IsNullOrEmpty(GlobalVariables.connectionString))
                {
                    deletedOrNot = bSQL.Delete_User(chosenUser);
                    if (deletedOrNot)
                    {
                        MessageBox.Show("Successfully deleted the user!");
                        LoadWindow();
                    }
                    else
                    {
                        MessageBox.Show("Failed to deleted the user");
                    }
                }
                else
                {
                    deletedOrNot = xmlClass.deleteUserFromXML(chosenUser);
                    if (deletedOrNot)
                    {
                        MessageBox.Show("Successfully deleted the user");
                        LoadWindow();
                    }
                    else
                    {
                        MessageBox.Show("Failed to deleted the user");
                    }
                }
            }
        }
Пример #3
0
 private void label_Generic_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if ((sender as Label).Content.ToString() == "Register a User")//register user
     {
         User_CreateUpdate userCreate = new User_CreateUpdate("Create");
         userCreate.whereFrom = "Login";
         userCreate.Show();
         this.Hide();
     }
     else//forgot password
     {
         User_CreateUpdate userCreate = new User_CreateUpdate("Change Password");
         userCreate.whereFrom = "Login";
         userCreate.Show();
         this.Hide();
     }
 }
Пример #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                xmlClass.PopulateAppSettings();
            }
            catch (Exception ex)
            {
                //pass
            }

            if (string.IsNullOrEmpty(GlobalVariables.connectionString))
            {
                GlobalVariables.connectionString = "";
            }
            xmlClass.CreateAppSettingsXML(GlobalVariables.chosenTheme, GlobalVariables.calendarStartSunday, GlobalVariables.connectionString, GlobalVariables.ranSetup);


            if (GlobalVariables.ranSetup == false)
            {
                this.Hide();
                SetupWindow sw = new SetupWindow();
                sw.ShowDialog();
                this.Show();
            }

            MainGrid.Background             = gvars.ThemeColors[GlobalVariables.chosenTheme][0] as Brush;
            label_username.Foreground       = gvars.ThemeColors[GlobalVariables.chosenTheme][8] as Brush;
            label_password.Foreground       = gvars.ThemeColors[GlobalVariables.chosenTheme][8] as Brush;
            GridLogin.Background            = gvars.ThemeColors[GlobalVariables.chosenTheme][11] as Brush;
            expander_MoreLess.Background    = gvars.ThemeColors[GlobalVariables.chosenTheme][11] as Brush;
            expander_MoreLess.Foreground    = gvars.ThemeColors[GlobalVariables.chosenTheme][8] as Brush;
            label_Register.Foreground       = gvars.ThemeColors[GlobalVariables.chosenTheme][12] as Brush;
            label_ForgotPassword.Foreground = gvars.ThemeColors[GlobalVariables.chosenTheme][12] as Brush;

            if (!string.IsNullOrEmpty(GlobalVariables.connectionString))//Connects to SQL DB
            {
            }
            else//XML Local Files
            {
                bool?toCreateUser = xmlClass.createUsersXML(new List <B_Users>()
                {
                });

                if (toCreateUser == null)
                {
                    label_ForgotPassword.IsEnabled = false;
                    MessageBoxResult chosen = System.Windows.MessageBox.Show("There are no users set up in the system. Do you want to create a user?", "No users in the system", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
                    if (chosen == MessageBoxResult.Yes)
                    {
                        User_CreateUpdate createUser = new User_CreateUpdate("Create");
                        createUser.Show();
                        this.Hide();
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    label_ForgotPassword.IsEnabled = true;
                }
            }
        }