private CropDataType DataRow2CropData(DataRow dr) { CropDataType cropdata = new CropDataType { SoilNum = dr[SoilTypeColumnName].ToString(), CropName = dr[CropNameColumnName].ToString(), Year = int.Parse(dr[YearColumnName].ToString()), Month = int.Parse(dr[MonthColumnName].ToString()), AmtKg = double.Parse(dr[AmountColumnName].ToString()) }; if (nitrogenColumnExists) { cropdata.Npct = double.Parse(dr[PercentNitrogenColumnName].ToString(), CultureInfo.InvariantCulture); } else { cropdata.Npct = double.NaN; } if (harvestTypeColumnExists) { cropdata.HarvestType = dr[HarvestTypeColumnName].ToString(); } cropdata.HarvestDate = new DateTime(cropdata.Year, cropdata.Month, 1); return(cropdata); }
private CropDataType DataRow2CropData(DataRow dr) { CropDataType cropdata = new CropDataType { SoilNum = dr[SoilTypeColumnName].ToString(), CropName = dr[CropNameColumnName].ToString(), Year = int.Parse(dr[YearColumnName].ToString()), Month = int.Parse(dr[MonthColumnName].ToString()), AmtKg = double.Parse(dr[AmountColumnName].ToString(), CultureInfo.InvariantCulture) }; //Npct column is optional //Only try to read it in if it exists in the file. if (nitrogenPercentIndex != -1) { cropdata.Npct = double.Parse(dr[PercentNitrogenColumnName].ToString(), CultureInfo.InvariantCulture); } else { cropdata.Npct = double.NaN; } cropdata.HarvestDate = new DateTime(cropdata.Year, cropdata.Month, 1); return(cropdata); }
private CropDataType DataRow2CropData(DataRow dr) { CropDataType cropdata = new CropDataType { SoilNum = dr["SoilNum"].ToString(), CropName = dr["CropName"].ToString(), Year = int.Parse(dr["Year"].ToString()), Month = int.Parse(dr["Month"].ToString()), AmtKg = double.Parse(dr["AmtKg"].ToString()) }; //Npct column is optional //Only try to read it in if it exists in the file. if (nitrogenPercentIndex != -1) { cropdata.Npct = double.Parse(dr["Npct"].ToString()); } else { cropdata.Npct = double.NaN; } cropdata.HarvestDate = new DateTime(cropdata.Year, cropdata.Month, 1); return(cropdata); }