public static TTBlock Load(IDataRecord reader) { TTBlock ret = new TTBlock(); ret._weekTimeSheetId = (int)reader["WeekTimeSheetId"]; ret._userId = (int)reader["UserId"]; ret._projectId = Helper.NullToInt32(reader["ProjectId"]); ret._startDate = (DateTime)reader["StartDate"]; ret._statusId = (int)reader["StatusId"]; ret._managerComments = reader["ManagerComments"].ToString(); ret._lastSavedDate = (DateTime)reader["LastSavedDate"]; ret._lastEditorId = (int)reader["LastEditorId"]; if (ret._projectId > 0) { ret._title = reader["Title"].ToString(); } if (Helper.NullToInt32(reader["ProjectSpreadSheetId"]) > 0) { ret._areFinancesRegistered = true; } return(ret); }
public static IDictionary <int, TTBlock> LoadList(DBHelper source) { Dictionary <int, TTBlock> ret = new Dictionary <int, TTBlock>(); using (IDataReader reader = source.RunTextDataReader("SELECT T.*, P.Title, S.ProjectSpreadSheetId FROM [WeekTimeSheet] T LEFT JOIN [PROJECTS] P ON P.ProjectId = T.ProjectId LEFT JOIN [ProjectSpreadSheet] S ON S.ProjectId = T.ProjectId")) { while (reader.Read()) { TTBlock item = Load(reader); if (!ret.ContainsKey(item._weekTimeSheetId)) { ret.Add(item._weekTimeSheetId, item); } } } return(ret); }
public static TTBlock Load(IDataRecord reader) { TTBlock ret = new TTBlock(); ret._weekTimeSheetId = (int)reader["WeekTimeSheetId"]; ret._userId = (int)reader["UserId"]; ret._projectId = Helper.NullToInt32(reader["ProjectId"]); ret._startDate = (DateTime)reader["StartDate"]; ret._statusId = (int)reader["StatusId"]; ret._managerComments = reader["ManagerComments"].ToString(); ret._lastSavedDate = (DateTime)reader["LastSavedDate"]; ret._lastEditorId = (int)reader["LastEditorId"]; if(ret._projectId > 0) ret._title = reader["Title"].ToString(); if (Helper.NullToInt32(reader["ProjectSpreadSheetId"]) > 0) ret._areFinancesRegistered = true; return ret; }