/// <summary> /// Update the project scope information in the database /// </summary> /// <remarks>Uses the [TIP].[UpdateProjectScope] stored proc.</remarks> /// <param name="model"></param> public void UpdateProjectScope(ScopeModel model) { using (SqlCommand command = new SqlCommand("[TIP].[UpdateProjectScope]") { CommandType = CommandType.StoredProcedure }) { command.Parameters.AddWithValue("@ProjectVersionID", model.ProjectVersionId); command.Parameters.AddWithValue("@TipYear", model.TipYear); command.Parameters.AddWithValue("@BeginConstructionYear", model.BeginConstructionYear != null ? (object)model.BeginConstructionYear.Value : (object)DBNull.Value); command.Parameters.AddWithValue("@EndConstructionYear", model.OpenToPublicYear != null ? (object)model.OpenToPublicYear.Value : (object)DBNull.Value); command.Parameters.AddWithValue("@ProjectDescription", model.ProjectDescription); this.ExecuteNonQuery(command); } }
public ScopeModel GetScopeModel(int projectVersionId, string tipYear) { ScopeModel result = null; using (SqlCommand command = new SqlCommand("[TIP].[GetProjectScope]") { CommandType = CommandType.StoredProcedure }) { command.Parameters.AddWithValue("@ProjectVersionId", projectVersionId); //command.Parameters.AddWithValue("@TipYear", tipYear); using (IDataReader rdr = ExecuteReader(command)) { if (rdr.Read()) { result = new ScopeModel(); result.BeginConstructionYear = rdr["BeginConstructionYear"] != DBNull.Value ? (int?)Convert.ToInt32(rdr["BeginConstructionYear"]) : null; result.OpenToPublicYear = rdr["EndConstructionYear"] != DBNull.Value ? (int?)Convert.ToInt32(rdr["EndConstructionYear"]) : null; result.ProjectDescription = rdr["Scope"].ToString().Trim(); result.ProjectId = rdr["ProjectId"] != DBNull.Value ? (int?)rdr["ProjectId"] : null; result.ProjectName = rdr["ProjectName"].ToString(); result.ProjectVersionId = rdr["ProjectVersionId"] != DBNull.Value ? (int)rdr["ProjectVersionId"] : default(int); result.TipYear = tipYear; } } } return result; }