private void btnDRoom_Click(object sender, EventArgs e) { if (dgvRoom.SelectedRows.Count <= 0) { md.MsgDivShow("请选中要删除的房间", 1); return; } if (MessageBox.Show("确认删除该房间吗?", "删除房间", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK) { int id = ((RoomInfo)dgvRoom.SelectedRows[0].DataBoundItem).RoomId; //判断该房间下是否有餐桌,有餐桌就不删除该房间 DeskInfoBLL dkBll = new DeskInfoBLL(); if (dkBll.GetDeskInfoCountByRoomId(id)>0) { md.MsgDivShow("对不起,该房间下有餐桌", 1); return; } //该房间下没有餐桌--可以删除选中的房间 RoomInfoBLL rBll = new RoomInfoBLL(); md.MsgDivShow(rBll.SoftDeleteRoomInfoByRoomId(id) ? "操作成功" : "操作失败", 1); LoadAllRoomInfoByDelFlag(0);//刷新 return; } md.MsgDivShow("您已经取消了删除该房间"); }