Beispiel #1
0
        //Updates the price of the View Model to the lowest
        static private List <PieceStock> UpdatePiecesInfo(SQLiteDataReader q, List <PieceStock> pieceList)
        {
            //Console.WriteLine(Convert.ToString(q["Piece_Code"]));
            PieceStock piece = pieceList.Where(e => Convert.ToString(q["Piece_Code"]) == e.Id).FirstOrDefault();

            if (piece != null)
            {
                if (piece.Price > Convert.ToInt32(q["Price"]))
                {
                    piece.Price         = Convert.ToInt32(q["Price"]);
                    piece.ShippingDelay = Convert.ToInt32(q["Delay"]);
                    piece.Supplier      = Convert.ToString(q["Name"]);
                }
                else if (piece.Price == Convert.ToInt32(q["Price"]) && piece.ShippingDelay > Convert.ToInt32(q["Delay"]))
                {
                    piece.ShippingDelay = Convert.ToInt32(q["Delay"]);
                    piece.Supplier      = Convert.ToString(q["Name"]);
                }
            }

            return(pieceList);
        }
Beispiel #2
0
        //Creates the View Model and add it for the others methods
        static private List <PieceStock> GetListPieces(SQLiteDataReader q, List <PieceStock> pieceList)
        {
            int    quantity  = 0;
            string reference = Convert.ToString(q["Reference"]);
            int    price     = Convert.ToInt32(q["Price_Client"]);
            string id        = Convert.ToString(q["Piece_Code"]);

            try
            {
                quantity = Convert.ToInt32(q["Quantity"]);
            }
            catch
            {
                quantity = Convert.ToInt32(q["Ordered_Extra"]);
            }

            PieceStock temp = new PieceStock(reference, quantity, price, id);

            pieceList.Add(temp);

            return(pieceList);
        }