public JsonResult UpdateFinancialRecord(Funding model) { //Funding model = new Funding() //{ // ProjectVersionId = projectVersionId // , // ConstantCost = (Decimal)constantCost // , // VisionCost = (Decimal)VisionCost // , // YOECost = (Decimal)yoeCost //}; try { _rtpProjectRepository.UpdateFinancialRecord(model); } catch (Exception ex) { //this.Logger.LogMethodError("ProjectController", "UpdateFinancialRecord", Request.Form.ToString(), ex); return Json(new { message = "Changes could not be stored. An error has been logged." , error = "true" , exceptionMessage = ex.Message }); } return Json(new { message = "Project Financial Record successfully updated." , error = "false" }); }
public Funding GetFunding(int projectVersionId, string plan) { Funding funding = null; using (SqlCommand command = new SqlCommand("[RTP].[GetProjectFunding]") { CommandType = CommandType.StoredProcedure }) { command.Parameters.AddWithValue("@ProjectVersionId", projectVersionId); using (IDataReader rdr = ExecuteReader(command)) { while (rdr.Read()) { funding = new Funding() { ProjectVersionId = projectVersionId , ConstantCost = rdr["ConstantCost"] != DBNull.Value ? (Decimal)Convert.ToDouble(rdr["ConstantCost"]) : (Decimal)0.00 , VisionCost = rdr["VisionCost"] != DBNull.Value ? (Decimal)Convert.ToDouble(rdr["VisionCost"]) : (Decimal)0.00 , YOECost = rdr["YOECost"] != DBNull.Value ? (Decimal)Convert.ToDouble(rdr["YOECost"]) : (Decimal)0.00 , Previous = rdr["Previous"] != DBNull.Value ? (Decimal)Convert.ToDouble(rdr["Previous"]) : (Decimal)0.00 , Future = rdr["Future"] != DBNull.Value ? (Decimal)Convert.ToDouble(rdr["Future"]) : (Decimal)0.00 , TotalCost = rdr["TotalCost"] != DBNull.Value ? (Decimal)Convert.ToDouble(rdr["TotalCost"]) : (Decimal)0.00 , PlanTypeId = rdr["PlanTypeId"] != DBNull.Value ? (int)rdr["PlanTypeId"] : Int32.MinValue , ReportGroupingCategoryId = rdr["RTPCategoryID"] != DBNull.Value ? (int)rdr["RTPCategoryID"] : Int32.MinValue }; } } } Funding categories = GetPlanReportGroupingCategories(plan); funding.ReportGroupingCategories = categories.ReportGroupingCategories; funding.ReportGroupingCategoriesDetail = categories.ReportGroupingCategoriesDetail; return funding; }
public Funding GetPlanReportGroupingCategories(string year) { var model = new Funding(); // Get Agencies which are eligible to sponsor projects SqlCommand cmd = new SqlCommand("[RTP].[Lookup_GetPlanReportGroupingCategories]"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@TimePeriod", year); using (IDataReader rdr = this.ExecuteReader(cmd)) { while (rdr.Read()) { model.ReportGroupingCategoriesDetail.Add(new PlanReportGroupingCategory() { CategoryId = (int)rdr["CategoryID"], Category = rdr["Category"].ToString(), ShortTitle = rdr["ShortTitle"].ToString(), Description = rdr["Description"].ToString() }); model.ReportGroupingCategories.Add((int)rdr["CategoryID"], rdr["Category"].ToString()); } } return model; }
public void UpdateFinancialRecord(Funding model) { using (SqlCommand command = new SqlCommand("[RTP].[UpdateFunding]") { CommandType = CommandType.StoredProcedure }) { command.Parameters.AddWithValue("@ProjectVersionId", model.ProjectVersionId); command.Parameters.AddWithValue("@ConstantCost", model.ConstantCost > 0 ? (object)model.ConstantCost : (object)DBNull.Value); command.Parameters.AddWithValue("@VisionCost", model.VisionCost > 0 ? (object)model.VisionCost : (object)DBNull.Value); command.Parameters.AddWithValue("@YOECost", model.YOECost > 0 ? (object)model.YOECost : (object)DBNull.Value); command.Parameters.AddWithValue("@Future", model.Future > 0 ? (object)model.Future : (object)DBNull.Value); command.Parameters.AddWithValue("@Previous", model.Previous > 0 ? (object)model.Previous : (object)DBNull.Value); command.Parameters.AddWithValue("@TotalCost", model.TotalCost > 0 ? (object)model.TotalCost : (object)DBNull.Value); command.Parameters.AddWithValue("@PlanTypeId", model.PlanTypeId > 0 ? (object)model.PlanTypeId : (object)DBNull.Value); command.Parameters.AddWithValue("@ReportGroupingCategoryId", model.ReportGroupingCategoryId > 0 ? (object)model.ReportGroupingCategoryId : (object)DBNull.Value); this.ExecuteNonQuery(command); } }