<file_sep>﻿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 Admin4You
{
    public partial class RestBookingPerDate : Form
    {
        private Models.RestaurantModel restToUse;

        public void SetRestToUse(Models.RestaurantModel rest)
        {
            restToUse = rest;
        }

        static private RestBookingPerDate _instance;
        static public RestBookingPerDate getInstance()
        {
            if (_instance == null)
                _instance = new RestBookingPerDate();
            return _instance;
        }
    
        public RestBookingPerDate()
        {
            InitializeComponent();
        }

        private void RestBookingPerDate_VisibleChanged(object sender, EventArgs e)
        {
            label_show_id.Text = restToUse.id.ToString();
        }

        private void RestBookingPerDate_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            dataGridView_ShowBookings.DataSource = BusinessLayer.RestBL.GetBookingByRestIDandDate(restToUse.id, dateTimePicker_ShowBooking.Value.Date);
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
using System.Data;

namespace BusinessLayer
{
    public class RestBL
    {
        public static RestaurantModel GetRestaurantByIDBL(int idRestToUse)
        {
            return DataAcessLayer.RestDAL.GetRestByIdDAL(idRestToUse);
        }

        public static DataView GetTableByRestIDandDate(int pRestID, DateTime pDate)
        {
            return DataAcessLayer.RestDAL.GetTablesByRestIDandDateDAL(pRestID, pDate);
        }

        public static DataView GetBookingByRestIDandDate(int pRestID, DateTime pDate)
        {
            return DataAcessLayer.RestDAL.GetBookingByRestIDandDateDAL(pRestID, pDate);
        }

        public static DataView GetMealByRestIDBL(int pRestID)
        {
            return DataAcessLayer.RestDAL.GetMealsByRestIDDAL(pRestID);
        }

        public static DataView GetRefMealByGroupIDBL(int pGroupID)
        {
            return DataAcessLayer.RestDAL.GetRefMByGroupIDDAL(pGroupID);
        }

        public static void InsertOrUpdateNewAvailableDishBL(int pREFM_ID, int pREST_ID, int pMEALREST_Price)
        {
            DataAcessLayer.RestDAL.InsertOrUpdateNewAvailableDishDAL(pREFM_ID, pREST_ID, pMEALREST_Price);
        }


        static public DataTable GetMealsByRestIDandTypeBL(int pRestID, int pTypeID)
        {
            return DataAcessLayer.RestDAL.GetMealsByRestIDandTypeDAL(pRestID, pTypeID);
        }

        public static DataView GetComboByRestIDBL(int pRestID)
        {
            return DataAcessLayer.RestDAL.GetComboByRestIDDAL(pRestID);
        }

        public static void InsertOrUpdateComboBL(int pRestID, int pStarterID, int pMainCourseID, int pDessertID, string pName)
        {
            //Pour déterminer le prix du combo qui doit être égal au MSRP des produits - 10% arrondi à l'unité inférieur, on appelle la DAL pour qu'elle nous fournisse ces prix.
            DataView oDataView = DataAcessLayer.FunctionTestDAL.GetPriceWithREFMDAL(pStarterID, pMainCourseID, pDessertID);
            DataRowView oRow = (DataRowView)oDataView[0];
            int pPrice = (Convert.ToInt32(oRow.Row[0]) + Convert.ToInt32(oRow.Row[1]) + Convert.ToInt32(oRow.Row[2])); // le prix du combo est celui de la somme de ses msrp avec la réduction de la ligne suivante
            pPrice = pPrice - (int)Math.Ceiling(pPrice/10.0); // Utilisation de la fonction Math.Ceiling pour obtenir un arrondi inférieur qui est casté en int afin de pouvoir le soustraire au prix et obtenir la réduction.

            DataAcessLayer.FunctionTestDAL.InsertOrUpdateComboDAL(pRestID, pStarterID, pMainCourseID, pDessertID, pPrice, pName);
        }
    }


}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAcessLayer
{
    public static class GroupDAL
    {
        //Permet de récupérer un Group en utilisant seulement son ID
        public static Models.GroupModel GetGroupByIdDAL(int pId)
        {
            Models.GroupModel groupToReturn = new Models.GroupModel();

            try
            {
                using (SqlConnection oConnect = new SqlConnection(Utils._connectionString))
                {
                    SqlCommand oComm = new SqlCommand();
                    SqlParameter oParam = new SqlParameter("@GrId", pId);
                    oComm.Parameters.Add(oParam);
                    oComm.Connection = oConnect;
                    oComm.CommandType = System.Data.CommandType.StoredProcedure;
                    oComm.CommandText = "SelectGroupById";
                    oConnect.Open();
                    SqlDataReader reader = oComm.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            groupToReturn.id = reader.GetInt32(0);
                            groupToReturn.Name = reader.GetString(1);
                        }
                        //Console.WriteLine("Connection successfull and reader has rows."); //Debug
                    }
                    
                    else groupToReturn = null;
                    oConnect.Close();
                }
            }
            catch { }

            return groupToReturn;
        }

        static public DataView GetPrices(DateTime date, int RestId)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("SelectPreoIDByRestAndDate", oConn);
                    SqlParameter oParam1 = new SqlParameter("@Date", date.Date);
                    SqlParameter oParam2 = new SqlParameter("@RestId", RestId);
                    oComm.Parameters.Add(oParam1);
                    oComm.Parameters.Add(oParam2);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("Preo");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "Preo");
                    //Console.WriteLine("DataSet OK !");
                    oConn.Close();
                    return oDataSet.Tables["Preo"].DefaultView;
                }
                catch { return null; }
                finally { }
            }
        }

        static public DataView GetRestaurantsByGroupId(int pGrId)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("SelectRestByGroupId", oConn);
                    SqlParameter oParam2 = new SqlParameter("@GrId", pGrId);
                    oComm.Parameters.Add(oParam2);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("RESTAURANTS");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "RESTAURANTS");
                    Console.WriteLine("DataSet OK !");
                    oConn.Close();
                    return oDataSet.Tables["RESTAURANTS"].DefaultView;
                }
                catch { return null; }
                finally { }
            }
        }
        static public int GetComboPriceDAL(int pComboId)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                int priceToReturn = -1;
                try
                {
                    SqlCommand oComm = new SqlCommand("GetComboPriceByID", oConn);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlParameter oParam1 = new SqlParameter("@ComboId", pComboId);
                    oComm.Parameters.Add(oParam1);
                    oConn.Open();
                    SqlDataReader reader = oComm.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            priceToReturn = reader.GetInt32(0);
                        }
                        Console.WriteLine("Connection successfull and reader has rows."); //Debug
                    }
                    oConn.Close();

                }
                catch { }
                return priceToReturn;
            }

        }
    }
}


