Пример #1
0
        public List<CRoom> get_rooms(string state_str)
        {
            List<CRoom> rooms = new List<CRoom>();
            SqlConnection sqlCn = null;
            string cmd_str = "";

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                cmd_str = "Select * from [Room]";
                if (state_str != null && state_str != "")
                    cmd_str += "where (" + state_str + ")";
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        var room = new CRoom();

                        room.id = (int)dr["id"];
                        room.name = dr["name"].ToString();
                        room.population = (int)dr["population"];
                        room.openTime = dr["openTime"].ToString();
                        room.seat = dr["seat"].ToString();
                        room.systemId = dr["systemId"].ToString();
                        room.orderTime = dr["orderTime"].ToString();
                        room.menu = dr["menu"].ToString();
                        room.orderTechId = dr["orderTechId"].ToString();
                        room.techId = dr["techId"].ToString();
                        room.startTime = dr["startTime"].ToString();
                        room.serverTime = dr["serverTime"].ToString();
                        room.status = dr["status"].ToString();
                        room.note = dr["note"].ToString();
                        room.hintPlayed = dr["hintPlayed"].ToString();
                        room.reserveId = dr["reserveId"].ToString();
                        room.reserveTime = dr["reserveTime"].ToString();
                        room.selectId = dr["selectId"].ToString();
                        room.seatIds = dr["seatIds"].ToString();

                        rooms.Add(room);
                    }
                }

            }
            catch (System.Exception e)
            {
                IOUtil.insert_file(DateTime.Now.ToString() + "=" + cmd_str);
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return rooms;
        }
Пример #2
0
        /// <summary>
        /// 获取房间号
        /// </summary>
        /// <param name="cmd_str"></param>
        /// <returns></returns>
        public CRoom get_Room(string cmd_str)
        {
            CRoom room = null;
            SqlConnection sqlCn = null;

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        room = new CRoom();
                        room.id = (int)dr["id"];
                        room.name = dr["name"].ToString();
                        room.seatIds = ToString(dr["seatIds"]);

                        break;
                    }
                }

            }
            catch (System.Exception e)
            {
                //IOUtil.insert_file(e.Message);
                //IOUtil.insert_file("method=execute_command,time=" + DateTime.Now.ToString() + ",cmd_str=" + cmd_str);
                //BathClass.printErrorMsg(cmd_str);
                IOUtil.insert_file(e.Message);
                IOUtil.insert_file("time=" + DateTime.Now.ToString() + ",cmd_str=" + cmd_str);
                IOUtil.insert_file("\n");
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return room;
        }