Ejemplo n.º 1
0
        //
        public List<ChiefListEntry> getActiveOrders()
        {
            List<ChiefListEntry> list = new List<ChiefListEntry>();
            ChiefListEntry tmpEntry = new ChiefListEntry();
            connector.openConnection();
            OleDbDataReader reader = connector.executeQuery(
            @"SELECT
                sel.Name_Dish,
                sel.Need,
                sel.Ready,
                sel.Left_,
                sel2.StockLeft
            FROM
            (
                SELECT
                    d.Name_Dish,
                    SUM(do.Dish_Count) as Need,
                    SUM(do.Ready_Count) as Ready,
                    (Need - Ready) as Left_
                FROM
                    Dishes_Order AS do
                INNER JOIN
                    Dishes AS d ON d.ID_Dish = do.ID_Dish
                WHERE
                    do.Dish_Count - do.Ready_Count > 0
                GROUP BY
                    d.Name_Dish
            ) as sel
            LEFT JOIN
            (
                SELECT
                    lcd.Name_Dish, SUM(lcd.Amount - lcd.Out_Amount) as StockLeft
                FROM
                    Left_Cooked_Dishes as lcd
                GROUP BY lcd.Name_Dish
            ) as sel2
            ON sel.Name_Dish = sel2.Name_Dish"
            );

            while (reader.Read())
            {
                tmpEntry.name = reader[0].ToString();
                tmpEntry.need = Convert.ToInt32(reader[1]);
                tmpEntry.ready = Convert.ToInt32(reader[2]);
                tmpEntry.left = Convert.ToInt32(reader[3]);

                tmpEntry.inStock = !DBNull.Value.Equals(reader[4]) ? Convert.ToInt32(reader[4]) : 0;
                list.Add(tmpEntry);
            }
            reader.Close();
            connector.closeConnection();
            return list;
        }
Ejemplo n.º 2
0
        public List<ChiefListEntry> getActiveOrders()
        {
            List<ChiefListEntry> list = new List<ChiefListEntry>();
            ChiefListEntry tmpEntry = new ChiefListEntry();
            connector.openConnection();
            OleDbDataReader reader = connector.executeQuery("SELECT d.Name_Dish, SUM(do.Dish_Count) as Need, SUM(do.Ready_Count) as Ready, (Need - Ready) as Left_ FROM Dishes_Order AS do INNER JOIN Dishes AS d ON d.ID_Dish = do.ID_Dish WHERE do.Dish_Count - do.Ready_Count > 0 GROUP BY d.Name_Dish");

            while (reader.Read())
            {
                tmpEntry.name = reader[0].ToString();
                tmpEntry.need = Convert.ToInt32(reader[1]);
                tmpEntry.ready = Convert.ToInt32(reader[2]);
                tmpEntry.left = Convert.ToInt32(reader[3]);
                list.Add(tmpEntry);
            }
            reader.Close();
            connector.closeConnection();
            return list;
        }