<file_sep>﻿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 Admin4You
{
    public partial class RestTablePerDate : Form
    {
        private Models.RestaurantModel restToUse;
        public void SetRestToUse(Models.RestaurantModel rest)
        {
            restToUse = rest;
        }

        static private RestTablePerDate _instance;
        static public RestTablePerDate getInstance()
        {
            if (_instance == null)
                _instance = new RestTablePerDate();
            return _instance;
        }
        public RestTablePerDate()
        {
            InitializeComponent();
        }

        private void RestTablePerDate_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            dataGridView_ShowTable.DataSource = BusinessLayer.RestBL.GetTableByRestIDandDate(restToUse.id, dateTimePicker_ShowTable.Value.Date);
        }


        private void RestTablePerDate_VisibleChanged(object sender, EventArgs e)
        {
            label_show_id.Text = restToUse.id.ToString();
        }
    }
}
<file_sep>﻿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 Admin4You
{
    public partial class RestComboMaker : Form
    {
        //Implémentation du principe de singleton. On n'instancie pas quand on utilise mais on fais le getInstance(),
        // cela permet de n'avoir qu'une seule instance de la fenêtre à la fois.
        static private RestComboMaker _instance;

        static public RestComboMaker getInstance()
        {
            if (_instance == null)
                _instance = new RestComboMaker();
            return _instance;
        }

        //Mise en place d'un objet Restaurant model propre à la form. sera attribué lors de l'appel à l'affichage. Détermine quel restaurant est administré ici.
        private Models.RestaurantModel restToAdmin;
        public void SetRestToAdmin(Models.RestaurantModel rest) { restToAdmin = rest; }


        public RestComboMaker()
        {
            InitializeComponent();
        }



        //Application du principe de singleton, on ne détruit plus la form mais on la cache.
        private void RestComboMaker_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            comboBox_Starter.Update();
            this.Hide();
        }


        //Mise à jour des infos à chaque affichage, application du principe de singleton.
        private void RestComboMaker_VisibleChanged(object sender, EventArgs e)
        {
            label_show_RestID.Text = restToAdmin.id.ToString();

            dataGridView_ShowCombo.DataSource = BusinessLayer.RestBL.GetComboByRestIDBL(restToAdmin.id);

            comboBox_Starter.DataSource = BusinessLayer.RestBL.GetMealsByRestIDandTypeBL(restToAdmin.id, 1); //Attente de l'implémentation de la BL -> DAL -> SP
            comboBox_MainCourse.DataSource = BusinessLayer.RestBL.GetMealsByRestIDandTypeBL(restToAdmin.id, 2);
            comboBox_Dessert.DataSource = BusinessLayer.RestBL.GetMealsByRestIDandTypeBL(restToAdmin.id, 3);
            comboBox_Starter.DisplayMember = "Nom du plat"; comboBox_Starter.ValueMember = "REFM_Name";
            comboBox_MainCourse.DisplayMember = "Nom du plat"; comboBox_MainCourse.ValueMember = "REFM_Name";
            comboBox_Dessert.DisplayMember = "Nom du plat"; comboBox_Dessert.ValueMember = "REFM_Name";

        }

        private void bt_Add_Click(object sender, EventArgs e)
        {
            int pRestId = restToAdmin.id;
            int pStarterID = (int)((DataRowView)comboBox_Starter.SelectedItem).Row[0];
            int pMainCourseID = (int)((DataRowView)comboBox_MainCourse.SelectedItem).Row[0];
            int pDessertID = (int)((DataRowView)comboBox_Dessert.SelectedItem).Row[0];
            BusinessLayer.RestBL.InsertOrUpdateComboBL(pRestId, pStarterID, pMainCourseID, pDessertID, textBox_ComboName.Text);

            dataGridView_ShowCombo.DataSource = BusinessLayer.RestBL.GetComboByRestIDBL(restToAdmin.id);

        }
    }
}
<file_sep>﻿using Models;
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;


