예제 #1
0
        private void add_Click(object sender, EventArgs e)
        {
            AddEmployeeForm addForm = new AddEmployeeForm();

            addForm.ShowDialog();
            var employee = addForm.Employee;

            if (employee == null)
            {
                return;
            }
            dataGridEmployee.Rows.Add(employee.Name, employee.Surname, employee.WorkExperience, GetPosition(employee.Position), GetEducation(employee.Education));
            Listing.listEmployees.Add(employee);
            remove.Enabled  = true;
            btnEdit.Enabled = true;
        }
예제 #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int             row      = dataGridEmployee.SelectedCells[0].RowIndex;
            int             column   = dataGridEmployee.SelectedCells[0].ColumnIndex;
            AddEmployeeForm editForm = new AddEmployeeForm(row);

            editForm.ShowDialog();
            var employee = editForm.Employee;

            if (employee == null)
            {
                return;
            }
            Listing.listEmployees.Insert(row, employee);
            Listing.listEmployees.RemoveAt(row + 1);
            dataGridEmployee.Rows.Clear();
            foreach (var data in Listing.listEmployees)
            {
                dataGridEmployee.Rows.Add(data.Name, data.Surname, data.WorkExperience, GetPosition(data.Position), GetEducation(data.Education));
            }
            dataGridEmployee.CurrentCell        = dataGridEmployee.Rows[row].Cells[column];
            dataGridEmployee.Rows[row].Selected = true;
        }