public static List<Reservation> GetAllHistoryReservation()
        {
            List<Reservation> reservationList = new List<Reservation>();

            DataContextDataContext dc = new DataContextDataContext();
            ISingleResult<select_all_history_reservationResult> rs = dc.select_all_history_reservation();
            foreach (select_all_history_reservationResult r in rs)
            {
                List<DishQuota> dishQuotaList = new List<DishQuota>();

                ISingleResult<get_dishquota_by_reservationResult> rs2 = dc.get_dishquota_by_reservation(r.id);
                foreach (get_dishquota_by_reservationResult r2 in rs2)
                {
                    double price = 0;
                    ISingleResult<get_dish_by_nameResult> rs3 = dc.get_dish_by_name(r2.dish_name);
                    foreach (get_dish_by_nameResult r3 in rs3)
                    {
                        price = (double)r3.price;
                    }

                    DishQuota dishQuota = new DishQuota(r2.id, r2.dish_name, price, (int)r2.quato, r2.note);
                    dishQuotaList.Add(dishQuota);
                }

                Reservation reservation = new Reservation(
                    r.id,
                    r.user_from,
                    r.customer_name,
                    r.phone,
                    (DateTime)r.arrive_time,
                    r.table_name,
                    (int)r.seat,
                    (ReservationType)r.type,
                    (ReservationState)r.state,
                    dishQuotaList);
                reservationList.Add(reservation);
            }

            return reservationList;
        }
        //Function: initiate all the tables with states, by querying the db
        ////从数据库把桌子信息读出来,带着当前的状态
        public static void InitAllTable()
        {
            tableList = new List<SysTable>();

            DataContextDataContext dc = new DataContextDataContext();
            ISingleResult<select_all_tableResult> rs = dc.select_all_table();
            foreach (select_all_tableResult r in rs)
            {
                Reservation reservation = null;

                ISingleResult<get_current_reservation_by_tableResult> rs2 = dc.get_current_reservation_by_table(r.name);
                foreach (get_current_reservation_by_tableResult r2 in rs2)
                {
                    List<DishQuota> dishQuotaList = new List<DishQuota>();

                    ISingleResult<get_dishquota_by_reservationResult> rs3 = dc.get_dishquota_by_reservation(r2.id);
                    foreach (get_dishquota_by_reservationResult r3 in rs3)
                    {
                        double price = 0;
                        ISingleResult<get_dish_by_nameResult> rs4 = dc.get_dish_by_name(r3.dish_name);
                        foreach (get_dish_by_nameResult r4 in rs4)
                        {
                            price = (double)r4.price;
                        }

                        DishQuota dishQuota = new DishQuota((Guid)r3.id, r3.dish_name, price, (int)r3.quato, r3.note);
                        dishQuotaList.Add(dishQuota);
                    }

                    reservation = new Reservation(
                    r2.id,
                    r2.user_from,
                    r2.customer_name,
                    r2.phone,
                    (DateTime)r2.arrive_time,
                    r2.table_name,
                    (int)r2.seat,
                    (ReservationType)r2.type,
                    (ReservationState)r2.state,
                    dishQuotaList);
                }

                //only one reservation is bound to a table in a certain time
                //  in exact this foreach loop, not outside
                SysTable table = new SysTable(
                (Guid)r.id,
                r.name,
                (int)r.seat,
                r.pict_path,
                (TableState)r.current_state
                );
                table.SetReservation(reservation);
                tableList.Add(table);
            }
        }
        //Function: search reservations by keyword
        //Remarks: if the keyword == null, return all the records
        public List<Reservation> SearchReservationMatch(string keyword)
        {
            List<Reservation> reservationList = new List<Reservation>();

            if (keyword == null)
            { keyword = "%"; }  //search all the records
            else
            { }
            DataContextDataContext dc = new DataContextDataContext();
            ISingleResult<search_current_reservation_by_keywordResult> rs = dc.search_current_reservation_by_keyword(keyword);
            foreach (search_current_reservation_by_keywordResult r in rs)
            {
                List<DishQuota> dishQuotaList = new List<DishQuota>();

                ISingleResult<get_dishquota_by_reservationResult> rs2 = dc.get_dishquota_by_reservation(r.id);
                foreach (get_dishquota_by_reservationResult r2 in rs2)
                {
                    double price = 0;
                    ISingleResult<get_dish_by_nameResult> rs3 = dc.get_dish_by_name(r2.dish_name);
                    foreach (get_dish_by_nameResult r3 in rs3)
                    {
                        price = (double)r3.price;
                    }

                    DishQuota tDishQuota = new DishQuota(r2.id, r2.dish_name, price, (int)r2.quato, r2.note);
                    dishQuotaList.Add(tDishQuota);
                }

                Reservation reservation = new Reservation(
                    r.id,
                    r.user_from,
                    r.customer_name,
                    r.phone,
                    (DateTime)r.arrive_time,
                    r.table_name,
                    (int)r.seat,
                    (ReservationType)r.type,
                    (ReservationState)r.state,
                    dishQuotaList);
                reservationList.Add(reservation);
            }
            return reservationList;
        }
        public static List<Reservation> GetReservationByDurationAndUser(DateTime pBeginTime, DateTime pEndTime, string pUserFrom)
        {
            List<Reservation> reservationList = new List<Reservation>();

            DataContextDataContext dc = new DataContextDataContext();
            ISingleResult<select_reservation_by_duration_and_userResult> rs = dc.select_reservation_by_duration_and_user((DateTime?)pBeginTime, (DateTime?)pEndTime, pUserFrom);
            foreach (select_reservation_by_duration_and_userResult r in rs)
            {
                List<DishQuota> dishQuotaList = new List<DishQuota>();

                ISingleResult<get_dishquota_by_reservationResult> rs2 = dc.get_dishquota_by_reservation(r.id);
                foreach (get_dishquota_by_reservationResult r2 in rs2)
                {
                    double price = 0;
                    ISingleResult<get_dish_by_nameResult> rs3 = dc.get_dish_by_name(r2.dish_name);
                    foreach (get_dish_by_nameResult r3 in rs3)
                    {
                        price = (double)r3.price;
                    }

                    DishQuota tDishQuota = new DishQuota(r2.id, r2.dish_name, price, (int)r2.quato, r2.note);
                    dishQuotaList.Add(tDishQuota);
                }

                Reservation reservation = new Reservation(
                    r.id,
                    r.user_from,
                    r.customer_name,
                    r.phone,
                    (DateTime)r.arrive_time,
                    r.table_name,
                    (int)r.seat,
                    (ReservationType)r.type,
                    (ReservationState)r.state,
                    dishQuotaList);
                reservationList.Add(reservation);
            }
            return reservationList;
        }