/* ATTENTION A LA GESTION D'ERREUR
 * -> N'est pas traité : entré d'un id de groupe qui ne corresponds pas !
 */

namespace Admin4You
{
    public partial class GroupAdmin : Form
    {
        private GroupModel groupToAdmin;
        private static GroupAdmin _instance;

        //Implémentation du principe de singleton. On n'instancie pas quand on utilise mais on fais le getInstance(),
        // cela permet de n'avoir qu'une seule instance de la fenêtre à la fois.

        public static GroupAdmin getGrAdmin()
        {
            if (_instance == null)
                _instance = new GroupAdmin();

            return _instance;
        }

        public void setGrouptoAdmin(GroupModel grToAdmin)
        {
            groupToAdmin = grToAdmin;
        }

        public GroupAdmin()
        {
            InitializeComponent();
        }

        private void GroupAdmin_FormClosing(object sender, FormClosingEventArgs e)
        {//Application du principe de singleton, on ne détruit plus la form mais on la cache.
            e.Cancel = true;
            this.Hide();
        }



        private void voirLeChiffreDuRestaurantÀUneDateDonnéeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int restaurantSelected = Convert.ToInt32(dataGridView_restaurant.SelectedCells[0].Value);
            label_show_MoneyMade.Text = BusinessLayer.GroupBL.GetPreoPriceBL(dtp_dayToWatch.Value.Date, restaurantSelected).ToString();
        }

