public static Canvas InitFromDisplay(int displayId) { Canvas canvas = null; using (SqlCommand cmd = new SqlCommand() { CommandType = CommandType.Text, CommandText = "SELECT c.* FROM Display d INNER JOIN Canvas c on c.CanvasId=d.CanvasId WHERE DisplayId=@displayId", }) { cmd.Parameters.AddWithValue("@displayId", displayId); cmd.ExecuteReaderExt((r) => { canvas = new Canvas() { DisplayId = displayId, }; canvas._initFromRow(r); return(false); }); } if (canvas == null) { throw new Exception("Canvas not found"); } canvas.Display = new Display(displayId); canvas.Location = new Location(displayId); canvas.Panels = Panel.List(canvas.CanvasId); return(canvas); }
public static Canvas InitFromDisplay(int displayId) { Canvas canvas = null; string sql = string.Format( "SELECT c.* FROM Display d INNER JOIN Canvas c on c.CanvasId=d.CanvasId WHERE DisplayId={0};", displayId ); using (DataSet ds = DataAccess.RunSql(sql)) { if (0 == ds.Tables[0].Rows.Count) { throw new Exception("Canvas not found"); } canvas = new Canvas() { DisplayId = displayId, } ._initFromRow(ds.Tables[0].Rows[0]) ; } canvas.Display = new Display(displayId); canvas.Location = new Location(displayId); canvas.Panels = Panel.List(canvas.CanvasId); return(canvas); }