91 lines
2.8 KiB
C#
91 lines
2.8 KiB
C#
using projet.Controller;
|
|
using projet.modele;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace projet.View
|
|
{
|
|
public partial class ModifierPersonne : Form
|
|
{
|
|
private ModifierPersonneController controller;
|
|
private Personnel personne;
|
|
|
|
/// <summary>
|
|
/// Méthode d'initialisation du formulaire de modification d'un personnel.
|
|
/// </summary>
|
|
/// <param name="personne">Personne concernée</param>
|
|
public ModifierPersonne(Personnel personne)
|
|
{
|
|
Init();
|
|
this.personne = personne;
|
|
InitializeComponent();
|
|
labelTitle.Text = $"Voulez vous vraiment modifier {personne.Prenom} ?";
|
|
remplirComboBoxService();
|
|
remplirInfos();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
controller = new ModifierPersonneController();
|
|
}
|
|
|
|
private void buttonAnnuler_Click(object sender, EventArgs e)
|
|
{
|
|
this.Hide();
|
|
this.Close();
|
|
Admin admin = new Admin();
|
|
admin.ShowDialog();
|
|
}
|
|
|
|
private void remplirInfos()
|
|
{
|
|
textBoxNom.Text = personne.Nom;
|
|
textBoxPrenom.Text = personne.Prenom;
|
|
textBoxMail.Text = personne.Mail;
|
|
textBoxTel.Text = personne.Tel;
|
|
comboBoxService.SelectedIndex = personne.IdService - 1;
|
|
}
|
|
|
|
private void remplirComboBoxService()
|
|
{
|
|
List<Service> services = controller.GetAllServices();
|
|
foreach (Service service in services)
|
|
{
|
|
comboBoxService.Items.Add(service.Nom);
|
|
}
|
|
}
|
|
|
|
private void buttonConfirmer_Click(object sender, EventArgs e)
|
|
{
|
|
if(string.IsNullOrEmpty(textBoxNom.Text) || string.IsNullOrEmpty(textBoxPrenom.Text) || string.IsNullOrEmpty(textBoxMail.Text) || string.IsNullOrEmpty(textBoxTel.Text) || comboBoxService.SelectedIndex == -1)
|
|
{
|
|
MessageBox.Show("Veuillez remplir tous les champs.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Personnel personne = new Personnel(
|
|
this.personne.IdPersonnel,
|
|
textBoxNom.Text,
|
|
textBoxPrenom.Text,
|
|
textBoxTel.Text,
|
|
textBoxMail.Text,
|
|
comboBoxService.SelectedIndex + 1
|
|
);
|
|
controller.ModifierPersonnel(personne);
|
|
|
|
this.Hide();
|
|
this.Close();
|
|
Admin admin = new Admin();
|
|
admin.ShowDialog();
|
|
}
|
|
}
|
|
}
|
|
}
|