Esempio n. 1
0
 /// <summary>
 /// Callback for when the DBA panel is made visible after clicking the "DBA" menu button. This method repopulates the DBA List
 /// and adds the data to the DBA listbox. The listbox contains all of the DBAs in the system, except for the DBA user. This is done
 /// to prevent the case where a DBA can delete from themselves from the system (and potentially have 0 DBAs for the system)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void panel_dba_VisibleChanged(object sender, EventArgs e)
 {
     dbas = Dba.Generate();
     for (int i = 0; i < dbas.Count; i++)
     {
         if (dbas.ElementAt(i).username.Equals(dba.username))
         {
             dbas.RemoveAt(i);
             break;
         }
     }
     listBox_dba.DataSource    = dbas;
     listBox_dba.DisplayMember = "fullName";
 }
Esempio n. 2
0
        /// <summary>
        /// Callback that occurs when a new item is selected in the DBA Listbox. Upon change, it populates the data fields
        /// with the respective DBA's information.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listBox_dba_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBox_dba.SelectedIndex > -1)
            {
                Dba d = dbas.ElementAt(listBox_dba.SelectedIndex);

                textBox_dba_fName.Text       = d.fName;
                textBox_dba_lName.Text       = d.lName;
                textBox_dba_username.Text    = d.username;
                textBox_dba_password.Text    = d.password;
                button_dba_delete.Enabled    = true;
                textBox_dba_username.Enabled = false;
                button_dba_save.Text         = "Save";
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Callback for when the "Reset" button is clicked in the DBA panel. This method reverts the information in the data fields to their original state.
 /// The original state varies based off of whether the user has anything currently selected. If they do, it repopulates the fields with that DBA's
 /// original information. If they do not, it empties all of the fields.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button_dba_reset_Click(object sender, EventArgs e)
 {
     if (listBox_dba.SelectedIndex < 0)
     {
         textBox_dba_fName.Text    = "";
         textBox_dba_lName.Text    = "";
         textBox_dba_username.Text = "";
         textBox_dba_password.Text = "";
     }
     else
     {
         Dba d = dbas.ElementAt(listBox_dba.SelectedIndex);
         textBox_dba_fName.Text    = d.fName;
         textBox_dba_lName.Text    = d.lName;
         textBox_dba_password.Text = d.password;
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Callback for when the "Delete" button is clicked in the DBA panel. This method is used to trigger the deletion of the DBA in the system.
        /// If no item is selected, nothing happens. An error message displays if the operation was uncessful.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_dba_delete_Click(object sender, EventArgs e)
        {
            if (listBox_dba.SelectedIndex > -1)
            {
                dbas.ElementAt(listBox_dba.SelectedIndex).Delete();

                listBox_dba.SelectedIndex = -1;
                dbas = Dba.Generate();
                for (int i = 0; i < dbas.Count; i++)
                {
                    if (dbas.ElementAt(i).username.Equals(dba.username))
                    {
                        dbas.RemoveAt(i);
                        break;
                    }
                }
                listBox_dba.DataSource    = dbas;
                listBox_dba.DisplayMember = "fullName";
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Callback for when the "Save" or "Add" button is clicked in the DBA panel. The button has the text "Save" when updating an already existing DBA
        /// and the text "Add" when creating a new DBA to the system. This is determined by checking to see if an element is selected before proceding with
        /// the operation. If any of the fields are left empty an error message is displayed for the user. The password must also meet the specified requirements.
        /// If the operation was uncessful, another error message is displayed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_dba_save_Click(object sender, EventArgs e)
        {
            if (textBox_dba_fName.Text.Equals("") || textBox_dba_lName.Text.Equals("") || textBox_dba_username.Text.Equals("") || textBox_dba_password.Text.Equals(""))
            {
                MessageBox.Show("Please fill in all fields.");
            }
            else
            {
                if (!PasswordMeetsRequirements(textBox_dba_password.Text))
                {
                    MessageBox.Show("Entered passwords do not meet minimum requirements\n1 upper case letter, 1 lower case letter, 1 digit, and legth of at least 8.");
                }
                else
                {
                    if (listBox_dba.SelectedIndex < 0)
                    {
                        Dba d = new Dba(textBox_dba_username.Text, textBox_dba_password.Text, textBox_dba_fName.Text, textBox_dba_lName.Text);

                        if (!d.Add())
                        {
                            MessageBox.Show("Database administrator could not be added.");
                        }
                        else
                        {
                            dbas = Dba.Generate();
                            for (int i = 0; i < dbas.Count; i++)
                            {
                                if (dbas.ElementAt(i).username.Equals(dba.username))
                                {
                                    dbas.RemoveAt(i);
                                    break;
                                }
                            }
                            listBox_dba.DataSource    = dbas;
                            listBox_dba.DisplayMember = "fullName";
                        }
                    }
                    else
                    {
                        Dba d = dbas.ElementAt(listBox_dba.SelectedIndex);

                        if (!d.Update(textBox_dba_password.Text, textBox_dba_fName.Text, textBox_dba_lName.Text))
                        {
                            MessageBox.Show("Database administrator could not be updated.");
                        }
                        else
                        {
                            dbas = Dba.Generate();
                            for (int i = 0; i < dbas.Count; i++)
                            {
                                if (dbas.ElementAt(i).username.Equals(dba.username))
                                {
                                    dbas.RemoveAt(i);
                                    break;
                                }
                            }
                            listBox_dba.DataSource    = dbas;
                            listBox_dba.DisplayMember = "fullName";
                        }
                    }
                }
            }
        }