1 public Entity.ResultObj GetCarTakRenl(string Imei, string start, string end, int page,int uid) 2 { 3 DataSet ds; 4 int RecordCount = 0; 5 int PageCount = 0; 6 int PageSize = 6; 7 string sqlwhere; 8 start = start.Replace("/", "-"); 9 end = end.Replace("/", "-"); 10 Model.Person.pmEquipmentMap m = eqBLL.GetModelList("Imei='" + Imei + "' and uid=" + uid + " and ParentUid=0").FirstOrDefault(); 11 if (m != null) 12 { 13 sqlwhere = "l.Imei='" + Imei + "' and l.CarState=2"; 14 if (start != "" || end != "") 15 sqlwhere += "and CONVERT(varchar(100), l.DateStart, 23)>='" + start + "' and CONVERT(varchar(100), l.DateEnd, 23)<='" + end + "' and TrackState=1"; 16 } 17 else 18 { 19 sqlwhere = "l.Imei='" + Imei + "'and l.uid=" + uid; 20 if (start != "" || end != "") 21 sqlwhere += "and CONVERT(varchar(100), l.DateStart, 23)>='" + start + "' and CONVERT(varchar(100), l.DateEnd, 23)<='" + end + "' and TrackState=1"; 22 } 23 cBLL.GetCarTktaList(page, PageSize, sqlwhere, out ds, out RecordCount, out PageCount); 24 Entity.carTrackLog ctk; 25 Dictionary<string, List<object>> lists = new Dictionary<string, List<object>>(); 26 List<object> datas = new List<object>(); 27 foreach (DataRow dr in ds.Tables[0].Rows) 28 { 29 List<object> list = new List<object>(); 30 string key = Convert.ToDateTime(dr["DateStart"]).ToString("yyyy-MM-dd"); 31 32 Datas dts = datas.Find(o => ((Datas)o).time == key) as Datas; 33 if (dts == null) 34 { 35 dts = new Datas(); 36 dts.time = key; 37 datas.Add(dts); 38 } 39 ctk = new Entity.carTrackLog(); 40 ctk.Id = Convert.ToInt32(dr["id"].ToString()); 41 ctk.Imei = dr["Imei"].ToString(); 42 43 if (!string.IsNullOrEmpty(dr["DateStart"]+"")) 44 ctk.DateStart = Convert.ToDateTime(dr["DateStart"]).ToString("yyyy-MM-dd HH:mm:ss"); 45 46 if (!string.IsNullOrEmpty(dr["DateEnd"]+"")) 47 ctk.DateEnd = Convert.ToDateTime(dr["DateEnd"]).ToString("yyyy-MM-dd HH:mm:ss"); 48 49 decimal Mileage; 50 if (decimal.TryParse(dr["Mileage"] + "", out Mileage)) 51 ctk.Mileage = Mileage; 52 else 53 ctk.Mileage = 0; 54 55 56 if (!string.IsNullOrEmpty(dr["Time"]+"")) 57 ctk.Time = Convert.ToInt32(dr["Time"]); 58 59 int Speed; 60 if (int.TryParse(dr["Speed"] + "", out Speed)) 61 ctk.Speed = Speed; 62 else 63 ctk.Speed = 0; 64 65 ctk.NickName = dr["NickName"].ToString(); 66 67 if (!string.IsNullOrEmpty(dr["DateCreated"]+"")) 68 ctk.DateCreated = Convert.ToDateTime(dr["DateCreated"]).ToString("yyyy-MM-dd HH:mm:ss"); 69 70 dts.lists.Add(ctk); 71 } 72 Entity.PageInfo p = new Entity.PageInfo(); 73 p.content = datas; 74 p.totalPages = PageCount; 75 p.totalElements = RecordCount; 76 return new Entity.ResultObj(true, p); 77 } 78 public class Datas 79 { 80 public string time; 81 public List<object> lists = new List<object>(); 82 }
C# 根据一个其中的一个值获取到对应的数据列表
猜你喜欢
转载自www.cnblogs.com/shanshuiYiCheng/p/10514725.html
今日推荐
周排行