//加载餐桌,tp表示的是哪个选项卡.p表示的是删除标识 private void LoadDeskInfoByDelFlag(TabPage tp)//, int p) { RoomInfo room = tp.Tag as RoomInfo; int roomId = Convert.ToInt32(room.RoomId); //获取房间的id ListView lv = tp.Controls[0] as ListView; //获取当前选项卡中的listview控件(东西) lv.Clear(); //清空 DeskInfoBLL bll = new DeskInfoBLL(); //通过房间的id获取该房间下的所有的餐桌 List <DeskInfo> list = bll.GetAllDeskInfoByRoomId(roomId);// for (int i = 0; i < list.Count; i++) { //if (list[i].DeskState==0) //{ // lv.Items.Add(list[i].DeskName, 0); //} //else if (list[i].DeskState==1) //{ // lv.Items.Add(list[i].DeskName, 1); //} lv.Items.Add(list[i].DeskName, Convert.ToInt32(list[i].DeskState)); lv.Items[i].Tag = list[i];//把餐桌的对象绑定到每个项的tag属性中 //else if (list[i].DeskState==2) //{ //} } }
//加载餐桌 private void LoadDeskInfoBySelectedRoomId(TabPage tp) { var rm = tp.Tag as RoomInfo; var lv = tp.Controls[0] as ListView;//lv对象储存在tabPage中 lv.Clear(); var bll = new DeskInfoBLL(); var listDesk = bll.GetAllDeskInfoByRoomId((int)rm.RoomId); for (int i = 0; i < listDesk.Count; i++) { lv.Items.Add(listDesk[i].DeskName, (int)listDesk[i].DeskState); lv.Items[i].Tag = listDesk[i]; } }
private void LoadDeskInfoByTabpagesSelect(TabPage tp) { RoomInfo room = (RoomInfo)tp.Tag; //获取tabpage控件中的listview控件 ListView lv = (ListView)tp.Controls[0];//为什么是0 因为我只往tab下面添加了一个listview控件 //根据房间的id查询该房间下所有的餐桌 List <DeskInfo> list = dbll.GetAllDeskInfoByRoomId(room.RoomId); lv.Clear(); for (int i = 0; i < list.Count; i++) { lv.Items.Add(list[i].DeskName, list[i].DeskState); lv.Items[i].Tag = list[i]; } }
//根据房间的id显示里面的餐桌 private void LoadDeakInfoByTabpageSelect(TabPage tp) { RoomInfo room = (RoomInfo)tp.Tag; //获取房间对象 //获取tabpage控件中的listview控件 ListView lv = (ListView)tp.Controls[0]; //获取包含在控件内的控件 lv.Clear(); //清除 //根据房间Id查询该房间下所有的餐桌 DeskInfoBLL dkBll = new DeskInfoBLL(); List <DeskInfo> listDesk = dkBll.GetAllDeskInfoByRoomId(room.RoomId); for (int i = 0; i < listDesk.Count; i++) { lv.Items.Add(listDesk[i].DeskName, listDesk[i].DeskState); //用指定的文本和图像创建一个项并添加到集合中 lv.Items[i].Tag = listDesk[i]; //餐桌对象存起来 } }