示例#1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            EditDialog newEmployeeDialog = new EditDialog();

            if (newEmployeeDialog.ShowDialog() == DialogResult.OK)
            {
                lstEmployees.Items.Add(newEmployeeDialog.StaffMember);
            }
        }
示例#2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (lstEmployees.SelectedIndex == -1)
            {
                return;
            }

            int        employeeNum       = lstEmployees.SelectedIndex;
            EditDialog newEmployeeDialog = new EditDialog();

            newEmployeeDialog.StaffMember = (Employee)lstEmployees.SelectedItem;

            if (newEmployeeDialog.ShowDialog() == DialogResult.OK)
            {
                lstEmployees.Items.RemoveAt(employeeNum);
                lstEmployees.Items.Insert(employeeNum, newEmployeeDialog.StaffMember);
                lstEmployees.SelectedIndex = employeeNum;
            }
        }