Hi there,
I just saw the thread about helping with assignments but I'm hoping you will be able to share your knowledge with me on this.
We have had one week to complete this assignment and I'm beginning to worry I won't be able to finish it, I've tried to find things on the internet and I've played around with my code for hours but just cant seem to get it right. Please give me some pointers!

This is obviously using C# and we are using Windows Forms.

The purpose of the assignment is to create a prototype program to enable a large Florist’s business to handle information about their employees.

The program will be a single form that allows the user to -
1. Add an employee record
a. Employee details include: last name, first name, salary, a single telephone number (a string), date employed, job role (a char – M for manager, S for supervisor, F for florist and L for labourer).
2. Display all employees
a. List all current employees alphabetically by surname.
b. List all current employees by their job role, and within that category, alphabetically by surname.
c. Select and delete an employee record.
3. Calculate the maximum total commission for all florists. Commission is 10% of the total salary for all florists.
4. Display all of the employee’s details in a format suitable for printing.
5. All data entry must be validated and exceptions handled appropriately.
6. All displayed data must be in the appropriate format.
7. All variables must be of the appropriate data type.
8. Appropriate controls must be used on the forms (e.g. text box, list box or combo box, date time picker etc.) including tool tips on data entry fields.
9. The tab order must be controlled to guide the user through the interface when entering data and when any data entry errors occur.
10. The form must be set up so that it is positioned in the centre of the screen on start up

The thing I really want help with is putting new employee details into a listbox.
At the moment I have put the text value of all relavent textboxes into an array and then used 'listbox.items.addrange' to add the array into the listbox. The problem with this however is that in the listbox, each instance of the array is seperated in the listbox. As in the employee details are not collective so I can't sort the employees by their last names as it sorts every value alphabetically, not just the lastname. I tried putting all the employee data into one instance of an array so it is collective, though now it sits only on one line of the listbox and using '\n' doesn't work. I just want each new employee record added to the listbox to be 'one employee' as such. So sorting the employess simply sorts them by last name, and if I choose to delete an employee it deletes all the records, not just one line.

Please give me some tips, if you understood that.
I can try and explain more clearly or post the full assignment, but atm I am completely stuck!

Thanks in advance!

-Eddy

Recommended Answers

All 4 Replies

Well, having read the assignment sticky you know we wont do it for you.

If its deleting all employees then your coding is wrong, which I guess you know, but, we have no code to comment on.

Have you covered databases on your course?

go step by step... dont try to solve all problem in one step...

and at the end you won't bleive that you did it...

This is my code for adding the employee details into an array and then to the listbox.

string[] newEmployeeArray = new string[1];
                        newEmployeeArray[0] = lastNameTextBox.Text + "\n\t"
                            + firstNameTextBox.Text + "\n\t"
                            + salaryTextBox.Text +  "\n\t"
                            + telephoneTextBox.Text + "\n\t"
                            + employmentDateTimePicker.Text + "\n\t" 
                            + jobRoleComboBox.Text + "\n\t";
                      
                        employeeListBox.Items.AddRange(newEmployeeArray)

However the \n does not create a new line in the textbox.
I don't know why, it just comes up with a [].
I tried putting each detail in a different part of the array, but then when it puts it into the listbox, each part of the array is seperate, so if I try delete or sort the employees by say last name, it sorts each attribute, or if I try and delete a whole employee it'll only delete each part seperately. What I want to do is get the Employee details into the listbox on different lines.. but all as one object.

Any ideas?

Also here are my sort and delete buttons.

private void sortEmployeeButton_Click(object sender, EventArgs e)
        {
            {
                int employeeCount = employeeListBox.Items.Count;
                string[] employeeListArray = new string[employeeCount];
                {
                    for (int l = 0; l < employeeCount; l++)
                    {
                        employeeListArray[l] = Convert.ToString(employeeListBox.Items[l]);
                    }
                }
                Array.Sort(employeeListArray);
                employeeListBox.Items.Clear();
                {
                        employeeListBox.Items.AddRange(employeeListArray);                    
                }
            }
        }
private void deleteEmployeeButton_Click(object sender, EventArgs e)
        {
            if (employeeListBox.Items.Count < 1)
            {
                MessageBox.Show("There are no items to delete");
            }
            else if (employeeListBox.Text == "")
            {
                MessageBox.Show("Please select an item to delete");
            }
            else
            {
                DialogResult button = MessageBox.Show(
                    "Do you want to perform this action?", "Are you sure?",                                                                                                                                                                                   			
                    MessageBoxButtons.YesNo,                                                        			
                    MessageBoxIcon.Question,                                                       			
                    MessageBoxDefaultButton.Button2 ); 
								if (button == DialogResult.Yes)
                                {
                                    employeeListBox.Items.RemoveAt(employeeListBox.SelectedIndex);     
                                }

            }
            employeeListBoxNumber = employeeListBoxNumber - 1;
        }

Listboxes dont support new lines by default..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.