        //Vu le principe de singleton, ceci permet qu'à chaque fois que la form est ouverte, on affiche des données mises à jour.
        private void GroupAdmin_VisibleChanged(object sender, EventArgs e)
        {
            dataGridView_restaurant.DataSource = BusinessLayer.GroupBL.GetRestByGroupIDBL(groupToAdmin.id);
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAcessLayer
{
    public class RestDAL
    {

        public static Models.RestaurantModel GetRestByIdDAL(int pId)
        {
            Models.RestaurantModel restToReturn = new Models.RestaurantModel();
            try
            {
                using (SqlConnection oConnect = new SqlConnection(Utils._connectionString))
                {
                    SqlCommand oComm = new SqlCommand();
                    SqlParameter oParam = new SqlParameter("@RestID", pId);
                    oComm.Parameters.Add(oParam);
                    oComm.Connection = oConnect;
                    oComm.CommandType = System.Data.CommandType.StoredProcedure;
                    oComm.CommandText = "GetRestByID";
                    oConnect.Open();
                    SqlDataReader reader = oComm.ExecuteReader();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            restToReturn.id = reader.GetInt32(0);
                            restToReturn.grId = reader.GetInt32(1);
                            restToReturn.place = reader.GetInt32(2);
                            restToReturn.name = reader.GetString(3);

                        }
                        Console.WriteLine("Connection successfull and reader has rows."); //Debug
                    }

                    else restToReturn = null;
                    oConnect.Close();
                }
            }
            catch { }

            return restToReturn;
        }

        static public DataView GetTablesByRestIDandDateDAL(int pRestID, DateTime pDate)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("GetTableByDateAndRestID", oConn);
                    SqlParameter oParam1 = new SqlParameter("@RestID", pRestID);
                    SqlParameter oParam2 = new SqlParameter("@Date", pDate);
                    oComm.Parameters.Add(oParam1);
                    oComm.Parameters.Add(oParam2);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("TableByRestIDandDate");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "TableByRestIDandDate");
                    Console.WriteLine("DataSet tables OK !");
                    oConn.Close();
                    return oDataSet.Tables["TableByRestIDandDate"].DefaultView;
                }
                catch { return null; }
                finally { }
            }
        }
        static public DataView GetBookingByRestIDandDateDAL(int pRestID, DateTime pDate)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("GetBookingByRestIDandDate", oConn);
                    SqlParameter oParam1 = new SqlParameter("@RestID", pRestID);
                    SqlParameter oParam2 = new SqlParameter("@Date", pDate);
                    oComm.Parameters.Add(oParam1);
                    oComm.Parameters.Add(oParam2);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("BookByRestIDandDate");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "BookByRestIDandDate");
                    Console.WriteLine("DataSet book OK !");
                    oConn.Close();
                    return oDataSet.Tables["BookByRestIDandDate"].DefaultView;
                }
                catch { return null; }
                finally { }
            }
        }

        static public DataView GetMealsByRestIDDAL(int pRestID)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("GetAllMealRestByRestID", oConn);
                    SqlParameter oParam1 = new SqlParameter("@RestID", pRestID);
                    oComm.Parameters.Add(oParam1);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("MealByRestID");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "MealByRestID");
                    Console.WriteLine("DataSet meals OK !"); // DEBUG
                    oConn.Close();
                    return oDataSet.Tables["MealByRestID"].DefaultView;
                }
                catch { return null; }
                finally { }

            }
        }

        static public DataView GetRefMByGroupIDDAL(int pGroupID)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("GetREFMavailablebyGroupID", oConn);
                    SqlParameter oParam1 = new SqlParameter("@GroupID", pGroupID);
                    oComm.Parameters.Add(oParam1);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("RefMealByGroupID");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "RefMealByGroupID");
                    Console.WriteLine("DataSet refmeals OK !"); // DEBUG
                    oConn.Close();
                    return oDataSet.Tables["RefMealByGroupID"].DefaultView;
                }
                catch { return null; }
                finally { }

            }
        }

        public static DataView GetComboByRestIDDAL(int pRestID)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("GetComboByRestID", oConn);
                    SqlParameter oParam1 = new SqlParameter("@RestID", pRestID);
                    oComm.Parameters.Add(oParam1);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("ComboByRestID");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "ComboByRestID");
                    Console.WriteLine("DataSet combo OK !"); // DEBUG
                    oConn.Close();
                    return oDataSet.Tables["ComboByRestID"].DefaultView;
                }
                catch { return null; }
                finally { }

            }
        }

        static public void InsertOrUpdateNewAvailableDishDAL(int pREFM_ID, int pREST_ID, int pMEALREST_Price)
        {// ATTENTION ! UN SCOPE DOIT ÊTRE PLACÉ ICI !!!!!
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    //Mise en place de la commande SP
                    SqlCommand oComm = new SqlCommand("InsertOrUpdateNewAvailableDish", oConn);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlParameter oParam1 = new SqlParameter("@REFM_ID", pREFM_ID);
                    SqlParameter oParam2 = new SqlParameter("@REST_ID", pREST_ID);
                    SqlParameter oParam3 = new SqlParameter("@MEALREST_Price", pMEALREST_Price);
                    oComm.Parameters.Add(oParam1);
                    oComm.Parameters.Add(oParam2);
                    oComm.Parameters.Add(oParam3);

                    oConn.Open();
                    oComm.ExecuteNonQuery();
                    oConn.Close();
                }
                catch { }
                finally { }
            }

        }

        static public DataTable GetMealsByRestIDandTypeDAL(int pRestID, int pTypeID)
        {
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    SqlCommand oComm = new SqlCommand("GetMealsByRestIDandType", oConn);
                    SqlParameter oParam1 = new SqlParameter("@RestID", pRestID);
                    SqlParameter oParam2 = new SqlParameter("@TypeID", pTypeID);
                    oComm.Parameters.Add(oParam1);
                    oComm.Parameters.Add(oParam2);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlDataAdapter oDataAdapter = new SqlDataAdapter(oComm);
                    DataSet oDataSet = new DataSet("MealsByRestIDandType");
                    oConn.Open();
                    oDataAdapter.Fill(oDataSet, "MealsByRestIDandType");
                    Console.WriteLine("DataSet refmeals OK !"); // DEBUG
                    oConn.Close();
                    return oDataSet.Tables["MealsByRestIDandType"];
                }
                catch { return null; }
                finally { }

            }
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataAcessLayer;

