protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            csc = new CrossSlopeChange("Data Source=Localhost;database=RoadCenter;User ID=admin;Password=admin123");
            //调用Databind方法
            Databind();
            //读取传参
            Route.Text = Request.Cookies["RouteID"].Value;
        }
        if (IsPostBack)
        {
            csc = new CrossSlopeChange("Data Source=Localhost;database=RoadCenter;User ID=admin;Password=admin123");
        }

        if (this.CrossSlopeChange.SelectedIndex > -1)
        {
            // 调用GridView的UpdateRow方法
            this.CrossSlopeChange.UpdateRow(this.CrossSlopeChange.SelectedIndex, false);
        }
    }
 /// <summary>                                                          
 /// 横坡变化Csv文件查询结果转换成泛型集合                                         
 /// </summary>                                                                            
 /// <param name="filePath">文件路径</param>                         
 /// <returns>以实体类为元素的泛型集合</returns>
 public List<CrossSlopeChange> ImportCrossSlopeChangeList(string filePath)
 {
     List<CrossSlopeChange> csc = new List<CrossSlopeChange>();
     StreamReader fileReader = new StreamReader(filePath, Encoding.Default);
     try
     {
         //列之间的分隔符
         char cv = ',';
         while (fileReader.EndOfStream == false)
         {
             CrossSlopeChange t = new CrossSlopeChange();
             string line = fileReader.ReadLine();
             string[] y = line.Split(cv);
             t.Stake = y[0].Trim().ToString();
             t.LeftSoilShoulder = Convert.ToDouble(y[1].Trim().ToString());
             t.LeftHardShoulder = Convert.ToDouble(y[2].Trim().ToString());
             t.LeftCarriageway = Convert.ToDouble(y[3].Trim().ToString());
             t.LeftMiddle = Convert.ToDouble(y[4].Trim().ToString());
             t.RightMiddle = Convert.ToDouble(y[5].Trim().ToString());
             t.RightCarriageway = Convert.ToDouble(y[6].Trim().ToString());
             t.RightHardShoulder = Convert.ToDouble(y[7].Trim().ToString());
             t.RightSoilShoulder = Convert.ToDouble(y[8].Trim().ToString());
             t.Remarks = y[9].Trim().ToString();
             csc.Add(t);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         fileReader.Close();
         fileReader.Dispose();
     }
     return csc;
 }
 protected void import_Click(object sender, EventArgs e)
 {
     if (file.HasFile == false)// 判断fileupload是否有指定文件
     {
         Response.Write("<script>alert('请您选择Excel文件')</script>");
         return;//当无文件时,返回
     }
     string filename = file.PostedFile.FileName;
     List<CrossSlopeChange> csc = new List<CrossSlopeChange>();
     CsvFileImport cfi = new CsvFileImport();
     csc = cfi.ImportCrossSlopeChangeList(filename);
 }
 /// <summary>
 /// 加载横坡变化 
 /// </summary>
 /// <param name="RouteID"></param>
 /// <returns></returns>
 public List<CrossSlopeChange> Load(int RouteID)
 {
     List<CrossSlopeChange> list = new List<CrossSlopeChange>();
     if (DbConnection == null) return null;
     string sql = @"select *from RDC_CrossSlopeChange where RouteID='" + RouteID + "'";
     DataSet ds = DbConnection.GetDataSet(sql);
     foreach (DataRow r in ds.Tables[0].Rows)
     {
         CrossSlopeChange csc = new CrossSlopeChange();
         csc.CrossSlopeChangeID = (int)(r["CrossSlopeChangeID"]);
         csc.RouteID = r["RouteID"] == DBNull.Value ? 0 : Convert.ToInt32(r["RouteID"]);
         csc.SerialNumber = r["SerialNumber"] == DBNull.Value ? 0 : Convert.ToInt32(r["SerialNumber"]);
         csc.Stake = r["Stake"].ToString();
         csc.LeftSoilShoulder = r["LeftSoilShoulder"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftSoilShoulder"]);
         csc.LeftHardShoulder = r["LeftHardShoulder"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftHardShoulder"]);
         csc.LeftCarriageway = r["LeftCarriageway"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftCarriageway"]);
         csc.LeftMiddle = r["LeftMiddle"] == DBNull.Value ? 0 : Convert.ToDouble(r["LeftMiddle"]);
         csc.RightMiddle = r["RightMiddle"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightMiddle"]);
         csc.RightCarriageway = r["RightCarriageway"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightCarriageway"]);
         csc.RightHardShoulder = r["RightHardShoulder"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightHardShoulder"]);
         csc.RightSoilShoulder = r["RightSoilShoulder"] == DBNull.Value ? 0 : Convert.ToDouble(r["RightSoilShoulder"]);
         csc.Remarks = r["Remarks"].ToString();
         list.Add(csc);
     }
     return list;
 }