public Floors() { DataTable dt = null; using (FirebirdDBHelper db = new FirebirdDBHelper(util.strDBConn)) { try { dt = db.GetDataTableSP("GET_FLOOR"); } catch (FirebirdSql.Data.FirebirdClient.FbException ex) { util.WriteLog(string.Format("DB Error ({0}) : {1}", this.GetType(), ex.Message)); } } foreach (DataRow row in dt.Rows) { DataTable dt1 = null; using (FirebirdDBHelper db = new FirebirdDBHelper(util.strDBConn)) { DataTable _input = util.CreateDT2SP(); _input.Rows.Add("@I_ROOM", row[0].ToString()); try { dt1 = db.GetDataTableSP("GET_ROOM_BY_FLOOR", _input); } catch (FirebirdSql.Data.FirebirdClient.FbException ex) { util.WriteLog(string.Format("DB Error ({0}) : {1}", this.GetType(), ex.Message)); } } ObservableCollection <RoomItem> _list = new ObservableCollection <RoomItem>(); foreach (DataRow _row in dt1.Rows) { int err_count = 0; RoomItem txtroom = new RoomItem() { RoomNum = _row[0].ToString(), States = string.IsNullOrEmpty(_row[1].ToString()) == true || _row[1].ToString().Equals("0") ? "0" : "1", States_Clean = _row[4].ToString(), States_Laundary = _row[5].ToString(), States_Parcel = _row[6].ToString(), IsChecked = false, Height = 130, Width = 130, CWidth = 70, CHeight = 70, Margin = new Thickness(10, 10, 10, 10), HAlignment = System.Windows.HorizontalAlignment.Left, VAlignment = System.Windows.VerticalAlignment.Top }; _cgi_pms_data_type pms_data_type; using (HotelHelper hh = new HotelHelper(util.PBXIP)) { pms_data_type = hh.GetPolicy(_row[2].ToString()); if (pms_data_type.status == STRUCTS.ERR_SOCKET_TIMEOUT) { _list.Add(txtroom); continue; } } txtroom.Hour = pms_data_type.hour; txtroom.Minutes = pms_data_type.minutes; if (txtroom.States.Equals("0")) { pms_data_type.language = 0; } txtroom.Languages = pms_data_type.language.ToString(); txtroom.PMSDATA = pms_data_type; _list.Add(txtroom); } var lastitem = _list.Where(x => x.PMSDATA.status == STRUCTS.ERR_SOCKET_TIMEOUT); if (lastitem.Count() > 1) { break; } this.Add(new Floor() { txtFloor = string.Format("{0}F", row[0].ToString()), list = _list }); } }