Example #1
0
 /// <summary>
 /// 转换表中的值
 /// </summary>
 /// <param name="dt"></param>
 /// <returns></returns>
 public static DataTable Convert_TableValue(DataTable dt)
 {
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         if (dt.Columns.Count == 4)                 //根据输出列数判断是否是Soil
         {
             if (dt.Columns[0].ColumnName == "作业站") //根据列名判断作物范围
             {
                 dt.Rows[i][0] = DataBaseOperate.getVillName(dt.Rows[i][0].ToString());
             }
             else if (dt.Columns[0].ColumnName == "作业区")
             {
                 dt.Rows[i][0] = DataBaseOperate.getTownName(dt.Rows[i][0].ToString());
             }
             dt.Rows[i][1] = ((DateTime)dt.Rows[i][1]).ToShortDateString();
             dt.Rows[i][2] = DataBaseOperate.get_CropCHName(dt.Rows[i][2].ToString());
             dt.Rows[i][3] = Math.Round((double)dt.Rows[i][3], 3);
         }
         else //soil
         {
             if (dt.Columns[0].ColumnName == "作业站")
             {
                 dt.Rows[i][0] = DataBaseOperate.getVillName(dt.Rows[i][0].ToString());
             }
             else if (dt.Columns[0].ColumnName == "作业区")
             {
                 dt.Rows[i][0] = DataBaseOperate.getTownName(dt.Rows[i][0].ToString());
             }
             dt.Rows[i][1] = ((DateTime)dt.Rows[i][1]).ToShortDateString();
             dt.Rows[i][2] = DataBaseOperate.get_CropCHName(dt.Rows[i][2].ToString());
             dt.Rows[i][3] = DataBaseOperate.get_NutrientCHName(dt.Rows[i][3].ToString());
             dt.Rows[i][4] = Math.Round((double)dt.Rows[i][4], 4);
         }
     }
     return(dt);
 }