public static Project Load(IDataRecord reader) { Project ret = new Project(); ret._projectId = (int)reader["ProjectId"]; ret._title = reader["Title"].ToString(); ret._statusId = (int)reader["StatusId"]; ret._managerId = (int)reader["ManagerId"]; ret._executiveManagerId = Helper.NullToNulableInt32(reader["ExecutiveManagerId"]); return ret; }
public void Save(DBHelper target, Project project) { _blockTypeInstanceId = project != null ? project.BlockTypeInstanceId : NonProjectTTBlockTypeInstanceId; _blockId = target.RunTextInteger("INSERT INTO [cls_TimeTrackingBlock] ([Modified],[ModifierId],[Card],[Title],[BlockTypeInstanceId],[Day1],[Day2],[Day3],[Day4],[Day5],[Day6],[Day7],[OwnerId],[mc_StateId],[mc_StateMachineId],[StartDate],[ProjectId],[AreFinancesRegistered],[IsRejected]) VALUES (@p1,@p2,@p3,@p5,@p6,@p7,@p7,@p7,@p7,@p7,@p7,@p7,@p8,@p9,@p10,@p11,@p12,@p13,@p14) SELECT @retval = SCOPE_IDENTITY()" , DBHelper.MP("@p1", SqlDbType.DateTime, _lastSavedDate) , DBHelper.MP("@p2", SqlDbType.Int, _lastEditorId) , DBHelper.MP("@p3", SqlDbType.NVarChar, 50, "TimeTrackingBlockDescr") , DBHelper.MP("@p5", SqlDbType.NVarChar, 100, _title) , DBHelper.MP("@p6", SqlDbType.Int, _blockTypeInstanceId) , DBHelper.MP("@p7", SqlDbType.Float, 0F) , DBHelper.MP("@p8", SqlDbType.Int, _userId) , DBHelper.MP("@p9", SqlDbType.Int, ConvertState(_statusId, _projectId > 0, ref _isRejected)) , DBHelper.MP("@p10", SqlDbType.Int, TTBlockStateMachineId) , DBHelper.MP("@p11", SqlDbType.DateTime, _startDate) , DBHelper.MP("@p12", SqlDbType.Int, _projectId > 0 ? (object)_projectId : DBNull.Value) , DBHelper.MP("@p13", SqlDbType.Bit, _areFinancesRegistered) , DBHelper.MP("@p14", SqlDbType.Bit, _isRejected) ); if (!string.IsNullOrEmpty(_managerComments)) { target.RunText("INSERT INTO [cls_TimeTrackingBlockDescr] ([TimeTrackingBlockId],[Description]) VALUES (@p1,@p2)" , DBHelper.MP("@p1", SqlDbType.Int, _blockId) , DBHelper.MP("@p2", SqlDbType.NText, _managerComments) ); } // Save role principals Helper.SaveRolePrincipals(target, "cls_TimeTrackingBlock_Role_Principal", _blockId, 6, _userId); // Owner if (project != null) project.SaveProjectRoles(target, "cls_TimeTrackingBlock_Role_Principal", _blockId); }