예제 #1
0
 /// <summary>                                                          
 /// 征地线Csv文件查询结果转换成泛型集合                                         
 /// </summary>                                                                            
 /// <param name="filePath">文件路径</param>                         
 /// <returns>以实体类为元素的泛型集合</returns>
 public List<LandRequisitionLine> ImportLandRequisitionLineList(string filePath)
 {
     List<LandRequisitionLine> lrl = new List<LandRequisitionLine>();
     StreamReader fileReader = new StreamReader(filePath, Encoding.Default);
     try
     {
         //列之间的分隔符
         char cv = ',';
         while (fileReader.EndOfStream == false)
         {
             LandRequisitionLine t = new LandRequisitionLine();
             string line = fileReader.ReadLine();
             string[] y = line.Split(cv);
             t.Stake = y[0].Trim().ToString();
             t.Dist = Convert.ToDouble(y[1].Trim().ToString());
             lrl.Add(t);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         fileReader.Close();
         fileReader.Dispose();
     }
     return lrl;
 }
 /// <summary>
 /// 加载征地线
 /// </summary>
 /// <param name="RouteID"></param>
 /// <returns></returns>
 public List<LandRequisitionLine> Load(int RouteID)
 {
     if (DbConnection == null) return null;
     List<LandRequisitionLine> list = new List<LandRequisitionLine>();
     string sql = @"select *from RDC_LandRequisitionLine where RouteID='" + RouteID + "'";
     DataSet ds= DbConnection.GetDataSet(sql);
     foreach (DataRow r in ds.Tables[0].Rows)
     {
         LandRequisitionLine l = new LandRequisitionLine();
         l.LandRequisitionLineID = r["LandRequisitionLineID"] == DBNull.Value ? 0 : Convert.ToInt32(r["LandRequisitionLineID"]);
         l.RouteID= r["RouteID"] == DBNull.Value ? 0 : Convert.ToInt32(r["RouteID"]);
         l.Stake = r["Stake"].ToString();
         l.Dist = r["Dist"] == DBNull.Value ? 0 : Convert.ToDouble(r["Dist"]);
         list.Add(l);
     }
     return list;
 }