private void modifierEmploye() { frmDetEmp detailEmploye; if (gestionEmp.etat == true) { detailEmploye = new frmDetEmp((Employe)this.Tag); detailEmploye.ShowDialog(); if (this.Tag != detailEmploye.Tag) update(); } else { string[] nEmp = new string[8]; int index = gridEmploye.SelectedRows[0].Index; for (int i = 0; i < 8; i++) { nEmp[i] = (string)gridEmploye.SelectedRows[0].Cells[i].Value.ToString(); } detailEmploye = new frmDetEmp(nEmp); detailEmploye.ShowDialog(); if (detailEmploye.Tag.ToString() == "1" && gestionEmp.verifAjout(detailEmploye.empSelect) == true) // il est ajouter { gestionEmp.supprimer(this.Tag); gridEmploye.Rows.RemoveAt(gridEmploye.SelectedRows[0].Index); } if (gridEmploye.Rows.Count == 0) this.Close(); else if(gridEmploye.Rows.Count > index) { gridEmploye.Rows[index].Selected = true; //gridEmploye.Rows[0].Cells[0].Selected = true; this.Tag = gridEmploye.Rows[index].Tag; } else { gridEmploye.Rows[index - 1].Selected = true; //gridEmploye.Rows[0].Cells[0].Selected = true; this.Tag = gridEmploye.Rows[index - 1].Tag; } } }
private void toolStripDetEmp_Click(object sender, EventArgs e) { var formOuvert = new frmDetEmp(); this.Hide(); formOuvert.Show(); formOuvert.Closed += (s, args) => this.Close(); }