Ejemplo n.º 1
0
        //when the checkbox is checked it will change the ID box to reflect if the user is looking for outliers or not
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            FindOutliers();

            if (checkBox1.Checked)
            {
                showOutliers();
            }
            else
            {
                showID();
            }
            showForeNames();
            showSurNames();
            showEmail();
            showJobSection();
            showJobs();
            showWUForeNames();
            showWUSurNames();
            showJobBenefits();
            showEmployeeBenefits();
            if (EmpBeneBox.Items.Count == 0)
            {
                EmpBeneDescBox.Clear();
            }
            if (JobBeneBox.Items.Count == 0)
            {
                JobBeneDescBox.Clear();
            }
        }
Ejemplo n.º 2
0
        //Adds the highlighted benefit to the chosen employee's benefits when the button is clicked
        private void AddBenefitBtn_Click(object sender, EventArgs e)
        {
            if (IDBox.Items.Count > 0)
            {
                if (JobBeneBox.Items.Count > 0)
                {
                    String query = "Insert into [Employee Benefits] Values (@EmployeeID, @EntitlementID)";

                    using (connection = new SqlConnection(connectionString))
                        using (SqlCommand command = new SqlCommand(query, connection))
                            using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                            {
                                connection.Open();
                                command.Parameters.AddWithValue("@EmployeeID", IDBox.Text);
                                command.Parameters.AddWithValue("@EntitlementID", JobBeneBox.Text);
                                try
                                {
                                    command.ExecuteNonQuery();
                                }
                                catch (System.Data.SqlClient.SqlException ex)
                                {
                                    MessageBox.Show("This Employee already has this entitlement and it cannot be entered in again. Please select a different entitlement. ");
                                }
                            }
                    FindOutliers();
                    if (checkBox1.Checked)
                    {
                        string X = IDBox.Text;
                        showOutliers();
                        IDBox.Text = X;
                    }
                    showForeNames();
                    showSurNames();
                    showEmail();
                    showJobSection();
                    showJobs();
                    showWUForeNames();
                    showWUSurNames();
                    showJobBenefits();
                    showEmployeeBenefits();
                    if (EmpBeneBox.Items.Count == 0)
                    {
                        EmpBeneDescBox.Clear();
                    }
                    if (JobBeneBox.Items.Count == 0)
                    {
                        JobBeneDescBox.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("There are no Benefits to add");
                }
            }
            else
            {
                MessageBox.Show("There are no employees");
            }
        }
Ejemplo n.º 3
0
        //Removes the highlighted benefit from the chosen employee's benefits when the button is pressed
        private void RemoveBtn_Click(object sender, EventArgs e)
        {
            if (IDBox.Items.Count > 0)
            {
                if (EmpBeneBox.Items.Count > 0)
                {
                    String query = "Delete from [Employee Benefits] where EmployeeID = @EmployeeID and EntitlementID = @EntitlementID";

                    using (connection = new SqlConnection(connectionString))
                        using (SqlCommand command = new SqlCommand(query, connection))
                            using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                            {
                                connection.Open();
                                command.Parameters.AddWithValue("@EmployeeID", IDBox.Text);
                                command.Parameters.AddWithValue("@EntitlementID", EmpBeneBox.Text);
                                try
                                {
                                    command.ExecuteNonQuery();
                                }
                                catch
                                {
                                }
                            }

                    FindOutliers();
                    if (checkBox1.Checked)
                    {
                        string X = IDBox.Text;
                        showOutliers();
                        IDBox.Text = X;
                    }
                    showForeNames();
                    showSurNames();
                    showEmail();
                    showJobSection();
                    showJobs();
                    showWUForeNames();
                    showWUSurNames();
                    showJobBenefits();
                    showEmployeeBenefits();
                    if (EmpBeneBox.Items.Count == 0)
                    {
                        EmpBeneDescBox.Clear();
                    }
                    if (JobBeneBox.Items.Count == 0)
                    {
                        JobBeneDescBox.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("There are no benefits to remove");
                }
            }
            else
            {
                MessageBox.Show("There are no Employees");
            }
        }
Ejemplo n.º 4
0
        //Changes the current job of the chosen employee to the chosenjob in the dropdown box
        private void JobUpdateBtn_Click(object sender, EventArgs e)
        {
            if (IDBox.Items.Count > 0)
            {
                if (ChngJobBox.Items.Count > 0)
                {
                    connection = new SqlConnection(connectionString);
                    String query = "Update [Employee] set JobID = (Select JobID from Jobs where [Job Name] = @JobName) where EmployeeID = @EmployeeID";
                    using (connection = new SqlConnection(connectionString))
                        using (SqlCommand command = new SqlCommand(query, connection))
                        {
                            connection.Open();
                            command.Parameters.AddWithValue("@JobName", ChngJobBox.Text);
                            command.Parameters.AddWithValue("@EmployeeID", IDBox.Text);

                            command.ExecuteScalar();
                        }
                    FindOutliers();
                    if (checkBox1.Checked)
                    {
                        string X = IDBox.Text;
                        showOutliers();
                        IDBox.Text = X;
                    }
                    showForeNames();
                    showSurNames();
                    showEmail();
                    showJobSection();
                    showJobs();
                    showWUForeNames();
                    showWUSurNames();
                    showJobBenefits();
                    showEmployeeBenefits();
                    if (EmpBeneBox.Items.Count == 0)
                    {
                        EmpBeneDescBox.Clear();
                    }
                    if (JobBeneBox.Items.Count == 0)
                    {
                        JobBeneDescBox.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("There are no Jobs to change into");
                }
            }
            else
            {
                MessageBox.Show("There are no employees");
            }
        }
Ejemplo n.º 5
0
        //shows the description of the job benefit in the listbox
        private void showJobBenefitDescription()
        {
            JobBeneDescBox.Clear();
            String query = "select [Description] from [Entitlements] where EntitlementID = @EntitlementID";

            using (connection = new SqlConnection(connectionString))
                using (SqlCommand command = new SqlCommand(query, connection))
                    using (SqlDataAdapter adapter = new SqlDataAdapter(command))
                    {
                        command.Parameters.AddWithValue("@EntitlementID", JobBeneBox.Text);

                        connection.Open();
                        SqlDataReader cr = command.ExecuteReader();
                        if (cr.Read())
                        {
                            JobBeneDescBox.Text = (cr["Description"].ToString());
                        }
                    }
        }
Ejemplo n.º 6
0
        //changes the values of the various text boxes when the value of the Employee ID box changes
        private void IDBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            showForeNames();
            showSurNames();
            showEmail();
            showJobs();
            showJobSection();
            showWUForeNames();
            showWUSurNames();
            showBenefits();
            showEmployeeBenefits();
            showJobBenefits();

            if (JobBeneBox.Items.Count == 0)
            {
                JobBeneDescBox.Clear();
            }
            if (EmpBeneBox.Items.Count == 0)
            {
                EmpBeneDescBox.Clear();
            }
        }