Exemplo n.º 1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     // Open frmEmployeeDetails with all fields blank.
     frmEmployeeDetails newEmployee = new frmEmployeeDetails();
     newEmployee.FormClosed += EmployeeDetails_FormClosed;
     newEmployee.Show();
 }
Exemplo n.º 2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            DataRow selectedRow;

            if (dataGrdEmployees.SelectedRows.Count != 0)
            {
                // Get the currently selected row.
                selectedRow = ((DataRowView)dataGrdEmployees.SelectedRows[0].DataBoundItem).Row;

                // Open frmEmployeeDetails with the values of the selected row filled in.
                frmEmployeeDetails editEmployee = new frmEmployeeDetails(selectedRow);
                editEmployee.FormClosed += EmployeeDetails_FormClosed;
                editEmployee.Show();
            }
            else
            {
                MessageBox.Show("Please select an employee to edit.", "No Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }