Ajout des fonctionnalités pour modifier une personne et gérer ses absences
This commit is contained in:
parent
b68adb42ee
commit
e7f5498737
13 changed files with 511 additions and 42 deletions
49
projet/Controller/GestionAbsenceController.cs
Normal file
49
projet/Controller/GestionAbsenceController.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
using projet.dal;
|
||||||
|
using projet.modele;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace projet.Controller
|
||||||
|
{
|
||||||
|
internal class GestionAbsenceController
|
||||||
|
{
|
||||||
|
private readonly AbsenceAccess absenceAccess;
|
||||||
|
private readonly PersonnelAccess personnelAccess;
|
||||||
|
private readonly MotifAccess motifAccess;
|
||||||
|
|
||||||
|
public GestionAbsenceController()
|
||||||
|
{
|
||||||
|
absenceAccess = new AbsenceAccess();
|
||||||
|
personnelAccess = new PersonnelAccess();
|
||||||
|
motifAccess = new MotifAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Absence> GetAbsences(Personnel personnel)
|
||||||
|
{
|
||||||
|
return absenceAccess.GetAbsences(personnel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Motif> GetAllMotifs()
|
||||||
|
{
|
||||||
|
return motifAccess.GetAllMotifs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddAbsence(Absence absence, Personnel personne)
|
||||||
|
{
|
||||||
|
absenceAccess.AddAbsence(absence, personne);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteAbsence(Absence absence)
|
||||||
|
{
|
||||||
|
absenceAccess.DeleteAbsence(absence);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetMotifIdByLibelle(string libelle)
|
||||||
|
{
|
||||||
|
return motifAccess.GetMotifIdByLibelle(libelle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
31
projet/Controller/ModifierPersonneController.cs
Normal file
31
projet/Controller/ModifierPersonneController.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
using projet.dal;
|
||||||
|
using projet.modele;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace projet.Controller
|
||||||
|
{
|
||||||
|
internal class ModifierPersonneController
|
||||||
|
{
|
||||||
|
private readonly ServiceAccess serviceAccess;
|
||||||
|
private readonly PersonnelAccess personnelAccess;
|
||||||
|
|
||||||
|
public ModifierPersonneController()
|
||||||
|
{
|
||||||
|
serviceAccess = new ServiceAccess();
|
||||||
|
personnelAccess = new PersonnelAccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Service> GetAllServices()
|
||||||
|
{
|
||||||
|
return serviceAccess.GetAllServices();
|
||||||
|
}
|
||||||
|
public void ModifierPersonnel(Personnel personnel)
|
||||||
|
{
|
||||||
|
personnelAccess.ModifierPersonnel(personnel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
projet/View/Admin.Designer.cs
generated
1
projet/View/Admin.Designer.cs
generated
|
|
@ -136,6 +136,7 @@
|
||||||
buttonEdit.Size = new Size(150, 30);
|
buttonEdit.Size = new Size(150, 30);
|
||||||
buttonEdit.TabIndex = 9;
|
buttonEdit.TabIndex = 9;
|
||||||
buttonEdit.Text = "Modifier personne";
|
buttonEdit.Text = "Modifier personne";
|
||||||
|
buttonEdit.Click += buttonEdit_Click;
|
||||||
//
|
//
|
||||||
// buttonAbsence
|
// buttonAbsence
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -48,9 +48,10 @@ namespace projet.View
|
||||||
{
|
{
|
||||||
if (comboBoxPersonnel.SelectedItem != null)
|
if (comboBoxPersonnel.SelectedItem != null)
|
||||||
{
|
{
|
||||||
|
Personnel personne = (Personnel)comboBoxPersonnel.SelectedItem;
|
||||||
this.Hide();
|
this.Hide();
|
||||||
this.Close();
|
this.Close();
|
||||||
GestionAbsence gestionAbsence = new GestionAbsence();
|
GestionAbsence gestionAbsence = new GestionAbsence(personne);
|
||||||
gestionAbsence.ShowDialog();
|
gestionAbsence.ShowDialog();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -74,5 +75,21 @@ namespace projet.View
|
||||||
MessageBox.Show("Veuillez sélectionner un membre du personnel.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Veuillez sélectionner un membre du personnel.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void buttonEdit_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(comboBoxPersonnel.SelectedItem != null)
|
||||||
|
{
|
||||||
|
Personnel personne = (Personnel)comboBoxPersonnel.SelectedItem;
|
||||||
|
this.Hide();
|
||||||
|
this.Close();
|
||||||
|
ModifierPersonne modifierPersonne = new ModifierPersonne(personne);
|
||||||
|
modifierPersonne.ShowDialog();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Veuillez sélectionner un membre du personnel.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
60
projet/View/GestionAbsence.Designer.cs
generated
60
projet/View/GestionAbsence.Designer.cs
generated
|
|
@ -46,12 +46,15 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
|
DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
|
||||||
DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
|
DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
|
||||||
pictureBoxTop = new PictureBox();
|
pictureBoxTop = new PictureBox();
|
||||||
pictureBoxBottom = new PictureBox();
|
pictureBoxBottom = new PictureBox();
|
||||||
labelTitle = new Label();
|
labelTitle = new Label();
|
||||||
dataGridViewAbsences = new DataGridView();
|
dataGridViewAbsences = new DataGridView();
|
||||||
|
dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
|
||||||
|
dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
|
||||||
|
dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
|
||||||
groupBoxNouvelleAbsence = new GroupBox();
|
groupBoxNouvelleAbsence = new GroupBox();
|
||||||
labelDateDebut = new Label();
|
labelDateDebut = new Label();
|
||||||
textBoxDateDebut = new TextBox();
|
textBoxDateDebut = new TextBox();
|
||||||
|
|
@ -65,9 +68,7 @@
|
||||||
comboBoxAbsence = new ComboBox();
|
comboBoxAbsence = new ComboBox();
|
||||||
buttonSupprimer = new Button();
|
buttonSupprimer = new Button();
|
||||||
panelSeparator = new Panel();
|
panelSeparator = new Panel();
|
||||||
dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
|
buttonBack = new Button();
|
||||||
dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
|
|
||||||
dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
|
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxTop).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxTop).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxBottom).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxBottom).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewAbsences).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridViewAbsences).BeginInit();
|
||||||
|
|
@ -112,20 +113,36 @@
|
||||||
dataGridViewAbsences.AllowUserToAddRows = false;
|
dataGridViewAbsences.AllowUserToAddRows = false;
|
||||||
dataGridViewAbsences.AllowUserToDeleteRows = false;
|
dataGridViewAbsences.AllowUserToDeleteRows = false;
|
||||||
dataGridViewAbsences.AllowUserToResizeRows = false;
|
dataGridViewAbsences.AllowUserToResizeRows = false;
|
||||||
dataGridViewAbsences.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
|
dataGridViewAbsences.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3;
|
||||||
dataGridViewAbsences.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridViewAbsences.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridViewAbsences.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, dataGridViewTextBoxColumn2, dataGridViewTextBoxColumn3 });
|
dataGridViewAbsences.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, dataGridViewTextBoxColumn2, dataGridViewTextBoxColumn3 });
|
||||||
dataGridViewAbsences.EnableHeadersVisualStyles = false;
|
dataGridViewAbsences.EnableHeadersVisualStyles = false;
|
||||||
dataGridViewAbsences.Location = new Point(60, 240);
|
dataGridViewAbsences.Location = new Point(60, 240);
|
||||||
|
dataGridViewAbsences.MultiSelect = false;
|
||||||
dataGridViewAbsences.Name = "dataGridViewAbsences";
|
dataGridViewAbsences.Name = "dataGridViewAbsences";
|
||||||
dataGridViewAbsences.ReadOnly = true;
|
dataGridViewAbsences.ReadOnly = true;
|
||||||
dataGridViewAbsences.RowHeadersVisible = false;
|
dataGridViewAbsences.RowHeadersVisible = false;
|
||||||
dataGridViewCellStyle2.Font = new Font("Segoe UI", 10F);
|
dataGridViewCellStyle4.Font = new Font("Segoe UI", 10F);
|
||||||
dataGridViewAbsences.RowsDefaultCellStyle = dataGridViewCellStyle2;
|
dataGridViewAbsences.RowsDefaultCellStyle = dataGridViewCellStyle4;
|
||||||
dataGridViewAbsences.ScrollBars = ScrollBars.Vertical;
|
dataGridViewAbsences.ScrollBars = ScrollBars.Vertical;
|
||||||
|
dataGridViewAbsences.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridViewAbsences.Size = new Size(680, 180);
|
dataGridViewAbsences.Size = new Size(680, 180);
|
||||||
dataGridViewAbsences.TabIndex = 3;
|
dataGridViewAbsences.TabIndex = 3;
|
||||||
dataGridViewAbsences.CellContentClick += dataGridViewAbsences_CellContentClick;
|
//
|
||||||
|
// dataGridViewTextBoxColumn1
|
||||||
|
//
|
||||||
|
dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
|
||||||
|
dataGridViewTextBoxColumn1.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// dataGridViewTextBoxColumn2
|
||||||
|
//
|
||||||
|
dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
|
||||||
|
dataGridViewTextBoxColumn2.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// dataGridViewTextBoxColumn3
|
||||||
|
//
|
||||||
|
dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
|
||||||
|
dataGridViewTextBoxColumn3.ReadOnly = true;
|
||||||
//
|
//
|
||||||
// groupBoxNouvelleAbsence
|
// groupBoxNouvelleAbsence
|
||||||
//
|
//
|
||||||
|
|
@ -210,6 +227,7 @@
|
||||||
buttonAjouter.TabIndex = 6;
|
buttonAjouter.TabIndex = 6;
|
||||||
buttonAjouter.Text = "Ajouter";
|
buttonAjouter.Text = "Ajouter";
|
||||||
buttonAjouter.UseVisualStyleBackColor = true;
|
buttonAjouter.UseVisualStyleBackColor = true;
|
||||||
|
buttonAjouter.Click += buttonAjouter_Click;
|
||||||
//
|
//
|
||||||
// groupBoxSupprimerAbsence
|
// groupBoxSupprimerAbsence
|
||||||
//
|
//
|
||||||
|
|
@ -252,6 +270,7 @@
|
||||||
buttonSupprimer.TabIndex = 2;
|
buttonSupprimer.TabIndex = 2;
|
||||||
buttonSupprimer.Text = "Supprimer";
|
buttonSupprimer.Text = "Supprimer";
|
||||||
buttonSupprimer.UseVisualStyleBackColor = true;
|
buttonSupprimer.UseVisualStyleBackColor = true;
|
||||||
|
buttonSupprimer.Click += buttonSupprimer_Click;
|
||||||
//
|
//
|
||||||
// panelSeparator
|
// panelSeparator
|
||||||
//
|
//
|
||||||
|
|
@ -261,26 +280,22 @@
|
||||||
panelSeparator.Size = new Size(2, 160);
|
panelSeparator.Size = new Size(2, 160);
|
||||||
panelSeparator.TabIndex = 6;
|
panelSeparator.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// dataGridViewTextBoxColumn1
|
// buttonBack
|
||||||
//
|
//
|
||||||
dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
|
buttonBack.Location = new Point(60, 646);
|
||||||
dataGridViewTextBoxColumn1.ReadOnly = true;
|
buttonBack.Name = "buttonBack";
|
||||||
//
|
buttonBack.Size = new Size(75, 23);
|
||||||
// dataGridViewTextBoxColumn2
|
buttonBack.TabIndex = 7;
|
||||||
//
|
buttonBack.Text = "Retour";
|
||||||
dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
|
buttonBack.UseVisualStyleBackColor = true;
|
||||||
dataGridViewTextBoxColumn2.ReadOnly = true;
|
buttonBack.Click += buttonBack_Click;
|
||||||
//
|
|
||||||
// dataGridViewTextBoxColumn3
|
|
||||||
//
|
|
||||||
dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
|
|
||||||
dataGridViewTextBoxColumn3.ReadOnly = true;
|
|
||||||
//
|
//
|
||||||
// GestionAbsence
|
// GestionAbsence
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 800);
|
ClientSize = new Size(800, 800);
|
||||||
|
Controls.Add(buttonBack);
|
||||||
Controls.Add(pictureBoxTop);
|
Controls.Add(pictureBoxTop);
|
||||||
Controls.Add(pictureBoxBottom);
|
Controls.Add(pictureBoxBottom);
|
||||||
Controls.Add(labelTitle);
|
Controls.Add(labelTitle);
|
||||||
|
|
@ -307,5 +322,6 @@
|
||||||
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
|
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
|
||||||
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
|
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
|
||||||
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
|
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
|
||||||
|
private Button buttonBack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using projet.modele;
|
||||||
|
using projet.Controller;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
|
@ -12,14 +14,114 @@ namespace projet.View
|
||||||
{
|
{
|
||||||
public partial class GestionAbsence : Form
|
public partial class GestionAbsence : Form
|
||||||
{
|
{
|
||||||
public GestionAbsence()
|
private Personnel personne;
|
||||||
|
private GestionAbsenceController controller;
|
||||||
|
public GestionAbsence(Personnel personne)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.personne = personne;
|
||||||
|
Init();
|
||||||
|
labelTitle.Text = $"Gestion des absences de {personne.Nom} {personne.Prenom}";
|
||||||
|
RemplirComboBoxMotif();
|
||||||
|
RemplirComboBoxAbsence();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dataGridViewAbsences_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
private void Init()
|
||||||
{
|
{
|
||||||
|
controller = new GestionAbsenceController();
|
||||||
|
|
||||||
|
// Effacer les colonnes par défaut avant d'assigner la source de données
|
||||||
|
dataGridViewAbsences.Columns.Clear();
|
||||||
|
|
||||||
|
dataGridViewAbsences.DataSource = controller.GetAbsences(personne);
|
||||||
|
dataGridViewAbsences.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
|
||||||
|
// Configuration des colonnes
|
||||||
|
dataGridViewAbsences.Columns["IdPersonnel"].Visible = false;
|
||||||
|
dataGridViewAbsences.Columns["DateDebut"].HeaderText = "Date de début";
|
||||||
|
dataGridViewAbsences.Columns["DateFin"].HeaderText = "Date de fin";
|
||||||
|
dataGridViewAbsences.Columns["IdMotif"].HeaderText = "Motif";
|
||||||
|
|
||||||
|
// Format des dates
|
||||||
|
dataGridViewAbsences.Columns["DateDebut"].DefaultCellStyle.Format = "dd/MM/yyyy";
|
||||||
|
dataGridViewAbsences.Columns["DateFin"].DefaultCellStyle.Format = "dd/MM/yyyy";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAjouter_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(textBoxDateDebut.Text) || !string.IsNullOrEmpty(textBoxDateFin.Text) || comboBoxMotif.SelectedItem != null)
|
||||||
|
{
|
||||||
|
string dateDebutStr = textBoxDateDebut.Text;
|
||||||
|
string dateFinStr = textBoxDateFin.Text;
|
||||||
|
|
||||||
|
DateTime dateDebut, dateFin;
|
||||||
|
|
||||||
|
if (DateTime.TryParseExact(dateDebutStr, "dd-MM-yyyy", null, System.Globalization.DateTimeStyles.None, out dateDebut) &&
|
||||||
|
DateTime.TryParseExact(dateFinStr, "dd-MM-yyyy", null, System.Globalization.DateTimeStyles.None, out dateFin))
|
||||||
|
{
|
||||||
|
string idMotif = Convert.ToString(((Motif)comboBoxMotif.SelectedItem).IdMotif);
|
||||||
|
Absence absence = new Absence(personne.IdPersonnel, dateDebut, dateFin, idMotif);
|
||||||
|
controller.AddAbsence(absence, personne);
|
||||||
|
dataGridViewAbsences.DataSource = controller.GetAbsences(personne);
|
||||||
|
|
||||||
|
textBoxDateDebut.Clear();
|
||||||
|
textBoxDateFin.Clear();
|
||||||
|
comboBoxMotif.SelectedIndex = -1; // Réinitialiser la sélection du motif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Erreur : Format de date invalide\nUtilisez le format : dd-MM-yyyy", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Veuillez remplir tous les champs.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void RemplirComboBoxMotif()
|
||||||
|
{
|
||||||
|
List<Motif> motifs = controller.GetAllMotifs();
|
||||||
|
foreach (Motif motif in motifs)
|
||||||
|
{
|
||||||
|
comboBoxMotif.Items.Add(motif);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSupprimer_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxAbsence.SelectedIndex == -1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Veuillez sélectionner une absence à supprimer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Absence absence = (Absence)comboBoxAbsence.SelectedItem;
|
||||||
|
int idMotif = controller.GetMotifIdByLibelle(absence.IdMotif);
|
||||||
|
Absence absence2 = new Absence(absence.IdPersonnel, absence.DateDebut, absence.DateFin, Convert.ToString(idMotif));
|
||||||
|
controller.DeleteAbsence(absence2);
|
||||||
|
|
||||||
|
RemplirComboBoxAbsence();
|
||||||
|
dataGridViewAbsences.DataSource = controller.GetAbsences(personne);
|
||||||
|
comboBoxAbsence.SelectedIndex = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemplirComboBoxAbsence()
|
||||||
|
{
|
||||||
|
comboBoxAbsence.Items.Clear();
|
||||||
|
List<Absence> absences = controller.GetAbsences(personne);
|
||||||
|
foreach (Absence absence in absences)
|
||||||
|
{
|
||||||
|
comboBoxAbsence.Items.Add(absence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonBack_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Hide();
|
||||||
|
this.Close();
|
||||||
|
Admin admin = new Admin();
|
||||||
|
admin.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
3
projet/View/ModifierPersonne.Designer.cs
generated
3
projet/View/ModifierPersonne.Designer.cs
generated
|
|
@ -128,7 +128,6 @@
|
||||||
tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F));
|
tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F));
|
||||||
tableLayoutPanel.Size = new Size(560, 250);
|
tableLayoutPanel.Size = new Size(560, 250);
|
||||||
tableLayoutPanel.TabIndex = 3;
|
tableLayoutPanel.TabIndex = 3;
|
||||||
tableLayoutPanel.Visible = false;
|
|
||||||
//
|
//
|
||||||
// labelNom
|
// labelNom
|
||||||
//
|
//
|
||||||
|
|
@ -244,6 +243,7 @@
|
||||||
buttonConfirmer.Size = new Size(120, 23);
|
buttonConfirmer.Size = new Size(120, 23);
|
||||||
buttonConfirmer.TabIndex = 0;
|
buttonConfirmer.TabIndex = 0;
|
||||||
buttonConfirmer.Text = "CONFIRMER";
|
buttonConfirmer.Text = "CONFIRMER";
|
||||||
|
buttonConfirmer.Click += buttonConfirmer_Click;
|
||||||
//
|
//
|
||||||
// buttonAnnuler
|
// buttonAnnuler
|
||||||
//
|
//
|
||||||
|
|
@ -252,6 +252,7 @@
|
||||||
buttonAnnuler.Size = new Size(100, 23);
|
buttonAnnuler.Size = new Size(100, 23);
|
||||||
buttonAnnuler.TabIndex = 1;
|
buttonAnnuler.TabIndex = 1;
|
||||||
buttonAnnuler.Text = "Annuler";
|
buttonAnnuler.Text = "Annuler";
|
||||||
|
buttonAnnuler.Click += buttonAnnuler_Click;
|
||||||
//
|
//
|
||||||
// ModifierPersonne
|
// ModifierPersonne
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using projet.Controller;
|
||||||
|
using projet.modele;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
|
@ -12,9 +14,73 @@ namespace projet.View
|
||||||
{
|
{
|
||||||
public partial class ModifierPersonne : Form
|
public partial class ModifierPersonne : Form
|
||||||
{
|
{
|
||||||
public ModifierPersonne()
|
private ModifierPersonneController controller;
|
||||||
|
private Personnel personne;
|
||||||
|
public ModifierPersonne(Personnel personne)
|
||||||
{
|
{
|
||||||
|
Init();
|
||||||
|
this.personne = personne;
|
||||||
InitializeComponent();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,102 @@
|
||||||
namespace projet.dal
|
using projet.modele;
|
||||||
|
|
||||||
|
namespace projet.dal
|
||||||
{
|
{
|
||||||
public class AbsenceAccess
|
public class AbsenceAccess
|
||||||
{
|
{
|
||||||
private static readonly string connectionString = "server=localhost;user id=root;password=;database=mediatek;";
|
private readonly Access access;
|
||||||
|
public AbsenceAccess()
|
||||||
public static string GetConnexion()
|
|
||||||
{
|
{
|
||||||
return connectionString;
|
access = Access.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Absence> GetAbsences(Personnel personnel)
|
||||||
|
{
|
||||||
|
List<Absence> absences = new List<Absence>();
|
||||||
|
if (access.Manager != null)
|
||||||
|
{
|
||||||
|
// Sélecte toutes les absence + join libelle du motif d'absence
|
||||||
|
string req2 = "SELECT a.idPersonnel, a.dateDebut, a.dateFin, m.libelle FROM absence a JOIN motif m ON a.idMotif = m.idMotif WHERE a.idPersonnel = @idPersonnel ORDER BY a.dateDebut;";
|
||||||
|
//string req = "SELECT * FROM absence WHERE idPersonnel = @idPersonnel ORDER BY dateDebut;";
|
||||||
|
var parameters = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "@idPersonnel", personnel.IdPersonnel }
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Exécute la requête de sélection
|
||||||
|
List<Object[]> resultats = access.Manager.ReqSelect(req2, parameters);
|
||||||
|
if (resultats != null)
|
||||||
|
{
|
||||||
|
// Parcourt les résultats et crée des objets Absence
|
||||||
|
foreach (Object[] resultat in resultats)
|
||||||
|
{
|
||||||
|
Absence absence = new Absence(
|
||||||
|
Convert.ToInt32(resultat[0]), // IdPersonnel
|
||||||
|
Convert.ToDateTime(resultat[1]), // DateDebut
|
||||||
|
Convert.ToDateTime(resultat[2]), // DateFin
|
||||||
|
Convert.ToString(resultat[3])// Motif
|
||||||
|
);
|
||||||
|
absences.Add(absence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return absences;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Erreur lors de la récupération des absences du personnel.");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return absences;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddAbsence(Absence absence, Personnel personne)
|
||||||
|
{
|
||||||
|
if (access.Manager != null)
|
||||||
|
{
|
||||||
|
string req = "INSERT INTO absence (idPersonnel, dateDebut, dateFin, idMotif) VALUES (@idPersonnel, @dateDebut, @dateFin, @idMotif);";
|
||||||
|
var parameters = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "@idPersonnel", personne.IdPersonnel },
|
||||||
|
{ "@dateDebut", absence.DateDebut },
|
||||||
|
{ "@dateFin", absence.DateFin },
|
||||||
|
{ "@idMotif", Convert.ToInt32(absence.IdMotif) }
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
access.Manager.ReqUpdate(req, parameters);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Erreur lors de l'ajout de l'absence.");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeleteAbsence(Absence absence)
|
||||||
|
{
|
||||||
|
if (access.Manager != null)
|
||||||
|
{
|
||||||
|
string req = "DELETE FROM absence WHERE idPersonnel = @idPersonnel AND dateDebut = @dateDebut AND dateFin = @dateFin AND idMotif = @idMotif;";
|
||||||
|
var parameters = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "@idPersonnel", absence.IdPersonnel },
|
||||||
|
{ "@dateDebut", absence.DateDebut },
|
||||||
|
{ "@dateFin", absence.DateFin },
|
||||||
|
{ "@idMotif", Convert.ToInt32(absence.IdMotif) }
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
access.Manager.ReqUpdate(req, parameters);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Erreur lors de la suppression de l'absence.");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,72 @@
|
||||||
namespace projet.dal
|
using projet.modele;
|
||||||
|
|
||||||
|
namespace projet.dal
|
||||||
{
|
{
|
||||||
public class MotifAccess
|
public class MotifAccess
|
||||||
{
|
{
|
||||||
private static readonly string connectionString = "server=localhost;user id=root;password=;database=mediatek;";
|
private readonly Access access;
|
||||||
|
|
||||||
public static string GetConnexion()
|
public MotifAccess()
|
||||||
{
|
{
|
||||||
return connectionString;
|
access = Access.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Motif> GetAllMotifs()
|
||||||
|
{
|
||||||
|
List<Motif> motifList = new List<Motif>();
|
||||||
|
if (access.Manager != null)
|
||||||
|
{
|
||||||
|
string req = "SELECT * FROM motif ORDER BY libelle;";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Object[]> resultats = access.Manager.ReqSelect(req);
|
||||||
|
if (resultats != null)
|
||||||
|
{
|
||||||
|
foreach (Object[] resultat in resultats)
|
||||||
|
{
|
||||||
|
Motif motif = new Motif(
|
||||||
|
Convert.ToInt32(resultat[0]), // IdMotif
|
||||||
|
Convert.ToString(resultat[1]) // Libelle
|
||||||
|
);
|
||||||
|
motifList.Add(motif);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Erreur lors de la récupération des données des motifs.");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return motifList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetMotifIdByLibelle(string libelle)
|
||||||
|
{
|
||||||
|
int idMotif = -1;
|
||||||
|
if (access.Manager != null)
|
||||||
|
{
|
||||||
|
string req = "SELECT idMotif FROM motif WHERE libelle = @libelle;";
|
||||||
|
var parameters = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "@libelle", libelle }
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Object[]> resultats = access.Manager.ReqSelect(req, parameters);
|
||||||
|
if (resultats != null && resultats.Count > 0)
|
||||||
|
{
|
||||||
|
idMotif = Convert.ToInt32(resultats[0][0]);
|
||||||
|
}
|
||||||
|
return idMotif;
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Erreur lors de la récupération de l'ID du motif par libellé.");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return idMotif;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,5 +89,30 @@ namespace projet.dal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void ModifierPersonnel(Personnel personnel)
|
||||||
|
{
|
||||||
|
if(access.Manager != null)
|
||||||
|
{
|
||||||
|
string req = "UPDATE personnel SET nom = @nom, prenom = @prenom, tel = @tel, mail = @mail, idService = @idService WHERE idPersonnel = @idPersonnel;";
|
||||||
|
var parameters = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "@idPersonnel", personnel.IdPersonnel },
|
||||||
|
{ "@nom", personnel.Nom },
|
||||||
|
{ "@prenom", personnel.Prenom },
|
||||||
|
{ "@tel", personnel.Tel },
|
||||||
|
{ "@mail", personnel.Mail },
|
||||||
|
{ "@idService", personnel.IdService }
|
||||||
|
};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
access.Manager.ReqUpdate(req, parameters);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Erreur lors de la modification du personnel dans la base de données.");
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,23 @@ namespace projet.modele
|
||||||
public DateTime? DateFin { get; set; }
|
public DateTime? DateFin { get; set; }
|
||||||
|
|
||||||
/// <summary>Identifiant du motif d'absence</summary>
|
/// <summary>Identifiant du motif d'absence</summary>
|
||||||
public int IdMotif { get; set; }
|
public string IdMotif { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructeur de la classe Absence
|
/// Constructeur de la classe Absence
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Absence(int idPersonnel, DateTime dateDebut, DateTime? dateFin, int idMotif)
|
public Absence(int idPersonnel, DateTime dateDebut, DateTime? dateFin, string idMotif)
|
||||||
{
|
{
|
||||||
IdPersonnel = idPersonnel;
|
IdPersonnel = idPersonnel;
|
||||||
DateDebut = dateDebut;
|
DateDebut = dateDebut;
|
||||||
DateFin = dateFin;
|
DateFin = dateFin;
|
||||||
IdMotif = idMotif;
|
IdMotif = idMotif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
string dateDebut = Convert.ToString(DateDebut);
|
||||||
|
return dateDebut.Split(' ')[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,10 @@
|
||||||
IdMotif = idMotif;
|
IdMotif = idMotif;
|
||||||
Libelle = libelle;
|
Libelle = libelle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return this.Libelle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue