public List<Device> getDevices() { string sql = "select * from bu_device INNER JOIN bu_type ON bu_device.typeId=bu_type.Id INNER JOIN bu_brand ON bu_device.brandId=bu_brand.Id INNER JOIN bu_cell ON bu_device.cellId=bu_cell.Id"; DataSet ds = new MySqlDa().fillDataSet(sql); List<Device> lstDevice = new List<Device>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Device device = fillDevice(ds,i); Brand brand = new Brand(); brand.Id=(int)ds.Tables[0].Rows[i]["brandId"]; brand.Name = ds.Tables[0].Rows[i][9].ToString(); device.Brand = brand; BackupAMSData.Type type = new BackupAMSData.Type(); type.Id = (int)ds.Tables[0].Rows[i]["typeId"]; type.Name = ds.Tables[0].Rows[i][7].ToString(); device.Type = type; Cell cell = new Cell(); cell.Id = (int)ds.Tables[0].Rows[i]["cellId"]; cell.Name=ds.Tables[0].Rows[i][12].ToString(); cell.CellNr = (int)ds.Tables[0].Rows[i]["CellNr"]; device.Cell = cell; lstDevice.Add(device); } return lstDevice; }
private Cell fillCell(DataSet ds, int i) { Cell cell = new Cell(); cell.Id = (int)ds.Tables[0].Rows[i]["Id"]; cell.Name = ds.Tables[0].Rows[i]["CellNr"].ToString(); cell.Name = ds.Tables[0].Rows[i]["Name"].ToString(); return cell; }
public List<Device> getDevicesByTime(DateTime date) { string sql = "select * from bu_task inner join bu_task_device on bu_task.id = bu_task_device.bu_task_id where timefield ='" + date.ToString("HH:mm") + "' and datefield='" + date.ToString("yyyMMdd") + "'"; DataSet ds = new MySqlDa().fillDataSet(sql); List<Device> lstDevice = new List<Device>(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Device device = new Device(); device.Id = (int)ds.Tables[0].Rows[i]["id"]; device.IP = ds.Tables[0].Rows[i]["ip"].ToString(); device.Name = ds.Tables[0].Rows[i]["name"].ToString(); device.TypeId = (int)ds.Tables[0].Rows[i]["typeId"]; device.BrandId = (int)ds.Tables[0].Rows[i]["brandId"]; device.CellId = (int) ds.Tables[0].Rows[i]["cellId"]; Cell cell = new Cell(); cell.Id = (int)ds.Tables[0].Rows[i]["cellId"]; cell.Name = ds.Tables[0].Rows[i][16].ToString(); cell.CellNr = (int)ds.Tables[0].Rows[i]["CellNr"]; device.Cell = cell; lstDevice.Add(device); } return lstDevice; }