private void GridMatriel_EditerMatrielEvent(object sender, EventArgs e) { Classe.Service mat = gridService1.Current;; string tabEditerName = "TabEditer-" + mat.Observation; if (tabService.TabPages.IndexOfKey(tabEditerName) == -1) { // Création de Tab TabPage tabEditerStagiaire = new TabPage(); tabEditerStagiaire.Text = mat.Observation + " "; tabEditerStagiaire.Name = tabEditerName; tabService.TabPages.Add(tabEditerStagiaire); tabService.SelectedTab = tabEditerStagiaire; // Insertion du formulaire FormService matForm = new FormService(); matForm.Name = "MatrielForm"; matForm.Service = mat; matForm.Afficher(); this.tabService.TabPages[tabEditerName].Controls.Add(matForm); // matForm.EnregistrerClick += StagiaireForm_EditerClick; // matForm.AnnulerClick += StagiaireForm_AnnulerEditerClick; } }
private void StagiaireForm_AnnulerEditerClick(object sender, EventArgs e) { FormService formMat = (FormService)sender; Classe.Service Mater = formMat.Service; string tabEditerName = "TabEditer-" + Mater.Observation; TabPage tabEditer = this.tabService.TabPages[tabEditerName]; tabService.TabPages.Remove(tabEditer); }
private void br_enregistrer_Click(object sender, EventArgs e) { if (this.Service == null) { Service = new Classe.Service(); } Service.Observation = observationTextBox.Text; EnregistrerClick(this, e); }
private void StagiaireForm_EditerClick(object sender, EventArgs e) { FormService formMatriel = (FormService)sender; Classe.Service mat = formMatriel.Service; string tabEditerName = "TabEditer-" + mat.Observation; TabPage tabEditer = this.tabService.TabPages[tabEditerName]; // if (new StagiairesService().Update(stagiaire)) { MessageBox.Show("Le Matriel :" + mat.ToString() + " a été bien enregistrer"); } // else { MessageBox.Show("Le Matriel :" + mat.ToString() + " n'est pas enregistrer car il n'y a pas des modifications"); } // Suppression de la page Editer this.tabService.TabPages.Remove(tabEditer); // this.materielGrid1.Actualiser(); }