public List <Fill_list> fill_area(string ulat, string ulon, string temp) { conn = new SqlConnection(cs); List <Fill_list> lst2 = new List <Fill_list>(); conn.Open(); ds = new DataSet(); SqlDataAdapter adp = new SqlDataAdapter("select Area_name,lat,lon from Area_master", conn); adp.Fill(ds, "Area_names"); conn.Close(); if (ds.Tables["Area_names"].Rows.Count > 0) { for (int i = 0; i < ds.Tables["Area_names"].Rows.Count; i++) { if (ds.Tables["Area_names"].Rows[i]["lat"].ToString() != String.Empty && ds.Tables["Area_names"].Rows[i]["lon"] != String.Empty) { double dlatitude = Convert.ToDouble(ds.Tables["Area_names"].Rows[i]["lat"]); double dlongitude = Convert.ToDouble(ds.Tables["Area_names"].Rows[i]["lon"]); var sCoord = new GeoCoordinate(Convert.ToDouble(ulat), Convert.ToDouble(ulon)); var eCoord = new GeoCoordinate(dlatitude, dlongitude); Fill_list objf_l = new Fill_list { a_name = ds.Tables["Area_names"].Rows[i]["Area_name"].ToString(), lat = ds.Tables["Area_names"].Rows[i]["lat"].ToString(), lon = ds.Tables["Area_names"].Rows[i]["lon"].ToString(), InformationDistance = sCoord.GetDistanceTo(eCoord) }; lst2.Add(objf_l); } } //return lst2; return(lst2.OrderBy(e => e.InformationDistance).ToList()); } else { return(lst2); } }
public List <Fill_list> fill_area_by(string byType) { conn = new SqlConnection(cs); List <Fill_list> lst2 = new List <Fill_list>(); conn.Open(); ds = new DataSet(); SqlDataAdapter adp; if (byType.Equals("Rating"))//or nos-number_of_slot { adp = new SqlDataAdapter("select Area_id,Area_name,lat,lon,case when avgrate is null then 0 else avgrate end as avgrate from Area_master as am left join (select areaid,avg(rating) avgrate from Rate_Master group by areaid) as avgtb on am.Area_id=avgtb.areaid order by avgrate desc", conn); } else { adp = new SqlDataAdapter("select Area_id, Area_name, total_slot as avgrate, lat, lon from Area_master order by total_slot desc", conn); } adp.Fill(ds, "Area_names"); conn.Close(); if (ds.Tables["Area_names"].Rows.Count > 0) { for (int i = 0; i < ds.Tables["Area_names"].Rows.Count; i++) { Fill_list objf_l = new Fill_list { a_name = ds.Tables["Area_names"].Rows[i]["Area_name"].ToString(), lat = ds.Tables["Area_names"].Rows[i]["lat"].ToString(), lon = ds.Tables["Area_names"].Rows[i]["lon"].ToString(), byValue = ds.Tables["Area_names"].Rows[i]["avgrate"].ToString() }; lst2.Add(objf_l); } return(lst2); } else { return(lst2); } }