Ejemplo n.º 1
0
        private void displayButton_Click(object sender, EventArgs e)
        {
            DisplayForm dForm = new DisplayForm(); //creates instance of Display form;

           if(count<3) //Checks atleast 10 employees have been entered, otherwise it gives 
                        //an error message  
            {
                MessageBox.Show("You must enter atleast 10 employees!");
            }
            else   //if count is more than 10 or more than 10 employees have been entered
            for (int i = 0; i < count; i++)   //it takes the details of each employee
            {
                string workerString = workers[i].employeeToString() + "\r\n"; //and puts them in an
                                                                            //array - workers[]
          
                dForm.richTextBox2.AppendText(workerString); //the string of employee details is 
                                                           //sent to the display form's richtextbox
                dForm.Show();                              //this shows the display form with all 
                                                           //the details 
            } 
         }
Ejemplo n.º 2
0
        //Method that receives the array of workers and prints the ones with the lowest salary
        private void PrintLowestSalary(Employee[] workers)
        {
            DisplayForm dForm = new DisplayForm(); //instance of display form

            dForm.richTextBox2.AppendText("Lowest salary workers:" + "\r\n" + "\r\n");
            double minSalary = workers[0].Salary;  //sets the the first element of the array
                                                   //as the default minimum salary

            for (int i = 0; i < count; i++)
            {
                if (workers[i].Salary < minSalary) //compares the minimum salary with other salaries
                {
                    minSalary = workers[i].Salary; //saves the new minimum salary
                }
            }

            //prints the employees with the lowest salary
            for (int i = 0; i < count; i++)  //checks every employee in the array
            {
                if (workers[i].Salary == minSalary) // if his salary is the same as the 
                                                    //minimum salary 
                {
                    string workerString = workers[i].employeeToString() + "\r\n";
                    dForm.richTextBox2.AppendText(workerString);//it sends the string to the 
                                                                //display form

                    dForm.Show();                              //shows the display form
                }
            }
        }