Example #1
0
        /// <summary>
        /// 创建台位界面
        /// </summary>
        /// <param name="dao">数据库连接</param>
        /// <param name="options">选项</param>
        /// <param name="seatPanel">面板</param>
        /// <param name="seatTab">标签页</param>
        /// <param name="btn_click">响应回调函数</param>
        /// <param name="cm">右键菜单</param>
        /// <param name="department">部门:桑拿部、客房部</param>
        public static void createSeatByDao(DAO dao, COptions options, Control seatPanel, TabControl seatTab, 
            EventHandler btn_click,EventHandler btn_MouseHover, ContextMenuStrip cm, string department)
        {
            if (MConvert<bool>.ToTypeOrDefault(options.台位类型分页显示, false))       //台位类型是否分页显示
            {
                seatPanel.Visible = false;
                seatTab.Visible = true;
                seatTab.Dock = DockStyle.Fill;

                List<CSeatType> seat_types = new List<CSeatType>();
                if (department == null)
                    seat_types = dao.get_seattypes(null, null);
                else
                    seat_types = dao.get_seattypes("department", department);
                foreach (var stype in seat_types)
                {
                    TabPage tp = create_seat_page(stype.name, seatTab);
                    var seats = dao.get_seats("typeId", stype.id).OrderBy(x => x.text).ToList();
                    creat_seat_per_panel(seats, tp, btn_click,btn_MouseHover, cm);
                }
            }
            else
            {
                seatPanel.Visible = true;
                seatTab.Visible = false;
                seatPanel.Dock = DockStyle.Fill;

                //var seatTypes = dao.get_seattypes("department", department).Select(x => x.id).ToList();
                List<CSeat> seats = new List<CSeat>();
                if (department == null)
                {
                    seats = dao.get_all_seats().OrderBy(x => x.typeId).ThenBy(x => x.text).ToList();
                }
                else
                {
                    seats = dao.get_seats("typeid in (select id from seattype where department='" + department + "')").
                        OrderBy(x => x.typeId).ThenBy(x => x.text).ToList();
                }

                //var seats = dao.get_seats(null, null).OrderBy(x => x.typeId).ThenBy(x => x.text).ToList();
                creat_seat_per_panel(seats, seatPanel, btn_click,btn_MouseHover, cm);

                //if (dao.has_hotel_department())
                //{
                //    seatPanel.Visible = false;
                //    seatTab.Visible = true;
                //    seatTab.Dock = DockStyle.Fill;
                //    TabPage tp = create_seat_page("桑拿部", seatTab);
                //    var seatTypes = dao.get_seattypes("name", "桑拿部").Select(x => x.id).ToList();
                //    var seats = dao.get_seats("typeId", seatTypes).OrderBy(x => x.typeId).ThenBy(x => x.text).ToList();
                //    creat_seat_per_panel(seats, tp, btn_click, cm);

                //    tp = create_seat_page("客房部", seatTab);
                //    seatTypes = dao.get_seattypes("department", "客房部").Select(x => x.id).ToList();
                //    seats = dao.get_seats("typeId", seatTypes).OrderBy(x => x.typeId).ThenBy(x => x.text).ToList();
                //    //seatTypes = dc.SeatType.Where(x => x.department == "客房部").Select(x => x.id);
                //    //seats = dc.Seat.Where(x => seatTypes.Contains(x.typeId)).OrderBy(x => x.typeId).ThenBy(x => x.text).ToList();
                //    creat_seat_per_panel(seats, tp, btn_click, cm);
                //}
                //else
                //{
                //}
            }
        }