示例#1
0
        //IMPLEMENTED WITH DATABASE

        /*public bool UpdateDatabase()
         * {
         *
         * }*/

        public List <Product> ItemToProduct()
        {
            List <Product> productList = new List <Product>();

            //Generate products
            Piece   piece   = new Cleat(14, 400);
            Product product = new Product(8, piece);

            productList.Add(product);

            return(productList);
        }
示例#2
0
        private static List <Piece> pieceList = new List <Piece>();  //liste avec les piece pour chaque élément, chaque piece a un type


        /// <summary>
        /// This method imports pieces from the DB to add them to the catalog
        /// All the pieces will be created according to their type (Cleat, AngleBar, ...)
        /// </summary>
        public static void GetPieces()
        {
            List <String> pieces = new List <String>();

            using (SQLiteConnection connect = new SQLiteConnection("Data Source=..\\..\\..\\..\\Kitbox.db"))
            {
                connect.Open();
                using (SQLiteCommand fmd = connect.CreateCommand())
                {
                    fmd.CommandText = @"SELECT * FROM Piece 
                                        INNER JOIN Reference 
                                        ON Piece.ID_Piece = Reference.ID_Piece
                                        LEFT OUTER JOIN Color 
                                        ON Piece.ID_Color = Color.PK_Color ";
                    SQLiteDataReader q = fmd.ExecuteReader();

                    while (q.Read())
                    {
                        string reference = Convert.ToString(q["Reference"]);
                        int    price     = Convert.ToInt32(q["Price_Client"]);
                        string id        = Convert.ToString(q["Piece_Code"]);

                        if (reference == "Angle bar")
                        {
                            int    height   = Convert.ToInt16(q["Height"]);
                            string color    = Convert.ToString(q["Color"]);
                            Piece  AngleBar = new AngleBar(height, color, price, id);
                            pieceList.Add(AngleBar);
                        }

                        else if (reference == "B_Panel")
                        {
                            int    length = Convert.ToInt16(q["Length"]);
                            int    height = Convert.ToInt16(q["Height"]);
                            int    depth  = Convert.ToInt16(q["Depth"]);
                            string color  = Convert.ToString(q["Color"]);
                            string type   = "B";
                            Piece  Panel  = new Panel(length, height, depth, color, type, price, id);
                            pieceList.Add(Panel);
                        }

                        else if (reference == "LR_Panel")
                        {
                            int    length = Convert.ToInt16(q["Length"]);
                            int    height = Convert.ToInt16(q["Height"]);
                            int    depth  = Convert.ToInt16(q["Depth"]);
                            string color  = Convert.ToString(q["Color"]);
                            string type   = "LR";
                            Piece  Panel  = new Panel(length, height, depth, color, type, price, id);
                            pieceList.Add(Panel);
                        }

                        else if (reference == "TB_Panel")
                        {
                            int    length = Convert.ToInt16(q["Length"]);
                            int    height = Convert.ToInt16(q["Height"]);
                            int    depth  = Convert.ToInt16(q["Depth"]);
                            string color  = Convert.ToString(q["Color"]);
                            string type   = "TB";//Top Bottom panel
                            Piece  Panel  = new Panel(length, height, depth, color, type, price, id);
                            pieceList.Add(Panel);
                        }

                        else if (reference == "Door")
                        {
                            int    length = Convert.ToInt16(q["Length"]);
                            int    height = Convert.ToInt16(q["Height"]);
                            string color  = Convert.ToString(q["Color"]);
                            Piece  Door   = new Door(length, height, color, price, id);
                            pieceList.Add(Door);
                        }

                        else if (reference == "Cleat")
                        {
                            int   height = Convert.ToInt16(q["Height"]);
                            Piece Cleat  = new Cleat(height, price, id);
                            pieceList.Add(Cleat);
                        }

                        else if (reference == "B_Rail")
                        {
                            string type   = "B";
                            int    length = Convert.ToInt16(q["Length"]);
                            Piece  Rail   = new Rail(type, length, price, id);
                            pieceList.Add(Rail);
                        }

                        else if (reference == "F_Rail")
                        {
                            string type   = "F";
                            int    length = Convert.ToInt16(q["Length"]);
                            Piece  Rail   = new Rail(type, length, price, id);
                            pieceList.Add(Rail);
                        }

                        else if (reference == "LR_Rail")
                        {
                            string type   = "LR";
                            int    length = Convert.ToInt16(q["Depth"]);
                            Piece  Rail   = new Rail(type, length, price, id);
                            pieceList.Add(Rail);
                        }

                        else if (reference == "Knob")
                        {
                            int   diameter = Convert.ToInt16(q["Dimensions"]); //ATTENTION changer le diamètre dans la table par juste le chiffre
                            Piece Knob     = new Knob(diameter, price, id);
                            pieceList.Add(Knob);
                        }
                    }
                }
            }
        }