public List <ELock> GetELock() { DataTable table = null; LoggingData data = new LoggingData(ip, username, password, database); table = data.GetELock(); if (table == null) { CLog4net.LogError("锁控板列表初始化错误"); return(null); } List <ELock> boxes = new List <ELock>(); foreach (System.Data.DataRow d in table.Rows) { ELock cb = new ELock(); cb.Id = Convert.ToInt32(d[TbELock.id]); if (d[TbELock.boxCode].ToString() != "") { cb.BoxCode = Convert.ToInt32(d[TbELock.boxCode]); } cb.Address = Convert.ToString(d[TbELock.ip]); cb.Password = Convert.ToString(d[TbELock.password]); cb.Value = Convert.ToString(d[TbELock.value]); boxes.Add(cb); } return(boxes); }