namespace BusinessLayer
{
    public static class GroupBL
    {
        public static Models.GroupModel GetGroupByIdBL(int pId)
        {
            return DataAcessLayer.GroupDAL.GetGroupByIdDAL(pId);
        }

        public static int GetPreoPriceBL(DateTime date, int RestId)
        {
            DataView oDataView = DataAcessLayer.GroupDAL.GetPrices(date, RestId);
            int Money = 0;
            foreach (DataRowView oRow in oDataView)
            {
               int comboId = 0;
                if (int.TryParse(oRow[1].ToString(), out comboId))
                    DataAcessLayer.GroupDAL.GetComboPriceDAL(comboId);
                else
                    Money += Convert.ToInt32(oRow["Total"]);
            }

            return Money;
        }
        public static DataView GetRestByGroupIDBL(int pGrId)
        {
            return DataAcessLayer.GroupDAL.GetRestaurantsByGroupId(pGrId);
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAcessLayer
{
    public class FunctionTestDAL
    {
        static public void InsertOrUpdateComboDAL(int pRestID, int pStarterID, int pMainCourseID, int pDessertID, int pPrice, string pName)
        {// ATTENTION ! UN SCOPE DOIT ÊTRE PLACÉ ICI !!!!!
            using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
            {
                try
                {
                    //Mise en place de la commande SP
                    SqlCommand oComm = new SqlCommand("InsertOrUpdateCombo ", oConn);
                    oComm.CommandType = CommandType.StoredProcedure;
                    SqlParameter oParam1 = new SqlParameter("REFM_ID_Starter", pStarterID);
                    SqlParameter oParam2 = new SqlParameter("REFM_ID_MainCourse", pMainCourseID);
                    SqlParameter oParam3 = new SqlParameter("REFM_ID_Dessert", pDessertID);
                    SqlParameter oParam4 = new SqlParameter("@COMBO_Price", pPrice);
                    SqlParameter oParam5 = new SqlParameter("@COMBO_REST_ID", pRestID);
                    SqlParameter oParam6 = new SqlParameter("@COMBO_Name", pName);
                    oComm.Parameters.Add(oParam1);
                    oComm.Parameters.Add(oParam2);
                    oComm.Parameters.Add(oParam3);
                    oComm.Parameters.Add(oParam4);
                    oComm.Parameters.Add(oParam5);
                    oComm.Parameters.Add(oParam6);

                    //Execution de la SP
                    oConn.Open();
                    oComm.ExecuteNonQuery();
                    oConn.Close();
                }
                catch {}
                finally { }
            }
        }
        static public DataView GetPriceWithREFMDAL(int pStarterID, int pMainCourseID, int pDessertID)
        {
            try
            {
                using (SqlConnection oConn = new SqlConnection(Utils._connectionString))
                {
                    SqlCommand oComm = new SqlCommand("GetREFM_MSRPbyREFMID", oConn);
                    SqlParameter oParam1 = new SqlParameter("@REFM_Starter_ID", pStarterID);
                    SqlParameter oParam2 = new SqlParameter("@REFM_MainCourse_ID", pMainCourseID);
                    SqlParameter oParam3 = new SqlParameter("@REFM_Dessert_ID", pDessertID);
                    oComm.Parameters.Add(oParam1);
                    oComm.Parameters.Add(oParam2);
                    oComm.Parameters.Add(oParam3);
                    oComm.CommandType = CommandType.StoredProcedure;

                    DataSet oDataSet = new DataSet("MSRP");
                    SqlDataAdapter oAdapter = new SqlDataAdapter(oComm);
                    oConn.Open();
                    oAdapter.Fill(oDataSet,"MSRP");
                    oConn.Close();
                    return oDataSet.Tables["MSRP"].DefaultView;
                }
            }
            catch { return null; }
            finally { }
        }
    }
}
    

<file_sep>﻿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;
using BusinessLayer;

namespace Admin4You
{
    public partial class RestID : Form
    {
        //Implémentation du principe de singleton. On n'instancie pas quand on utilise mais on fais le getInstance(),
        // cela permet de n'avoir qu'une seule instance de la fenêtre à la fois.
        static private RestID _instance;

        static public RestID GetInstance()
        {
            if (_instance == null)
                _instance = new RestID();
            return _instance;
        }

        //Permet de savoir ce qui va être fait ensuite. Set dans la form appellante.
        private int whatToDoNext;
        public void SetWhatToDoNext(int wtdn) { whatToDoNext = wtdn; }



        public RestID()
        {
            InitializeComponent();
        }

        //Application du principe de singleton, on ne détruit plus la form mais on la cache.
        private void btCancel_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            int idRestToUse;
            if(int.TryParse(txtRestId.Text, out idRestToUse))//Rentre dans le if si on arrive à extraire la valeur du TextBox.
            {
                Models.RestaurantModel restToAdmin = BusinessLayer.RestBL.GetRestaurantByIDBL(idRestToUse);

                if (restToAdmin == null) // Dans le cas ou on ne récupère pas un ID de restau valide, on envoie un messagebox qui clear la textbox et qui averti l'utilisateur du problème.
                {
                    MessageBox.Show("L'id que vous avez rentré ne corresponds pas.", "ERREUR", MessageBoxButtons.OK);
                    txtRestId.Text = "";
                }
                else // Si on a bien récupéré un restau
                {
                    switch (whatToDoNext) // Va ouvrir la form tel que prévu par le switch, whatToDoNext ayant été set lors du clic sur le menustrip correspondant.
                    {
                        case 1: // gererLesPlatsDisponibles
                            RestDishAvailable restDish = RestDishAvailable.getInstance();
                            restDish.setRestToAdmin(restToAdmin);
                            restDish.MdiParent = this.MdiParent;
                            restDish.Hide();
                            restDish.Show();
                            this.Hide();
                            break;
                        case 2:
                            RestComboMaker restCombo = RestComboMaker.getInstance();
                            restCombo.SetRestToAdmin(restToAdmin);
                            restCombo.MdiParent = this.MdiParent;
                            restCombo.Hide();
                            restCombo.Show();
                            this.Hide();
                            break;
                        case 3: // voirLesReservationsParDate
                            RestBookingPerDate restBook = RestBookingPerDate.getInstance();
                            restBook.SetRestToUse(restToAdmin);
                            restBook.MdiParent = this.MdiParent;
                            restBook.Hide();
                            restBook.Show();
                            this.Hide();
                            break;
                        case 4: // voirLesTablesParDates
                            RestTablePerDate restTable = RestTablePerDate.getInstance();
                            restTable.SetRestToUse(restToAdmin);
                            restTable.MdiParent = this.MdiParent;
                            restTable.Hide();
                            restTable.Show();
                            this.Hide();
                            break;

                        default: //Si il y a une erreur et qu'il y a une mauvaise valeur set, on envoie un messagebox explicant qu'une erreur est survenue. On ne devrait jamais être confronté au cas mais on sait jamais.
                            MessageBox.Show("Une erreur est survenue.", "ERREUR", MessageBoxButtons.OK);
                            break;
                    }
                }
            }
        }

        //Application du principe de singleton, on ne détruit plus la form mais on la cache.
        private void RestID_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }
    }
}
<file_sep>Liste des contraintes d'unicité :

- Customer : Name+LastName+DateOfBirth 
- Group : Name 
- Restaurant : Name+Place
- RefMeal : Name+Grou_Id+Type_Id

Tables populées : 

- Customer
- Table
- Group
- Restaurant
- Type
- RefMeal

--> a populer : MealRest +-, Combo, Preor+-, Book+-<file_sep>﻿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 Admin4You
{
    public partial class GroupId : Form
    {

        //Implémentation du principe de singleton. On n'instancie pas quand on utilise mais on fais le getInstance(),
        // cela permet de n'avoir qu'une seule instance de la fenêtre à la fois.
        static private GroupId _instance;

        static public GroupId getInstance()
        {
            if (_instance == null)
                _instance = new GroupId();
            return _instance;
        }

        public GroupId()
        {
            InitializeComponent();
        }

        //Application du principe de singleton, on ne détruit plus la form mais on la cache.
        private void btCancel_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void btOk_Click(object sender, EventArgs e)
        {
            int idGroupToUse;
            if (int.TryParse(txtGroupId.Text, out idGroupToUse))
            {
                Models.GroupModel grToAdmin = BusinessLayer.GroupBL.GetGroupByIdBL(idGroupToUse); //Récupère le Group Exact via une Sp.

                if(grToAdmin == null) //Dans le cas ou le group n'a pu être récupéré, renvoie une messageBox avec une erreur. Reset du TextBox.
                {
                    MessageBox.Show("L'ID que vous avez rentré ne corresponds pas.", "ERREUR", MessageBoxButtons.OK);
                    txtGroupId.Text = "";
                }
                else
                { 
                    GroupAdmin grad = GroupAdmin.getGrAdmin(); //Sinon on ouvre la nouvelle form (principe singleton) et on set le group qu'on a trouvé.
                    grad.setGrouptoAdmin(grToAdmin);
                    grad.MdiParent = this.MdiParent;
                    grad.Hide();
                    grad.Show();
                }

                this.Hide();
            }

            else
            { //Si le textbox n'a pu être parsé, on envoie une message box et on reset le Textbox
                MessageBox.Show("Veuillez rentrer un nombre dans le champ SVP", "ERREUR", MessageBoxButtons.OK);
                txtGroupId.Text = "";
            }
        }

        private void GroupId_FormClosing(object sender, FormClosingEventArgs e)
        {        //Application du principe de singleton, on ne détruit plus la form mais on la cache.
            e.Cancel = true;
            this.Hide();
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataAcessLayer
{
    static class Utils
    {
        static public string _connectionString = "Data Source=DESKTOP-63FMG3J;Initial Catalog=Resto4You;User ID=sa;Password=<PASSWORD>";
    }
}
<file_sep>﻿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 Admin4You
{
    public partial class RestAdmin4YouForm : Form
    {
        //A chaque fois on gardera cette form-ci comme MdiParent, meme pour les forms ouvertes par la suite.
        public RestAdmin4YouForm()
        {
            InitializeComponent();
        }
        //Partie de la gestion du groupe.

        private void voirLesChiffresParDateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GroupId groupAuth = GroupId.getInstance();
            groupAuth.MdiParent = this;
            groupAuth.Show();
        }

        //Partie de la gestion du Restaurant. En fonction du menustrip cliqué, va set le WhatToDoNext de la form RestID appellée afin qu'il sache ouvrir la form correspondante.
        //Ceci permet d'utiliser une seule fenêtre d'identification du restaurant.
        
        private void gererLesPlatsDisponiblesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RestID restAuth = RestID.GetInstance();
            restAuth.SetWhatToDoNext(1);
            restAuth.MdiParent = this;
            restAuth.Show();
        }

        private void gererLesMenusDisponiblesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RestID restAuth = RestID.GetInstance();
            restAuth.SetWhatToDoNext(2);
            restAuth.MdiParent = this;
            restAuth.Show();
        }

        private void voirLesReservationsParDateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RestID restAuth = RestID.GetInstance();
            restAuth.SetWhatToDoNext(3);
            restAuth.MdiParent = this;
            restAuth.Show();
        }

        private void voirLesTablesParDatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RestID restAuth = RestID.GetInstance();
            restAuth.SetWhatToDoNext(4);
            restAuth.MdiParent = this;
            restAuth.Show();
        }
    }
}
<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Models
{
    public class RestaurantModel
    {
        public int id { get; set; }
        public int grId { get; set; }
        public int place { get; set; }
        public string name { get; set; }
    }
}
<file_sep>﻿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 Admin4You
{
    public partial class RestDishAvailable : Form
    {
        //Mise en place d'un objet Restaurant model propre à la form. sera attribué lors de l'appel à l'affichage. Détermine quel restaurant est administré ici.
        private Models.RestaurantModel restToAdmin;

        public void setRestToAdmin(Models.RestaurantModel rest)
        {
            restToAdmin = rest;
        }

        //Implémentation du principe de singleton. On n'instancie pas quand on utilise mais on fais le getInstance(),
        // cela permet de n'avoir qu'une seule instance de la fenêtre à la fois.

        static private RestDishAvailable _instance;

        static public RestDishAvailable getInstance()
        {
            if (_instance == null)
                _instance = new RestDishAvailable();

            return _instance;
        }



        public RestDishAvailable()
        {
            InitializeComponent();
        }

        private void RestDishAvailable_VisibleChanged(object sender, EventArgs e)
        {//Charge les différents affichage de la form. vu le principe de singleton permet de garder les informations à jour à chaque affichage de la form.
            label_show_RestID.Text = restToAdmin.id.ToString();
            dataGridView_ShowDishesAvailableInTheRestau.DataSource = BusinessLayer.RestBL.GetMealByRestIDBL(restToAdmin.id);
            dataGridView_ShowDishesAvailableForTheGroup.DataSource = BusinessLayer.RestBL.GetRefMealByGroupIDBL(restToAdmin.grId);
        }

        private void bt_Add_Click(object sender, EventArgs e)
        {
            int pPrice;
            if (int.TryParse(textBox_Price.Text, out pPrice)) //if conditionné sur la récupération du prix dans la textbox. 
            {//remonte => BL => DAL => Sp pour inserer le nouveau plat proposé, utilisant la ligne sélectionné dans la Grid avec les plats du group, l'ID du restau et le prix de la box.
                BusinessLayer.RestBL.InsertOrUpdateNewAvailableDishBL(Convert.ToInt32(dataGridView_ShowDishesAvailableForTheGroup.SelectedCells[0].Value), restToAdmin.id, pPrice);
                dataGridView_ShowDishesAvailableInTheRestau.DataSource = BusinessLayer.RestBL.GetMealByRestIDBL(restToAdmin.id);
            }
            else //Si récupération impossible envoie un message box et reset le text du TextBox.
            { 
                MessageBox.Show("Une erreur est survenue.", "ERREUR", MessageBoxButtons.OK);
                textBox_Price.Text = "";
            }
        }

        //Application du principe de singleton, on ne détruit plus la form mais on la cache.
        private void RestDishAvailable_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
            this.Hide();
        }
    }
}
