From b68adb42ee7f017e6968b82f8ed0d33356505088 Mon Sep 17 00:00:00 2001 From: xdatomic-the-codeur Date: Mon, 2 Jun 2025 15:19:31 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20des=20fonctionnalit=C3=A9s=20des=20bout?= =?UTF-8?q?ons=20"Ajouter=20personnel",=20"supprimer=20personnel".=20Syst?= =?UTF-8?q?=C3=A8me=20de=20connexion.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projet/Controller/AdminController.cs | 28 ++ .../ConfirmeSupressionPersonnelController.cs | 25 ++ projet/Controller/PageConnexionController.cs | 33 ++ projet/Controller/addPersonnelController.cs | 32 ++ projet/Program.cs | 4 +- projet/View/AddPersonnel.Designer.cs | 376 ++++++++++++------ projet/View/AddPersonnel.cs | 93 ++++- projet/View/AddPersonnel.resx | 54 +-- projet/View/Admin.Designer.cs | 187 ++++----- projet/View/Admin.cs | 60 ++- projet/View/Admin.resx | 54 +-- .../ConfirmeSupressionPersonnel.Designer.cs | 122 +++--- projet/View/ConfirmeSupressionPersonnel.cs | 33 +- projet/View/ConfirmeSupressionPersonnel.resx | 54 +-- projet/View/PageConnexion.Designer.cs | 6 +- projet/View/PageConnexion.cs | 44 +- projet/bddmanager/BddManager.cs | 2 +- projet/dal/AbsenceAccess.cs | 2 +- projet/dal/Access.cs | 37 ++ projet/dal/MotifAccess.cs | 2 +- projet/dal/PersonnelAccess.cs | 89 ++++- projet/dal/ResponsableAccess.cs | 38 +- projet/dal/ServiceAccess.cs | 39 +- projet/modele/Absence.cs | 2 +- projet/modele/Motif.cs | 2 +- projet/modele/Personnel.cs | 7 +- projet/modele/Responsable.cs | 2 +- projet/projet.csproj | 4 - 28 files changed, 1033 insertions(+), 398 deletions(-) create mode 100644 projet/Controller/AdminController.cs create mode 100644 projet/Controller/ConfirmeSupressionPersonnelController.cs create mode 100644 projet/Controller/PageConnexionController.cs create mode 100644 projet/Controller/addPersonnelController.cs create mode 100644 projet/dal/Access.cs diff --git a/projet/Controller/AdminController.cs b/projet/Controller/AdminController.cs new file mode 100644 index 0000000..281bb9b --- /dev/null +++ b/projet/Controller/AdminController.cs @@ -0,0 +1,28 @@ +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 AdminController + { + private readonly PersonnelAccess personnelAccess; + + /// + /// Récupère l'accès aux données des responsables. + /// + public AdminController() + { + personnelAccess = new PersonnelAccess(); + } + + public List GetAllPersonnel() + { + return personnelAccess.GetAllPersonnel(); + } + } +} diff --git a/projet/Controller/ConfirmeSupressionPersonnelController.cs b/projet/Controller/ConfirmeSupressionPersonnelController.cs new file mode 100644 index 0000000..b60cc9c --- /dev/null +++ b/projet/Controller/ConfirmeSupressionPersonnelController.cs @@ -0,0 +1,25 @@ +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 ConfirmeSupressionPersonnelController + { + private PersonnelAccess personnelAccess; + + public ConfirmeSupressionPersonnelController() + { + personnelAccess = new PersonnelAccess(); + } + + public void deletePersonnel(Personnel personnel) + { + personnelAccess.deletePersonnel(personnel); + } + } +} diff --git a/projet/Controller/PageConnexionController.cs b/projet/Controller/PageConnexionController.cs new file mode 100644 index 0000000..9be3a38 --- /dev/null +++ b/projet/Controller/PageConnexionController.cs @@ -0,0 +1,33 @@ +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 +{ + public class PageConnexionController + { + private readonly ResponsableAccess responsableAccess; + + /// + /// Récupère l'accès aux données des responsables. + /// + public PageConnexionController() + { + responsableAccess = new ResponsableAccess(); + } + + /// + /// Connecte un responsable à l'application. + /// + /// + /// + public bool ConnecterResponsable(Responsable responsable) + { + return responsableAccess.ConnecterResponsable(responsable); + } + } +} diff --git a/projet/Controller/addPersonnelController.cs b/projet/Controller/addPersonnelController.cs new file mode 100644 index 0000000..8c5f452 --- /dev/null +++ b/projet/Controller/addPersonnelController.cs @@ -0,0 +1,32 @@ +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 addPersonnelController + { + private readonly PersonnelAccess personnelAccess; + private readonly ServiceAccess serviceAccess; + + public addPersonnelController() + { + personnelAccess = new PersonnelAccess(); + serviceAccess = new ServiceAccess(); + } + + public List GetAllServices() + { + return serviceAccess.GetAllServices(); + } + + public void addPersonnel(Personnel personnel) + { + personnelAccess.addPersonnel(personnel); + } + } +} diff --git a/projet/Program.cs b/projet/Program.cs index 86c64d1..7792945 100644 --- a/projet/Program.cs +++ b/projet/Program.cs @@ -1,3 +1,5 @@ +using projet.View; + namespace projet { internal static class Program @@ -11,7 +13,7 @@ namespace projet // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new PageConnexion()); } } } \ No newline at end of file diff --git a/projet/View/AddPersonnel.Designer.cs b/projet/View/AddPersonnel.Designer.cs index eccc4ca..cc87e56 100644 --- a/projet/View/AddPersonnel.Designer.cs +++ b/projet/View/AddPersonnel.Designer.cs @@ -3,25 +3,93 @@ partial class AddPersonnel { /// - /// Required designer variable. + /// Variable nécessaire au concepteur. /// private System.ComponentModel.IContainer components = null; + + /// + /// Bannière supérieure du formulaire + /// private System.Windows.Forms.PictureBox pictureBoxTop; + + /// + /// Bannière inférieure du formulaire + /// private System.Windows.Forms.PictureBox pictureBoxBottom; + + /// + /// Titre du formulaire + /// private System.Windows.Forms.Label labelTitle; + + /// + /// Conteneur principal organisant les champs de saisie + /// private System.Windows.Forms.TableLayoutPanel tableLayoutPanel; + + /// + /// Étiquette pour le champ Nom + /// private System.Windows.Forms.Label labelNom; + + /// + /// Zone de saisie du nom + /// private System.Windows.Forms.TextBox textBoxNom; + + /// + /// Étiquette pour le champ Prénom + /// private System.Windows.Forms.Label labelPrenom; + + /// + /// Zone de saisie du prénom + /// private System.Windows.Forms.TextBox textBoxPrenom; + + /// + /// Étiquette pour le champ Téléphone + /// private System.Windows.Forms.Label labelTel; + + /// + /// Zone de saisie du numéro de téléphone + /// private System.Windows.Forms.TextBox textBoxTel; + + /// + /// Étiquette pour le champ Email + /// private System.Windows.Forms.Label labelMail; + + /// + /// Zone de saisie de l'adresse email + /// private System.Windows.Forms.TextBox textBoxMail; + + /// + /// Étiquette pour le champ Service + /// private System.Windows.Forms.Label labelService; + + /// + /// Liste déroulante pour la sélection du service + /// private System.Windows.Forms.ComboBox comboBoxService; + + /// + /// Conteneur pour les boutons d'action + /// private System.Windows.Forms.FlowLayoutPanel flowLayoutPanelButtons; + + /// + /// Bouton de validation pour ajouter le personnel + /// private System.Windows.Forms.Button buttonAjouter; + + /// + /// Bouton pour annuler l'opération + /// private System.Windows.Forms.Button buttonAnnuler; /// @@ -45,191 +113,235 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); - this.pictureBoxTop = new System.Windows.Forms.PictureBox(); - this.pictureBoxBottom = new System.Windows.Forms.PictureBox(); - this.labelTitle = new System.Windows.Forms.Label(); - this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); - this.labelNom = new System.Windows.Forms.Label(); - this.textBoxNom = new System.Windows.Forms.TextBox(); - this.labelPrenom = new System.Windows.Forms.Label(); - this.textBoxPrenom = new System.Windows.Forms.TextBox(); - this.labelTel = new System.Windows.Forms.Label(); - this.textBoxTel = new System.Windows.Forms.TextBox(); - this.labelMail = new System.Windows.Forms.Label(); - this.textBoxMail = new System.Windows.Forms.TextBox(); - this.labelService = new System.Windows.Forms.Label(); - this.comboBoxService = new System.Windows.Forms.ComboBox(); - this.flowLayoutPanelButtons = new System.Windows.Forms.FlowLayoutPanel(); - this.buttonAjouter = new System.Windows.Forms.Button(); - this.buttonAnnuler = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTop)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBottom)).BeginInit(); - this.tableLayoutPanel.SuspendLayout(); - this.flowLayoutPanelButtons.SuspendLayout(); - this.SuspendLayout(); + pictureBoxTop = new PictureBox(); + pictureBoxBottom = new PictureBox(); + labelTitle = new Label(); + tableLayoutPanel = new TableLayoutPanel(); + labelNom = new Label(); + textBoxNom = new TextBox(); + labelPrenom = new Label(); + textBoxPrenom = new TextBox(); + labelTel = new Label(); + textBoxTel = new TextBox(); + labelMail = new Label(); + textBoxMail = new TextBox(); + labelService = new Label(); + comboBoxService = new ComboBox(); + flowLayoutPanelButtons = new FlowLayoutPanel(); + buttonAjouter = new Button(); + buttonAnnuler = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxTop).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBottom).BeginInit(); + tableLayoutPanel.SuspendLayout(); + flowLayoutPanelButtons.SuspendLayout(); + SuspendLayout(); // // pictureBoxTop // - this.pictureBoxTop.Dock = System.Windows.Forms.DockStyle.Top; - // this.pictureBoxTop.Image = global::projet.Properties.Resources.BlueHeader; // Désactivé car ressource manquante - this.pictureBoxTop.BackColor = System.Drawing.Color.SteelBlue; - this.pictureBoxTop.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.pictureBoxTop.Location = new System.Drawing.Point(0, 0); - this.pictureBoxTop.Name = "pictureBoxTop"; - this.pictureBoxTop.Size = new System.Drawing.Size(800, 180); - this.pictureBoxTop.TabIndex = 0; - this.pictureBoxTop.TabStop = false; + pictureBoxTop.BackColor = Color.SteelBlue; + pictureBoxTop.Dock = DockStyle.Top; + pictureBoxTop.Location = new Point(0, 0); + pictureBoxTop.Name = "pictureBoxTop"; + pictureBoxTop.Size = new Size(800, 180); + pictureBoxTop.SizeMode = PictureBoxSizeMode.StretchImage; + pictureBoxTop.TabIndex = 0; + pictureBoxTop.TabStop = false; // // pictureBoxBottom // - this.pictureBoxBottom.Dock = System.Windows.Forms.DockStyle.Bottom; - // this.pictureBoxBottom.Image = global::projet.Properties.Resources.BlueFooter; // Désactivé car ressource manquante - this.pictureBoxBottom.BackColor = System.Drawing.Color.SteelBlue; - this.pictureBoxBottom.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.pictureBoxBottom.Location = new System.Drawing.Point(0, 500); - this.pictureBoxBottom.Name = "pictureBoxBottom"; - this.pictureBoxBottom.Size = new System.Drawing.Size(800, 100); - this.pictureBoxBottom.TabIndex = 1; - this.pictureBoxBottom.TabStop = false; + pictureBoxBottom.BackColor = Color.SteelBlue; + pictureBoxBottom.Dock = DockStyle.Bottom; + pictureBoxBottom.Location = new Point(0, 500); + pictureBoxBottom.Name = "pictureBoxBottom"; + pictureBoxBottom.Size = new Size(800, 100); + pictureBoxBottom.SizeMode = PictureBoxSizeMode.StretchImage; + pictureBoxBottom.TabIndex = 1; + pictureBoxBottom.TabStop = false; // // labelTitle // - this.labelTitle.Font = new System.Drawing.Font("Segoe UI", 28F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.labelTitle.Location = new System.Drawing.Point(0, 180); - this.labelTitle.Name = "labelTitle"; - this.labelTitle.Size = new System.Drawing.Size(800, 60); - this.labelTitle.TabIndex = 2; - this.labelTitle.Text = "Ajouter une personne"; - this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + labelTitle.Font = new Font("Segoe UI", 28F); + labelTitle.Location = new Point(0, 180); + labelTitle.Name = "labelTitle"; + labelTitle.Size = new Size(800, 60); + labelTitle.TabIndex = 2; + labelTitle.Text = "Ajouter une personne"; + labelTitle.TextAlign = ContentAlignment.MiddleCenter; // // tableLayoutPanel // - this.tableLayoutPanel.ColumnCount = 2; - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 30F)); - this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70F)); - this.tableLayoutPanel.RowCount = 6; - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 40F)); - this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 50F)); - this.tableLayoutPanel.Controls.Add(this.labelNom, 0, 0); - this.tableLayoutPanel.Controls.Add(this.textBoxNom, 1, 0); - this.tableLayoutPanel.Controls.Add(this.labelPrenom, 0, 1); - this.tableLayoutPanel.Controls.Add(this.textBoxPrenom, 1, 1); - this.tableLayoutPanel.Controls.Add(this.labelTel, 0, 2); - this.tableLayoutPanel.Controls.Add(this.textBoxTel, 1, 2); - this.tableLayoutPanel.Controls.Add(this.labelMail, 0, 3); - this.tableLayoutPanel.Controls.Add(this.textBoxMail, 1, 3); - this.tableLayoutPanel.Controls.Add(this.labelService, 0, 4); - this.tableLayoutPanel.Controls.Add(this.comboBoxService, 1, 4); - this.tableLayoutPanel.Controls.Add(this.flowLayoutPanelButtons, 1, 5); - this.tableLayoutPanel.Location = new System.Drawing.Point(120, 260); - this.tableLayoutPanel.Name = "tableLayoutPanel"; - this.tableLayoutPanel.Size = new System.Drawing.Size(560, 250); - this.tableLayoutPanel.TabIndex = 3; + tableLayoutPanel.ColumnCount = 2; + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 30F)); + tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 70F)); + tableLayoutPanel.Controls.Add(labelNom, 0, 0); + tableLayoutPanel.Controls.Add(textBoxNom, 1, 0); + tableLayoutPanel.Controls.Add(labelPrenom, 0, 1); + tableLayoutPanel.Controls.Add(textBoxPrenom, 1, 1); + tableLayoutPanel.Controls.Add(labelTel, 0, 2); + tableLayoutPanel.Controls.Add(textBoxTel, 1, 2); + tableLayoutPanel.Controls.Add(labelMail, 0, 3); + tableLayoutPanel.Controls.Add(textBoxMail, 1, 3); + tableLayoutPanel.Controls.Add(labelService, 0, 4); + tableLayoutPanel.Controls.Add(comboBoxService, 1, 4); + tableLayoutPanel.Controls.Add(flowLayoutPanelButtons, 1, 5); + tableLayoutPanel.Location = new Point(120, 260); + tableLayoutPanel.Name = "tableLayoutPanel"; + tableLayoutPanel.RowCount = 6; + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 40F)); + tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, 50F)); + tableLayoutPanel.Size = new Size(560, 250); + tableLayoutPanel.TabIndex = 3; // // labelNom // - this.labelNom.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.labelNom.AutoSize = true; - this.labelNom.Font = new System.Drawing.Font("Segoe UI", 16F); - this.labelNom.Text = "Nom :"; + labelNom.Anchor = AnchorStyles.Right; + labelNom.AutoSize = true; + labelNom.Font = new Font("Segoe UI", 16F); + labelNom.Location = new Point(93, 5); + labelNom.Name = "labelNom"; + labelNom.Size = new Size(72, 30); + labelNom.TabIndex = 0; + labelNom.Text = "Nom :"; // // textBoxNom // - this.textBoxNom.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.textBoxNom.Width = 250; - this.textBoxNom.PlaceholderText = "Nom"; + textBoxNom.Anchor = AnchorStyles.Left; + textBoxNom.Location = new Point(171, 8); + textBoxNom.Name = "textBoxNom"; + textBoxNom.PlaceholderText = "Nom"; + textBoxNom.Size = new Size(250, 23); + textBoxNom.TabIndex = 1; // // labelPrenom // - this.labelPrenom.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.labelPrenom.AutoSize = true; - this.labelPrenom.Font = new System.Drawing.Font("Segoe UI", 16F); - this.labelPrenom.Text = "Prénom :"; + labelPrenom.Anchor = AnchorStyles.Right; + labelPrenom.AutoSize = true; + labelPrenom.Font = new Font("Segoe UI", 16F); + labelPrenom.Location = new Point(65, 45); + labelPrenom.Name = "labelPrenom"; + labelPrenom.Size = new Size(100, 30); + labelPrenom.TabIndex = 2; + labelPrenom.Text = "Prénom :"; // // textBoxPrenom // - this.textBoxPrenom.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.textBoxPrenom.Width = 250; - this.textBoxPrenom.PlaceholderText = "Prénom"; + textBoxPrenom.Anchor = AnchorStyles.Left; + textBoxPrenom.Location = new Point(171, 48); + textBoxPrenom.Name = "textBoxPrenom"; + textBoxPrenom.PlaceholderText = "Prénom"; + textBoxPrenom.Size = new Size(250, 23); + textBoxPrenom.TabIndex = 3; // // labelTel // - this.labelTel.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.labelTel.AutoSize = true; - this.labelTel.Font = new System.Drawing.Font("Segoe UI", 16F); - this.labelTel.Text = "Tél :"; + labelTel.Anchor = AnchorStyles.Right; + labelTel.AutoSize = true; + labelTel.Font = new Font("Segoe UI", 16F); + labelTel.Location = new Point(114, 85); + labelTel.Name = "labelTel"; + labelTel.Size = new Size(51, 30); + labelTel.TabIndex = 4; + labelTel.Text = "Tél :"; // // textBoxTel // - this.textBoxTel.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.textBoxTel.Width = 250; - this.textBoxTel.PlaceholderText = "Numéro de téléphone"; + textBoxTel.Anchor = AnchorStyles.Left; + textBoxTel.Location = new Point(171, 88); + textBoxTel.Name = "textBoxTel"; + textBoxTel.PlaceholderText = "Numéro de téléphone"; + textBoxTel.Size = new Size(250, 23); + textBoxTel.TabIndex = 5; // // labelMail // - this.labelMail.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.labelMail.AutoSize = true; - this.labelMail.Font = new System.Drawing.Font("Segoe UI", 16F); - this.labelMail.Text = "Mail :"; + labelMail.Anchor = AnchorStyles.Right; + labelMail.AutoSize = true; + labelMail.Font = new Font("Segoe UI", 16F); + labelMail.Location = new Point(100, 125); + labelMail.Name = "labelMail"; + labelMail.Size = new Size(65, 30); + labelMail.TabIndex = 6; + labelMail.Text = "Mail :"; // // textBoxMail // - this.textBoxMail.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.textBoxMail.Width = 250; - this.textBoxMail.PlaceholderText = "Adresse mail"; + textBoxMail.Anchor = AnchorStyles.Left; + textBoxMail.Location = new Point(171, 128); + textBoxMail.Name = "textBoxMail"; + textBoxMail.PlaceholderText = "Adresse mail"; + textBoxMail.Size = new Size(250, 23); + textBoxMail.TabIndex = 7; // // labelService // - this.labelService.Anchor = System.Windows.Forms.AnchorStyles.Right; - this.labelService.AutoSize = true; - this.labelService.Font = new System.Drawing.Font("Segoe UI", 16F); - this.labelService.Text = "Service :"; + labelService.Anchor = AnchorStyles.Right; + labelService.AutoSize = true; + labelService.Font = new Font("Segoe UI", 16F); + labelService.Location = new Point(71, 165); + labelService.Name = "labelService"; + labelService.Size = new Size(94, 30); + labelService.TabIndex = 8; + labelService.Text = "Service :"; // // comboBoxService // - this.comboBoxService.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.comboBoxService.Width = 250; - this.comboBoxService.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - // this.comboBoxService.PlaceholderText = "Service d'affectation"; // Supprimé car non supporté + comboBoxService.Anchor = AnchorStyles.Left; + comboBoxService.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxService.Location = new Point(171, 168); + comboBoxService.Name = "comboBoxService"; + comboBoxService.Size = new Size(250, 23); + comboBoxService.TabIndex = 9; // // flowLayoutPanelButtons // - this.flowLayoutPanelButtons.Anchor = System.Windows.Forms.AnchorStyles.Left; - this.flowLayoutPanelButtons.AutoSize = true; - this.flowLayoutPanelButtons.Controls.Add(this.buttonAjouter); - this.flowLayoutPanelButtons.Controls.Add(this.buttonAnnuler); + flowLayoutPanelButtons.Anchor = AnchorStyles.Left; + flowLayoutPanelButtons.AutoSize = true; + flowLayoutPanelButtons.Controls.Add(buttonAjouter); + flowLayoutPanelButtons.Controls.Add(buttonAnnuler); + flowLayoutPanelButtons.Location = new Point(171, 210); + flowLayoutPanelButtons.Name = "flowLayoutPanelButtons"; + flowLayoutPanelButtons.Size = new Size(212, 29); + flowLayoutPanelButtons.TabIndex = 10; // // buttonAjouter // - this.buttonAjouter.Text = "Ajouter"; - this.buttonAjouter.Width = 100; + buttonAjouter.Location = new Point(3, 3); + buttonAjouter.Name = "buttonAjouter"; + buttonAjouter.Size = new Size(100, 23); + buttonAjouter.TabIndex = 0; + buttonAjouter.Text = "Ajouter"; + buttonAjouter.Click += buttonAjouter_Click_1; // // buttonAnnuler // - this.buttonAnnuler.Text = "Annuler"; - this.buttonAnnuler.Width = 100; + buttonAnnuler.Location = new Point(109, 3); + buttonAnnuler.Name = "buttonAnnuler"; + buttonAnnuler.Size = new Size(100, 23); + buttonAnnuler.TabIndex = 1; + buttonAnnuler.Text = "Annuler"; + buttonAnnuler.Click += buttonAnnuler_Click_1; // // AddPersonnel // - this.ClientSize = new System.Drawing.Size(800, 600); - this.Controls.Add(this.pictureBoxTop); - this.Controls.Add(this.pictureBoxBottom); - this.Controls.Add(this.labelTitle); - this.Controls.Add(this.tableLayoutPanel); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "AddPersonnel"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTop)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBottom)).EndInit(); - this.tableLayoutPanel.ResumeLayout(false); - this.tableLayoutPanel.PerformLayout(); - this.flowLayoutPanelButtons.ResumeLayout(false); - this.ResumeLayout(false); + ClientSize = new Size(800, 600); + Controls.Add(pictureBoxTop); + Controls.Add(pictureBoxBottom); + Controls.Add(labelTitle); + Controls.Add(tableLayoutPanel); + FormBorderStyle = FormBorderStyle.FixedSingle; + MaximizeBox = false; + Name = "AddPersonnel"; + Load += AddPersonnel_Load; + ((System.ComponentModel.ISupportInitialize)pictureBoxTop).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBottom).EndInit(); + tableLayoutPanel.ResumeLayout(false); + tableLayoutPanel.PerformLayout(); + flowLayoutPanelButtons.ResumeLayout(false); + ResumeLayout(false); } #endregion diff --git a/projet/View/AddPersonnel.cs b/projet/View/AddPersonnel.cs index 91c6089..19e1819 100644 --- a/projet/View/AddPersonnel.cs +++ b/projet/View/AddPersonnel.cs @@ -1,4 +1,6 @@ -using System; +using projet.Controller; +using projet.modele; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -10,11 +12,100 @@ using System.Windows.Forms; namespace projet.View { + /// + /// Formulaire permettant l'ajout d'un nouveau membre du personnel. + /// Cette fenêtre gère la saisie et la validation des informations personnelles. + /// public partial class AddPersonnel : Form { + private addPersonnelController controller; + /// + /// Initialise une nouvelle instance du formulaire AddPersonnel. + /// Configure les composants de l'interface utilisateur et initialise les validations. + /// public AddPersonnel() { + Init(); InitializeComponent(); } + + private void Init() + { + controller = new addPersonnelController(); + } + + /// + /// Gère l'événement de clic sur le bouton Ajouter. + /// Valide les données saisies et ajoute le nouveau membre du personnel. + /// + /// L'objet qui a déclenché l'événement + /// Les arguments de l'événement + private void buttonAjouter_Click(object sender, EventArgs e) + { + // TODO: Implémenter la logique d'ajout + } + + /// + /// Gère l'événement de clic sur le bouton Annuler. + /// Ferme le formulaire sans sauvegarder les modifications. + /// + /// L'objet qui a déclenché l'événement + /// Les arguments de l'événement + private void buttonAnnuler_Click(object sender, EventArgs e) + { + // TODO: Implémenter la logique d'annulation + } + + private void buttonAnnuler_Click_1(object sender, EventArgs e) + { + Admin admin = new Admin(); + this.Hide(); + this.Close(); + admin.ShowDialog(); + } + + /// + /// Procédure d'événement pour le bouton Ajouter. + /// + /// + /// + private void buttonAjouter_Click_1(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxNom.Text) || string.IsNullOrEmpty(textBoxPrenom.Text) || string.IsNullOrEmpty(textBoxMail.Text) || string.IsNullOrEmpty(textBoxTel.Text) || comboBoxService.SelectedItem == null) + { + MessageBox.Show("Veuillez remplir tous les champs.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + else + { + Personnel personnel = new Personnel( + 0, // IdPersonnel + textBoxNom.Text, // Nom + textBoxPrenom.Text, // Prenom + textBoxTel.Text, // Tel + textBoxMail.Text, // Mail + comboBoxService.SelectedIndex+1 // IdService + ); + controller.addPersonnel(personnel); + this.Hide(); + this.Close(); + Admin admin = new Admin(); + admin.ShowDialog(); + } + } + + private void RemplirComboBoxService() + { + List services = controller.GetAllServices(); + foreach (Service service in services) + { + comboBoxService.Items.Add(service.Nom); + } + } + + private void AddPersonnel_Load(object sender, EventArgs e) + { + RemplirComboBoxService(); + } } } diff --git a/projet/View/AddPersonnel.resx b/projet/View/AddPersonnel.resx index 1af7de1..8b2ff64 100644 --- a/projet/View/AddPersonnel.resx +++ b/projet/View/AddPersonnel.resx @@ -1,17 +1,17 @@  - diff --git a/projet/View/Admin.Designer.cs b/projet/View/Admin.Designer.cs index 10b7e52..bcc6efa 100644 --- a/projet/View/Admin.Designer.cs +++ b/projet/View/Admin.Designer.cs @@ -40,128 +40,131 @@ /// private void InitializeComponent() { - this.pictureBoxTop = new System.Windows.Forms.PictureBox(); - this.pictureBoxBottom = new System.Windows.Forms.PictureBox(); - this.labelTitle = new System.Windows.Forms.Label(); - this.labelList = new System.Windows.Forms.Label(); - this.labelSeparator = new System.Windows.Forms.Label(); - this.comboBoxPersonnel = new System.Windows.Forms.ComboBox(); - this.buttonAdd = new System.Windows.Forms.Button(); - this.buttonDelete = new System.Windows.Forms.Button(); - this.buttonEdit = new System.Windows.Forms.Button(); - this.buttonAbsence = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTop)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBottom)).BeginInit(); - this.SuspendLayout(); + pictureBoxTop = new PictureBox(); + pictureBoxBottom = new PictureBox(); + labelTitle = new Label(); + labelList = new Label(); + labelSeparator = new Label(); + comboBoxPersonnel = new ComboBox(); + buttonAdd = new Button(); + buttonDelete = new Button(); + buttonEdit = new Button(); + buttonAbsence = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxTop).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBottom).BeginInit(); + SuspendLayout(); // // pictureBoxTop // - this.pictureBoxTop.BackColor = System.Drawing.Color.SteelBlue; - this.pictureBoxTop.Dock = System.Windows.Forms.DockStyle.Top; - this.pictureBoxTop.Location = new System.Drawing.Point(0, 0); - this.pictureBoxTop.Name = "pictureBoxTop"; - this.pictureBoxTop.Size = new System.Drawing.Size(800, 180); - this.pictureBoxTop.TabIndex = 0; - this.pictureBoxTop.TabStop = false; + pictureBoxTop.BackColor = Color.SteelBlue; + pictureBoxTop.Dock = DockStyle.Top; + pictureBoxTop.Location = new Point(0, 0); + pictureBoxTop.Name = "pictureBoxTop"; + pictureBoxTop.Size = new Size(800, 180); + pictureBoxTop.TabIndex = 0; + pictureBoxTop.TabStop = false; // // pictureBoxBottom // - this.pictureBoxBottom.BackColor = System.Drawing.Color.SteelBlue; - this.pictureBoxBottom.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pictureBoxBottom.Location = new System.Drawing.Point(0, 600 - 60); - this.pictureBoxBottom.Name = "pictureBoxBottom"; - this.pictureBoxBottom.Size = new System.Drawing.Size(800, 60); - this.pictureBoxBottom.TabIndex = 1; - this.pictureBoxBottom.TabStop = false; + pictureBoxBottom.BackColor = Color.SteelBlue; + pictureBoxBottom.Dock = DockStyle.Bottom; + pictureBoxBottom.Location = new Point(0, 540); + pictureBoxBottom.Name = "pictureBoxBottom"; + pictureBoxBottom.Size = new Size(800, 60); + pictureBoxBottom.TabIndex = 1; + pictureBoxBottom.TabStop = false; // // labelTitle // - this.labelTitle.Font = new System.Drawing.Font("Segoe UI", 28F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.labelTitle.Location = new System.Drawing.Point(0, 200); - this.labelTitle.Name = "labelTitle"; - this.labelTitle.Size = new System.Drawing.Size(800, 60); - this.labelTitle.TabIndex = 2; - this.labelTitle.Text = "Gérer le personnel"; - this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + labelTitle.Font = new Font("Segoe UI", 28F); + labelTitle.Location = new Point(0, 200); + labelTitle.Name = "labelTitle"; + labelTitle.Size = new Size(800, 60); + labelTitle.TabIndex = 2; + labelTitle.Text = "Gérer le personnel"; + labelTitle.TextAlign = ContentAlignment.MiddleCenter; // // labelList // - this.labelList.Font = new System.Drawing.Font("Segoe UI", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.labelList.Location = new System.Drawing.Point(0, 260); - this.labelList.Name = "labelList"; - this.labelList.Size = new System.Drawing.Size(800, 40); - this.labelList.TabIndex = 3; - this.labelList.Text = "Liste du personnel"; - this.labelList.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + labelList.Font = new Font("Segoe UI", 18F); + labelList.Location = new Point(0, 260); + labelList.Name = "labelList"; + labelList.Size = new Size(800, 40); + labelList.TabIndex = 3; + labelList.Text = "Liste du personnel"; + labelList.TextAlign = ContentAlignment.MiddleCenter; // // labelSeparator // - this.labelSeparator.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; - this.labelSeparator.Location = new System.Drawing.Point(300, 300); - this.labelSeparator.Name = "labelSeparator"; - this.labelSeparator.Size = new System.Drawing.Size(200, 2); - this.labelSeparator.TabIndex = 4; + labelSeparator.BorderStyle = BorderStyle.Fixed3D; + labelSeparator.Location = new Point(300, 300); + labelSeparator.Name = "labelSeparator"; + labelSeparator.Size = new Size(200, 2); + labelSeparator.TabIndex = 4; // // comboBoxPersonnel // - this.comboBoxPersonnel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBoxPersonnel.Font = new System.Drawing.Font("Segoe UI", 10F); - this.comboBoxPersonnel.Location = new System.Drawing.Point(300, 320); - this.comboBoxPersonnel.Name = "comboBoxPersonnel"; - this.comboBoxPersonnel.Size = new System.Drawing.Size(200, 25); - this.comboBoxPersonnel.TabIndex = 5; + comboBoxPersonnel.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxPersonnel.Font = new Font("Segoe UI", 10F); + comboBoxPersonnel.Location = new Point(300, 320); + comboBoxPersonnel.Name = "comboBoxPersonnel"; + comboBoxPersonnel.Size = new Size(200, 25); + comboBoxPersonnel.TabIndex = 5; // // buttonAdd // - this.buttonAdd.Location = new System.Drawing.Point(220, 370); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(150, 30); - this.buttonAdd.TabIndex = 6; - this.buttonAdd.Text = "Ajouter une personne"; - // - // buttonAbsence - // - this.buttonAbsence.Location = new System.Drawing.Point(430, 370); - this.buttonAbsence.Name = "buttonAbsence"; - this.buttonAbsence.Size = new System.Drawing.Size(150, 30); - this.buttonAbsence.TabIndex = 7; - this.buttonAbsence.Text = "Gérer ses absences"; + buttonAdd.Location = new Point(220, 370); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(150, 30); + buttonAdd.TabIndex = 6; + buttonAdd.Text = "Ajouter une personne"; + buttonAdd.Click += buttonAdd_Click; // // buttonDelete // - this.buttonDelete.Location = new System.Drawing.Point(220, 410); - this.buttonDelete.Name = "buttonDelete"; - this.buttonDelete.Size = new System.Drawing.Size(150, 30); - this.buttonDelete.TabIndex = 8; - this.buttonDelete.Text = "Supprimer la personne"; + buttonDelete.Location = new Point(220, 410); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(150, 30); + buttonDelete.TabIndex = 8; + buttonDelete.Text = "Supprimer la personne"; + buttonDelete.Click += buttonDelete_Click; // // buttonEdit // - this.buttonEdit.Location = new System.Drawing.Point(430, 410); - this.buttonEdit.Name = "buttonEdit"; - this.buttonEdit.Size = new System.Drawing.Size(150, 30); - this.buttonEdit.TabIndex = 9; - this.buttonEdit.Text = "Modifier personne"; + buttonEdit.Location = new Point(430, 410); + buttonEdit.Name = "buttonEdit"; + buttonEdit.Size = new Size(150, 30); + buttonEdit.TabIndex = 9; + buttonEdit.Text = "Modifier personne"; + // + // buttonAbsence + // + buttonAbsence.Location = new Point(430, 370); + buttonAbsence.Name = "buttonAbsence"; + buttonAbsence.Size = new Size(150, 30); + buttonAbsence.TabIndex = 7; + buttonAbsence.Text = "Gérer ses absences"; + buttonAbsence.Click += buttonAbsence_Click; // // Admin // - this.ClientSize = new System.Drawing.Size(800, 600); - this.Controls.Add(this.pictureBoxTop); - this.Controls.Add(this.pictureBoxBottom); - this.Controls.Add(this.labelTitle); - this.Controls.Add(this.labelList); - this.Controls.Add(this.labelSeparator); - this.Controls.Add(this.comboBoxPersonnel); - this.Controls.Add(this.buttonAdd); - this.Controls.Add(this.buttonAbsence); - this.Controls.Add(this.buttonDelete); - this.Controls.Add(this.buttonEdit); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "Admin"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTop)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBottom)).EndInit(); - this.ResumeLayout(false); + ClientSize = new Size(800, 600); + Controls.Add(pictureBoxTop); + Controls.Add(pictureBoxBottom); + Controls.Add(labelTitle); + Controls.Add(labelList); + Controls.Add(labelSeparator); + Controls.Add(comboBoxPersonnel); + Controls.Add(buttonAdd); + Controls.Add(buttonAbsence); + Controls.Add(buttonDelete); + Controls.Add(buttonEdit); + FormBorderStyle = FormBorderStyle.FixedSingle; + MaximizeBox = false; + Name = "Admin"; + ((System.ComponentModel.ISupportInitialize)pictureBoxTop).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBottom).EndInit(); + ResumeLayout(false); } #endregion diff --git a/projet/View/Admin.cs b/projet/View/Admin.cs index 2351c64..d3ef663 100644 --- a/projet/View/Admin.cs +++ b/projet/View/Admin.cs @@ -1,4 +1,6 @@ -using System; +using projet.Controller; +using projet.modele; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +14,65 @@ namespace projet.View { public partial class Admin : Form { + private AdminController controller; public Admin() { + Init(); InitializeComponent(); + RemplirComboBoxPersonnel(); + } + + public void Init() + { + controller = new AdminController(); + } + + private void RemplirComboBoxPersonnel() + { + List personnelList = controller.GetAllPersonnel(); + foreach (Personnel personnel in personnelList) + { + comboBoxPersonnel.Items.Add(personnel); + } + } + + private void buttonAdd_Click(object sender, EventArgs e) + { + this.Hide(); + this.Close(); + AddPersonnel addPersonnelForm = new AddPersonnel(); + addPersonnelForm.ShowDialog(); + } + + private void buttonAbsence_Click(object sender, EventArgs e) + { + if(comboBoxPersonnel.SelectedItem != null) + { + this.Hide(); + this.Close(); + GestionAbsence gestionAbsence = new GestionAbsence(); + gestionAbsence.ShowDialog(); + } + else + { + MessageBox.Show("Veuillez sélectionner un membre du personnel.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonDelete_Click(object sender, EventArgs e) + { + if(comboBoxPersonnel.SelectedItem != null) + { + Personnel personne = (Personnel)comboBoxPersonnel.SelectedItem; + this.Hide(); + this.Close(); + ConfirmeSupressionPersonnel confirmeSupressionPersonnel = new ConfirmeSupressionPersonnel(personne); + confirmeSupressionPersonnel.ShowDialog(); + } + else + { + MessageBox.Show("Veuillez sélectionner un membre du personnel.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } } } diff --git a/projet/View/Admin.resx b/projet/View/Admin.resx index 1af7de1..8b2ff64 100644 --- a/projet/View/Admin.resx +++ b/projet/View/Admin.resx @@ -1,17 +1,17 @@  - diff --git a/projet/View/ConfirmeSupressionPersonnel.Designer.cs b/projet/View/ConfirmeSupressionPersonnel.Designer.cs index dc75950..4573b34 100644 --- a/projet/View/ConfirmeSupressionPersonnel.Designer.cs +++ b/projet/View/ConfirmeSupressionPersonnel.Designer.cs @@ -34,84 +34,86 @@ /// private void InitializeComponent() { - this.pictureBoxTop = new System.Windows.Forms.PictureBox(); - this.pictureBoxBottom = new System.Windows.Forms.PictureBox(); - this.labelTitle = new System.Windows.Forms.Label(); - this.buttonAnnuler = new System.Windows.Forms.Button(); - this.buttonConfirmer = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTop)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBottom)).BeginInit(); - this.SuspendLayout(); + pictureBoxTop = new PictureBox(); + pictureBoxBottom = new PictureBox(); + labelTitle = new Label(); + buttonAnnuler = new Button(); + buttonConfirmer = new Button(); + ((System.ComponentModel.ISupportInitialize)pictureBoxTop).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBottom).BeginInit(); + SuspendLayout(); // // pictureBoxTop // - this.pictureBoxTop.BackColor = System.Drawing.Color.SteelBlue; - this.pictureBoxTop.Dock = System.Windows.Forms.DockStyle.Top; - this.pictureBoxTop.Location = new System.Drawing.Point(0, 0); - this.pictureBoxTop.Name = "pictureBoxTop"; - this.pictureBoxTop.Size = new System.Drawing.Size(800, 180); - this.pictureBoxTop.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.pictureBoxTop.TabIndex = 0; - this.pictureBoxTop.TabStop = false; + pictureBoxTop.BackColor = Color.SteelBlue; + pictureBoxTop.Dock = DockStyle.Top; + pictureBoxTop.Location = new Point(0, 0); + pictureBoxTop.Name = "pictureBoxTop"; + pictureBoxTop.Size = new Size(800, 180); + pictureBoxTop.SizeMode = PictureBoxSizeMode.StretchImage; + pictureBoxTop.TabIndex = 0; + pictureBoxTop.TabStop = false; // // pictureBoxBottom // - this.pictureBoxBottom.BackColor = System.Drawing.Color.SteelBlue; - this.pictureBoxBottom.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pictureBoxBottom.Location = new System.Drawing.Point(0, 520); - this.pictureBoxBottom.Name = "pictureBoxBottom"; - this.pictureBoxBottom.Size = new System.Drawing.Size(800, 140); - this.pictureBoxBottom.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; - this.pictureBoxBottom.TabIndex = 1; - this.pictureBoxBottom.TabStop = false; + pictureBoxBottom.BackColor = Color.SteelBlue; + pictureBoxBottom.Dock = DockStyle.Bottom; + pictureBoxBottom.Location = new Point(0, 520); + pictureBoxBottom.Name = "pictureBoxBottom"; + pictureBoxBottom.Size = new Size(800, 140); + pictureBoxBottom.SizeMode = PictureBoxSizeMode.StretchImage; + pictureBoxBottom.TabIndex = 1; + pictureBoxBottom.TabStop = false; // // labelTitle // - this.labelTitle.Font = new System.Drawing.Font("Segoe UI", 20F); - this.labelTitle.Location = new System.Drawing.Point(0, 180); - this.labelTitle.Name = "labelTitle"; - this.labelTitle.Size = new System.Drawing.Size(800, 50); - this.labelTitle.TabIndex = 2; - this.labelTitle.Text = "Voulez vous vraiment supprimer : PRÉNOM"; - this.labelTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + labelTitle.Font = new Font("Segoe UI", 20F); + labelTitle.Location = new Point(0, 180); + labelTitle.Name = "labelTitle"; + labelTitle.Size = new Size(800, 50); + labelTitle.TabIndex = 2; + labelTitle.Text = "Voulez vous vraiment supprimer : PRÉNOM"; + labelTitle.TextAlign = ContentAlignment.MiddleCenter; // // buttonAnnuler // - this.buttonAnnuler.Font = new System.Drawing.Font("Segoe UI", 10F); - this.buttonAnnuler.Location = new System.Drawing.Point(200, 260); - this.buttonAnnuler.Name = "buttonAnnuler"; - this.buttonAnnuler.Size = new System.Drawing.Size(100, 30); - this.buttonAnnuler.TabIndex = 3; - this.buttonAnnuler.Text = "Annuler"; - this.buttonAnnuler.UseVisualStyleBackColor = true; + buttonAnnuler.Font = new Font("Segoe UI", 10F); + buttonAnnuler.Location = new Point(200, 260); + buttonAnnuler.Name = "buttonAnnuler"; + buttonAnnuler.Size = new Size(100, 30); + buttonAnnuler.TabIndex = 3; + buttonAnnuler.Text = "Annuler"; + buttonAnnuler.UseVisualStyleBackColor = true; + buttonAnnuler.Click += buttonAnnuler_Click; // // buttonConfirmer // - this.buttonConfirmer.Font = new System.Drawing.Font("Segoe UI", 10F); - this.buttonConfirmer.Location = new System.Drawing.Point(500, 260); - this.buttonConfirmer.Name = "buttonConfirmer"; - this.buttonConfirmer.Size = new System.Drawing.Size(100, 30); - this.buttonConfirmer.TabIndex = 4; - this.buttonConfirmer.Text = "Confirmer"; - this.buttonConfirmer.UseVisualStyleBackColor = true; + buttonConfirmer.Font = new Font("Segoe UI", 10F); + buttonConfirmer.Location = new Point(500, 260); + buttonConfirmer.Name = "buttonConfirmer"; + buttonConfirmer.Size = new Size(100, 30); + buttonConfirmer.TabIndex = 4; + buttonConfirmer.Text = "Confirmer"; + buttonConfirmer.UseVisualStyleBackColor = true; + buttonConfirmer.Click += buttonConfirmer_Click; // // ConfirmeSupressionPersonnel // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 660); - this.Controls.Add(this.pictureBoxTop); - this.Controls.Add(this.pictureBoxBottom); - this.Controls.Add(this.labelTitle); - this.Controls.Add(this.buttonAnnuler); - this.Controls.Add(this.buttonConfirmer); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "ConfirmeSupressionPersonnel"; - this.Text = "Confirmation suppression"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxTop)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxBottom)).EndInit(); - this.ResumeLayout(false); + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 660); + Controls.Add(pictureBoxTop); + Controls.Add(pictureBoxBottom); + Controls.Add(labelTitle); + Controls.Add(buttonAnnuler); + Controls.Add(buttonConfirmer); + FormBorderStyle = FormBorderStyle.FixedSingle; + MaximizeBox = false; + Name = "ConfirmeSupressionPersonnel"; + Text = "Confirmation suppression"; + ((System.ComponentModel.ISupportInitialize)pictureBoxTop).EndInit(); + ((System.ComponentModel.ISupportInitialize)pictureBoxBottom).EndInit(); + ResumeLayout(false); } #endregion diff --git a/projet/View/ConfirmeSupressionPersonnel.cs b/projet/View/ConfirmeSupressionPersonnel.cs index a42e38f..7efd5fa 100644 --- a/projet/View/ConfirmeSupressionPersonnel.cs +++ b/projet/View/ConfirmeSupressionPersonnel.cs @@ -1,4 +1,6 @@ -using System; +using projet.Controller; +using projet.modele; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +14,36 @@ namespace projet.View { public partial class ConfirmeSupressionPersonnel : Form { - public ConfirmeSupressionPersonnel() + private ConfirmeSupressionPersonnelController controller; + private Personnel personne; + public ConfirmeSupressionPersonnel(Personnel personne) { + Init(); InitializeComponent(); + this.personne = personne; + labelTitle.Text = $"Voulez vous vraiment supprimer : {personne} ?"; + } + + public void Init() + { + controller = new ConfirmeSupressionPersonnelController(); + } + + private void buttonAnnuler_Click(object sender, EventArgs e) + { + this.Hide(); + this.Close(); + Admin admin = new Admin(); + admin.ShowDialog(); + } + + private void buttonConfirmer_Click(object sender, EventArgs e) + { + controller.deletePersonnel(personne); + this.Hide(); + this.Close(); + Admin admin = new Admin(); + admin.ShowDialog(); } } } diff --git a/projet/View/ConfirmeSupressionPersonnel.resx b/projet/View/ConfirmeSupressionPersonnel.resx index 1af7de1..8b2ff64 100644 --- a/projet/View/ConfirmeSupressionPersonnel.resx +++ b/projet/View/ConfirmeSupressionPersonnel.resx @@ -1,17 +1,17 @@  - diff --git a/projet/View/PageConnexion.Designer.cs b/projet/View/PageConnexion.Designer.cs index fc03af3..e4bfd58 100644 --- a/projet/View/PageConnexion.Designer.cs +++ b/projet/View/PageConnexion.Designer.cs @@ -88,7 +88,6 @@ textBoxLogin.Name = "textBoxLogin"; textBoxLogin.Size = new Size(200, 23); textBoxLogin.TabIndex = 3; - textBoxLogin.TextChanged += textBoxLogin_TextChanged; // // labelPassword // @@ -133,8 +132,9 @@ buttonLogin.Size = new Size(100, 23); buttonLogin.TabIndex = 8; buttonLogin.Text = "Se connecter"; + buttonLogin.Click += buttonLogin_Click; // - // Form1 + // PageConnexion // ClientSize = new Size(886, 600); Controls.Add(pictureBoxHeader); @@ -148,7 +148,7 @@ Controls.Add(buttonLogin); FormBorderStyle = FormBorderStyle.FixedSingle; MaximizeBox = false; - Name = "Form1"; + Name = "PageConnexion"; ((System.ComponentModel.ISupportInitialize)pictureBoxHeader).EndInit(); ResumeLayout(false); PerformLayout(); diff --git a/projet/View/PageConnexion.cs b/projet/View/PageConnexion.cs index 5192b86..6b840d2 100644 --- a/projet/View/PageConnexion.cs +++ b/projet/View/PageConnexion.cs @@ -1,4 +1,6 @@ -using System; +using projet.modele; +using projet.Controller; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,14 +14,52 @@ namespace projet.View { public partial class PageConnexion : Form { + private PageConnexionController controller; public PageConnexion() { + Init(); InitializeComponent(); } - private void textBoxLogin_TextChanged(object sender, EventArgs e) + /// + /// Initialisation du formulaire de connexion. + /// + private void Init() { + controller = new PageConnexionController(); + } + /// + /// Click sur le bouton se connecter + /// + /// + /// + private void buttonLogin_Click(object sender, EventArgs e) + { + if(string.IsNullOrEmpty(textBoxLogin.Text) || string.IsNullOrEmpty(textBoxPassword.Text)) + { + MessageBox.Show("Veuillez remplir tous les champs.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + else + { + // Connexion à faire tkt + Responsable responsable = new Responsable(textBoxLogin.Text, textBoxPassword.Text); + //MessageBox.Show("Identifiants : " + responsable.Login + " " + responsable.Pwd, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); + bool isConnected = controller.ConnecterResponsable(responsable); + + if (isConnected) + { + Admin adminPage = new Admin(); + this.Hide(); + adminPage.ShowDialog(); + this.Close(); + } + else + { + MessageBox.Show("Identifiants incorrects. Veuillez réessayer.", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } } } diff --git a/projet/bddmanager/BddManager.cs b/projet/bddmanager/BddManager.cs index 6d5cd67..cc14460 100644 --- a/projet/bddmanager/BddManager.cs +++ b/projet/bddmanager/BddManager.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; -namespace Habilitations.bddmanager +namespace projet.bddmanager { /// /// Singleton : connexion à la base de données et exécution des requêtes diff --git a/projet/dal/AbsenceAccess.cs b/projet/dal/AbsenceAccess.cs index 82d8973..5b6bd73 100644 --- a/projet/dal/AbsenceAccess.cs +++ b/projet/dal/AbsenceAccess.cs @@ -1,4 +1,4 @@ -namespace Habilitations.dal +namespace projet.dal { public class AbsenceAccess { diff --git a/projet/dal/Access.cs b/projet/dal/Access.cs new file mode 100644 index 0000000..a273af0 --- /dev/null +++ b/projet/dal/Access.cs @@ -0,0 +1,37 @@ +using projet.bddmanager; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace projet.dal +{ + public class Access + { + private static readonly string connectionString = "server=localhost;user id=root;password=;database=mediatek;"; + private static Access instance = null; + + public BddManager Manager { get; } + + private Access() + { + try + { + Manager = BddManager.GetInstance(connectionString); + } + catch (Exception) + { + Environment.Exit(0); + } + } + public static Access GetInstance() + { + if (instance == null) + { + instance = new Access(); + } + return instance; + } + } +} diff --git a/projet/dal/MotifAccess.cs b/projet/dal/MotifAccess.cs index 0d9d831..15f2601 100644 --- a/projet/dal/MotifAccess.cs +++ b/projet/dal/MotifAccess.cs @@ -1,4 +1,4 @@ -namespace Habilitations.dal +namespace projet.dal { public class MotifAccess { diff --git a/projet/dal/PersonnelAccess.cs b/projet/dal/PersonnelAccess.cs index eb6f1d8..087703a 100644 --- a/projet/dal/PersonnelAccess.cs +++ b/projet/dal/PersonnelAccess.cs @@ -1,12 +1,93 @@ -namespace Habilitations.dal +using projet.modele; + +namespace projet.dal { public class PersonnelAccess { - private static readonly string connectionString = "server=localhost;user id=root;password=;database=mediatek;"; + private readonly Access access; - public static string GetConnexion() + public PersonnelAccess() { - return connectionString; + access = Access.GetInstance(); + } + + public List GetAllPersonnel() + { + List personnelList = new List(); + if (access.Manager != null) + { + string req = "SELECT * FROM personnel ORDER BY nom, prenom;"; + try + { + List resultats = access.Manager.ReqSelect(req); + if (resultats != null) + { + foreach (Object[] resultat in resultats) + { + Personnel personnel = new Personnel( + Convert.ToInt32(resultat[0]), // IdPersonnel + Convert.ToString(resultat[1]), // Nom + Convert.ToString(resultat[2]), // Prenom + Convert.ToString(resultat[3]), // Tel + Convert.ToString(resultat[4]), // Mail + Convert.ToInt32(resultat[5]) // IdService + ); + personnelList.Add(personnel); + } + } + } + catch (Exception) + { + Console.WriteLine("Erreur lors de la récupération des données du personnel."); + Environment.Exit(0); + } + } + return personnelList; + } + public void addPersonnel(Personnel personne) + { + if (access.Manager != null) + { + string req = "INSERT INTO personnel (nom, prenom, tel, mail, idService) VALUES (@nom, @prenom, @tel, @mail, @idService);"; + var parameters = new Dictionary + { + { "@nom", personne.Nom }, + { "@prenom", personne.Prenom }, + { "@tel", personne.Tel }, + { "@mail", personne.Mail }, + { "@idService", personne.IdService } + }; + try + { + access.Manager.ReqUpdate(req, parameters); + } + catch (Exception) + { + Console.WriteLine("Erreur lors de l'ajout du personnel dans la base de données."); + Environment.Exit(0); + } + } + } + + public void deletePersonnel(Personnel personnel) + { + if (access.Manager != null) + { + string req = "DELETE FROM personnel WHERE idPersonnel = @idPersonnel;"; + var parameters = new Dictionary + { + { "@idPersonnel", personnel.IdPersonnel } + }; + try + { + access.Manager.ReqUpdate(req, parameters); + } + catch (Exception) + { + Console.WriteLine("Erreur lors de la suppression du personnel dans la base de données."); + Environment.Exit(0); + } + } } } } diff --git a/projet/dal/ResponsableAccess.cs b/projet/dal/ResponsableAccess.cs index bb4faf7..ad0a6c9 100644 --- a/projet/dal/ResponsableAccess.cs +++ b/projet/dal/ResponsableAccess.cs @@ -1,12 +1,42 @@ -namespace Habilitations.dal +using projet.modele; + +namespace projet.dal { public class ResponsableAccess { - private static readonly string connectionString = "server=localhost;user id=root;password=;database=mediatek;"; + private readonly Access access; - public static string GetConnexion() + public ResponsableAccess() { - return connectionString; + access = Access.GetInstance(); + } + + public bool ConnecterResponsable(Responsable responsable) + { + if(access.Manager != null) + { + string req = "SELECT * FROM responsable WHERE login = @login AND pwd = SHA2(@pwd, 256);"; + var parameters = new Dictionary + { + { "@login", responsable.Login }, + { "@pwd", responsable.Pwd } + }; + try + { + List result = access.Manager.ReqSelect(req, parameters); + if(result != null) + { + return (result.Count > 0); + } + } + catch (Exception) + { + Console.WriteLine("Erreur lors de la connexion à la base de données."); + Environment.Exit(0); + } + return false; + } + return false; } } } diff --git a/projet/dal/ServiceAccess.cs b/projet/dal/ServiceAccess.cs index 59d3d72..1cf5d6b 100644 --- a/projet/dal/ServiceAccess.cs +++ b/projet/dal/ServiceAccess.cs @@ -1,12 +1,43 @@ -namespace Habilitations.dal +using projet.modele; +namespace projet.dal { public class ServiceAccess { - private static readonly string connectionString = "server=localhost;user id=root;password=;database=mediatek;"; + private readonly Access access; - public static string GetConnexion() + public ServiceAccess() { - return connectionString; + access = Access.GetInstance(); + } + + public List GetAllServices() + { + List serviceList = new List(); + if (access.Manager != null) + { + string req = "SELECT * FROM service ORDER BY nom;"; + try + { + List resultats = access.Manager.ReqSelect(req); + if (resultats != null) + { + foreach (Object[] resultat in resultats) + { + Service service = new Service( + Convert.ToInt32(resultat[0]), // IdService + Convert.ToString(resultat[1]) // Nom + ); + serviceList.Add(service); + } + } + } + catch (Exception) + { + Console.WriteLine("Erreur lors de la récupération des données des services."); + Environment.Exit(0); + } + } + return serviceList; } } } diff --git a/projet/modele/Absence.cs b/projet/modele/Absence.cs index 20ee12b..a608e41 100644 --- a/projet/modele/Absence.cs +++ b/projet/modele/Absence.cs @@ -1,6 +1,6 @@ using System; -namespace Habilitations.modele +namespace projet.modele { /// /// Représente une absence d'un personnel. diff --git a/projet/modele/Motif.cs b/projet/modele/Motif.cs index bd90ec7..d587af3 100644 --- a/projet/modele/Motif.cs +++ b/projet/modele/Motif.cs @@ -1,4 +1,4 @@ -namespace Habilitations.modele +namespace projet.modele { /// /// Représente un motif d'absence diff --git a/projet/modele/Personnel.cs b/projet/modele/Personnel.cs index 72585e4..4b4c869 100644 --- a/projet/modele/Personnel.cs +++ b/projet/modele/Personnel.cs @@ -1,4 +1,4 @@ -namespace Habilitations.modele +namespace projet.modele { /// /// Représente un membre du personnel @@ -35,5 +35,10 @@ Mail = mail; IdService = idService; } + + public override string ToString() + { + return $"{this.Nom} {this.Prenom}"; + } } } diff --git a/projet/modele/Responsable.cs b/projet/modele/Responsable.cs index 69b35a4..7ac6739 100644 --- a/projet/modele/Responsable.cs +++ b/projet/modele/Responsable.cs @@ -1,4 +1,4 @@ -namespace Habilitations.modele +namespace projet.modele { /// /// Représente un responsable (admin) diff --git a/projet/projet.csproj b/projet/projet.csproj index c412b33..a10a059 100644 --- a/projet/projet.csproj +++ b/projet/projet.csproj @@ -10,10 +10,6 @@ True - - - -