private void btnEnr_Click(object sender, EventArgs e) { if (txtNom.Text == "" || txtRef.Text == "" || cbType.SelectedValue == "" || cbClient.SelectedValue == "" || cbSite.SelectedValue == "" || nUpMTBF.Text == "" || txtDescr.Text == "") { MessageBox.Show("Veuillez remplir les champs.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (btnEnr.Text == "Ajouter") { var dataMat = new Data_Materiels(txtNom.Text.Trim(), txtRef.Text.Trim(), txtDescr.Text.Trim(), dtpInstal.Text.Trim(), nUpMTBF.Text.Trim(), checkbPerime.Checked.ToString(), cbType.SelectedValue.ToString(), cbSite.SelectedValue.ToString(), cbClient.SelectedValue.ToString()); Fcts_Materiels.AjoutMateriel(dataMat); } else if (btnEnr.Text == "Modifier") { var dataMat = new Data_Materiels(txtNom.Text.Trim(), txtRef.Text.Trim(), txtDescr.Text.Trim(), dtpInstal.Text.Trim(), nUpMTBF.Text.Trim(), checkbPerime.Checked.ToString(), cbType.SelectedValue.ToString(), cbSite.SelectedValue.ToString(), cbClient.SelectedValue.ToString()); Fcts_Materiels.ModifMat(dataMat, id); } } _parent.Display(); }
private void dgvMat_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 0) { Fcts_Materiels.EstIntervenu(dgvMat.Rows[e.RowIndex].Cells[3].Value.ToString()); Display(); } else if (e.ColumnIndex == 1) { formAm.id = dgvMat.Rows[e.RowIndex].Cells[3].Value.ToString(); formAm.nomMat = dgvMat.Rows[e.RowIndex].Cells[4].Value.ToString(); formAm.refMat = dgvMat.Rows[e.RowIndex].Cells[5].Value.ToString(); formAm.descr = dgvMat.Rows[e.RowIndex].Cells[6].Value.ToString(); formAm.dateInstal = dgvMat.Rows[e.RowIndex].Cells[7].Value.ToString(); formAm.mtbf = dgvMat.Rows[e.RowIndex].Cells[8].Value.ToString(); formAm.perime = dgvMat.Rows[e.RowIndex].Cells[11].Value.ToString(); formAm.idType = dgvMat.Rows[e.RowIndex].Cells[12].Value.ToString(); formAm.idSite = dgvMat.Rows[e.RowIndex].Cells[13].Value.ToString(); formAm.idClient = dgvMat.Rows[e.RowIndex].Cells[14].Value.ToString(); formAm.MultipleCb(); formAm.ModifMat(); formAm.ShowDialog(); } else if (e.ColumnIndex == 2) { if (MessageBox.Show("Voulez-vous vraiment supprimer ce materiel ?", "Information", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { Fcts_Materiels.SupprMateriel(dgvMat.Rows[e.RowIndex].Cells[3].Value.ToString()); Display(); } } }