private void btnModifierChambre_Click(object sender, EventArgs e) { frmGestionAjoutModifChambres = new frmGestionAjoutModificationChambres(); frmGestionAjoutModifChambres.strvaleur = "b"; int noChambre = chambreBindingSource.Position; int nbChambre = chambreBindingSource.Count; if (noChambre >= 0 && noChambre < nbChambre) { dynamic chambreSelectionne = chambreBindingSource.Current; frmGestionAjoutModifChambres.strDecoration = chambreSelectionne["Decorations"]; frmGestionAjoutModifChambres.intEmplacement = chambreSelectionne["Emplacement"]; frmGestionAjoutModifChambres.intNoTypeChambre = chambreSelectionne["NoTypeChambre"]; } if (frmGestionAjoutModifChambres.ShowDialog() == DialogResult.OK) { chambreDataGridView.CurrentRow.Cells[1].Value = frmGestionAjoutModifChambres.intEmplacement; chambreDataGridView.CurrentRow.Cells[2].Value = frmGestionAjoutModifChambres.strDecoration; chambreDataGridView.CurrentRow.Cells[3].Value = frmGestionAjoutModifChambres.intNoTypeChambre; this.Validate(); this.chambreBindingSource.EndEdit(); this.chambreTableAdapter.Update(this.bDTP1Guelleh_MarreroDataSet); } }
private void btnAjouterChambre_Click(object sender, EventArgs e) { frmGestionAjoutModifChambres = new frmGestionAjoutModificationChambres(); frmGestionAjoutModifChambres.strvaleur = "a"; BDTP1Guelleh_MarreroDataSet.ChambreRow uneChambre = bDTP1Guelleh_MarreroDataSet.Chambre.NewChambreRow(); decimal noChambreMax = 0; foreach (BDTP1Guelleh_MarreroDataSet.ChambreRow uneLigne in bDTP1Guelleh_MarreroDataSet.Chambre.Rows) { if (uneLigne.NoChambre > noChambreMax) { noChambreMax = uneLigne.NoChambre; } } uneChambre.NoChambre = Convert.ToInt32(noChambreMax + 1); frmGestionAjoutModifChambres.uneChambre = uneChambre; if (frmGestionAjoutModifChambres.ShowDialog() == DialogResult.OK) { if (uneChambre.NoChambre != -1) { bDTP1Guelleh_MarreroDataSet.Chambre.AddChambreRow(uneChambre); chambreBindingSource.MoveLast(); this.chambreTableAdapter.Update(this.bDTP1Guelleh_MarreroDataSet.Chambre); MessageBox.Show("La chambre " + uneChambre.NoChambre.ToString() + " a été ajouté", "Ajout d'une chambre", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }