コード例 #1
0
        public News(Guid pId, string pTitle, string pContent, DateTime pPublishTime, string pAboutDish)
        {
            id = pId;
            title = pTitle;
            content = pContent;
            publishTime = pPublishTime;
            aboutDish = pAboutDish;

            DataContextDataContext dc = new DataContextDataContext();
            ISingleResult<get_dish_by_nameResult> rs2 = dc.get_dish_by_name(aboutDish);
            foreach (get_dish_by_nameResult r2 in rs2)
            {
                pictPath = r2.pict_path;
            }
        }
コード例 #2
0
        public static List<Delivery> GetAllHistoryDelivery()
        {
            List<Delivery> deliveryList = new List<Delivery>();
            DataContextDataContext dc = new DataContextDataContext();

            ISingleResult<select_all_history_deliveryResult> rs = dc.select_all_history_delivery();
            foreach (select_all_history_deliveryResult r in rs)
            {
                List<DishQuota> dishQuotaLish = new List<DishQuota>();

                ISingleResult<get_dishquota_by_deliveryResult> rs2 = dc.get_dishquota_by_delivery(r.id);
                foreach (get_dishquota_by_deliveryResult 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.quota, r2.note);
                    dishQuotaLish.Add(dishQuota);
                }

                Delivery delivery = new Delivery(
                    (Guid)r.id,
                    r.user_from,
                    r.customer_name,
                    r.phone,
                    r.address,
                    (DateTime)r.commit_time,
                    (DateTime)r.delivery_time,
                    (DeliveryState)r.state,
                    dishQuotaLish);

                deliveryList.Add(delivery);
            }

            return deliveryList;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        //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;
        }
コード例 #5
0
        //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);
            }
        }
コード例 #6
0
        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;
        }
コード例 #7
0
        public Dish GetDishByName(string pDishName)
        {
            Dish dish = null;

            DataContextDataContext dc = new DataContextDataContext();
            ISingleResult<get_dish_by_nameResult> rs = dc.get_dish_by_name(pDishName);

            foreach (get_dish_by_nameResult r in rs)
            {
                List<Tag> tagList = new List<Tag>();
                List<Comment> commentList = new List<Comment>();

                ISingleResult<get_tag_by_dishResult> rs2 = dc.get_tag_by_dish(r.name);
                foreach (get_tag_by_dishResult r2 in rs2)
                {
                    Tag tag = new Tag(r2.name, (int)r2.popularity);
                    tagList.Add(tag);
                }

                ISingleResult<get_comment_by_dishResult> rs3 = dc.get_comment_by_dish(r.name);
                foreach (get_comment_by_dishResult r3 in rs3)
                {
                    Comment comment = new Comment(r3.id, r3.content, r3.about_dish, r3.user_from);
                    commentList.Add(comment);

                }

                dish = new Dish(
                    r.name,
                    r.description,
                    (double)r.price,
                    r.pict_path,
                    (int)r.popularity,
                    tagList,
                    commentList);
            }
            return dish;
        }