Esempio n. 1
0
 private void AddNew()
 {
     try
     {
         Employee        emptyVar = new Employee();
         NewEmployeeForm newForm  = new NewEmployeeForm(ref emptyVar);
         newForm.ShowDialog(); //displays new form
         if (emptyVar.FirstName != null)
         {
             //creates Employee object with data
             eObjects[eIndex] = emptyVar;
             //adds object to the list box
             lstBxEmployees.Items.Add(eObjects[eIndex]);
             eIndex++;
         }
     }
     catch //displays MessageBox if unexpected error is encountered
     {
         ErrorBox();
     }
 }//code responsible for adding new item
Esempio n. 2
0
        }//code responsible for adding new item

        private void ItemProperties()
        {
            if (lstBxEmployees.SelectedIndex == -1)
            {
                MessageBox.Show("Select an item", "Properties");
            }
            else
            {
                //get index of selected item
                int      itemIndex = lstBxEmployees.SelectedIndex;
                Employee selected  = eObjects[itemIndex];

                //generates instance of form with Employee object
                NewEmployeeForm newForm = new NewEmployeeForm(ref selected);
                newForm.ShowDialog();

                //update listbox + array with new values
                eObjects[itemIndex]             = selected;
                lstBxEmployees.Items[itemIndex] = selected;
                lblStatus.Text = "Employee updated";
            }
        }