public void ClearPatLookup(object sender, EventArgs e) { txtSearch.Text = String.Empty; Store1.RemoveAll(); Store1.DataBind(); }
public void bindUser() { stulist.Add(new EB_Student() { Id = "001", Name = "张三", Course = "英语", Address = "海珠区", Tel = "13526201350" }); stulist.Add(new EB_Student() { Id = "002", Name = "李四", Course = "数学", Address = "白云区", Tel = "15236865280" }); stulist.Add(new EB_Student() { Id = "003", Name = "王五", Course = "金融", Address = "天河区", Tel = "13524680888" }); stulist.Add(new EB_Student() { Id = "004", Name = "陆六", Course = "法语", Address = "番禺区", Tel = "15625523666" }); stulist.Add(new EB_Student() { Id = "005", Name = "陈七", Course = "中医", Address = "越秀区", Tel = "14586856285" }); stulist.Add(new EB_Student() { Id = "006", Name = "赵八", Course = "法律", Address = "荔湾区", Tel = "15299665533" }); stulist.Add(new EB_Student() { Id = "007", Name = "钱九", Course = "材料", Address = "南沙区", Tel = "13624562563" }); Store1.RemoveAll(); Store1.DataSource = stulist; Store1.DataBind(); }
protected void Apply_Click(object sender, DirectEventArgs e) { try { if (ApprovalStatusId.SelectedItem.Value == null && DamageLevelId.SelectedItem.Value == null && justification.Text == "") { if (ApprovalStatusId.SelectedItem.Value == null) { X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("SelectApproval")).Show(); return; } else if (DamageLevelId.SelectedItem.Value == null) { X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("SelectDamage")).Show(); return; } else if (justification.Text == null) { X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("FillJustification")).Show(); return; } } else { string rep_params = vals.Text; //ReportGenericRequest req = new ReportGenericRequest(); TVListRequest req = new TVListRequest(); req.paramString = rep_params; req.size = "5000"; req.startAt = "0"; req.sortBy = "date,employeeRef"; ListResponse <DashBoardTimeVariation3> daysResponse = _timeAttendanceService.ChildGetAll <DashBoardTimeVariation3>(req); if (!daysResponse.Success) { Common.errorMessage(daysResponse); return; } DashBoardTimeVariation b = new DashBoardTimeVariation(); if (daysResponse.Items.Count > 0) { daysResponse.Items.ForEach( x => { b.apId = x.apId; if (ApprovalStatusId.SelectedItem.Value == null) { b.apStatus = x.apStatus; b.apStatusString = x.apStatusString; } else { b.apStatus = Convert.ToInt16(ApprovalStatusId.SelectedItem.Value); b.apStatusString = ApprovalStatusId.SelectedItem.Text; } b.branchName = x.branchName; b.clockDuration = x.clockDuration; b.clockDurationString = x.clockDurationString; if (arId.SelectedItem.Value == null) { b.arId = x.arId; } else { b.arId = arId.SelectedItem.Value; } if (DamageLevelId.SelectedItem.Value == null) { b.damageLevel = x.damageLevel; b.damageLevelString = x.damageLevelString; } else { b.damageLevel = Convert.ToInt16(DamageLevelId.SelectedItem.Value); b.damageLevelString = DamageLevelId.SelectedItem.Text; } b.date = x.date; b.dayId = x.dayId; b.dayIdDate = x.dayIdDate; b.dayIdString = x.dayIdString; b.dtFrom = x.dtFrom; b.dtTo = x.dtTo; b.duration = x.duration; b.durationString = x.durationString; b.employeeId = x.employeeId; b.employeeName = x.employeeName; b.employeeRef = x.employeeRef; if (justification.Text == "") { b.justification = x.justification; } else { b.justification = justification.Text; } b.positionName = x.positionName; //b.primaryKey = x.primaryKey; b.recordId = x.recordId; b.shiftId = x.shiftId; b.timeCode = x.timeCode; b.timeCodeString = x.timeCodeString; PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>(); request.entity = b; PostResponse <DashBoardTimeVariation> response = _timeAttendanceService.ChildAddOrUpdate <DashBoardTimeVariation>(request); if (!response.Success) //it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } } ); //ReloadData(new object(), new DirectEventArgs(new Ext.Net.ParameterCollection())); } } } catch (Exception exp) { X.MessageBox.Alert(Resources.Common.Error, exp.Message); } //ReloadData(new object(), new DirectEventArgs(new Ext.Net.ParameterCollection())); Store1.RemoveAll(); }
protected void HistoriqueTrajet(object sender, EventArgs e) { string userDate1 = this.DateField1.Value.ToString(); string[] du = userDate1.Split(' '); userDate1 = du[0] + " " + this.TimeField1.Value.ToString(); string userDate2 = this.DateField2.Value.ToString(); string[] du2 = userDate2.Split(' '); userDate2 = du2[0] + " " + this.TimeField2.Value.ToString(); string vehiculeid = ""; vehiculeid = this.MultiCombo1.SelectedItem.Value; if (vehiculeid == "" || userDate1 == "" || userDate2 == "") { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Veuillez choisir un véhicule, une date début et une date fin pour consulter les trajets", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { TimeSpan k = DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) - DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (k.TotalDays <= 0) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "La date début doit être inferieure à la date fin", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { string _reqTime = "select * from(select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid desc) a union select * from (select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid )b "; SqlDataReader drT = Select(_reqTime); int m = 0; while (drT.Read()) { du[m] = drT[0].ToString(); m++; } drT.Close(); DateTime dsup = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime dinf = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (dsup < dinf) { dinf = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); dsup = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); } if (DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf || DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup || DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf || DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Les dates début et fin doivent être comprises entre " + dinf + " et " + dsup, Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { int Compt = 0; int vites = 0; string c = ""; string _reqlist = "select d.GPSDateTime,d.latitude,d.longitude ,p.nom+' '+p.prenom as conducteur,d.speed ,d.contact,d.Odometer,d.adress from Datatracker d inner join boitier b on b.imei=d.imei inner join affectation_vehicule_boitier abv on abv.boitierid=b.boitierid inner join vehicules v on v.vehiculeid = abv.vehiculeid inner join vehicule_personnel vp on vp.vehiculeid=v.vehiculeid inner join personnel p on p.personnelid=vp.personnelid where cast(d.GPSDateTime AS datetime) >= '" + userDate1 + "' AND cast(d.GPSDateTime AS datetime) < '" + userDate2 + "' and v.vehiculeid='" + vehiculeid + "' order by cast(d.GPSDateTime AS datetime)"; SqlDataReader drlist = Select(_reqlist); int ve = 0; int tr = 0; while (drlist.Read()) { Datatracker t = new Datatracker(); t.contact = Convert.ToInt32(drlist[5]); t.GPSDateTime = drlist[0].ToString(); t.latitude = (double)drlist[1]; t.longitude = (double)drlist[2]; t.speed = (int)drlist[4]; c = drlist[3].ToString(); t.Odometer = (int)drlist[6]; t.adress = drlist[7].ToString(); List.Add(t); } drlist.Close(); for (int s = 0; s < List.Count; s++) { if (List[s].contact == 1) { tr++; if (tr == 1) { Listtrack = new List <Datatracker>(); } Listtrack.Add(List[s]); vites += (int)List[s].speed; ve = 0; } if (List[s].contact == 0) { ve++; } if (ve == 1 && tr != 0) { Htrajet tt = new Htrajet(); tt.setposition(Listtrack); tt.setConducteur(c); tt.Setvehicule(vehiculeid); tt.SetDateD(DateTime.ParseExact(tt.position[0].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); tt.SetDateF(DateTime.ParseExact(tt.position[tt.position.Count - 1].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); tt.vitesse = vites / (tt.position.Count); vites = 0; tt.setkm((int)(tt.position[tt.position.Count - 1].Odometer - tt.position[0].Odometer) / 10); Listtrajet.Add(tt); tr = 0; } if (s == List.Count - 1 && ve == 0) { Htrajet tt = new Htrajet(); tt.setposition(Listtrack); tt.setConducteur(c); tt.Setvehicule(vehiculeid); tt.SetDateD(DateTime.ParseExact(tt.position[0].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); tt.SetDateF(DateTime.ParseExact(tt.position[tt.position.Count - 1].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); tt.vitesse = vites / (tt.position.Count - 1); vites = 0; tt.setkm((double)(((double)(tt.position[tt.position.Count - 1].Odometer) - (double)(tt.position[0].Odometer))) / 10); Listtrajet.Add(tt); } } List <object> lo = new List <object>(); if (Listtrajet.Count == 0) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Aucun trajet n'a été parcouru", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { Store1.RemoveAll(); //Store Store1 = this.GridPanelVoyage.GetStore(); DateTime d1 = DateTime.ParseExact(DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss.fff"), "dd'/'MM'/'yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture); for (int i = 0; i < Listtrajet.Count; i++) { if (i % 4 == 0 && i >= 4) { System.Threading.Thread.Sleep(1000); //DateTime d2 = DateTime.ParseExact(DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss.fff"), "dd'/'MM'/'yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture); //TimeSpan t = d2 - d1; //int ms = (int)t.TotalMilliseconds; //if (ms < 999) //{ // System.Threading.Thread.Sleep((1000 -ms)+5); //} //d1 = DateTime.ParseExact(DateTime.Now.ToString("dd'/'MM'/'yyyy HH:mm:ss.fff"), "dd'/'MM'/'yyyy HH:mm:ss.fff", CultureInfo.InvariantCulture); } DateTime d = DateTime.ParseExact(Listtrajet[i].GetDateD().ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime dd = DateTime.ParseExact(Listtrajet[i].GetDateF().ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); //string lat = Listtrajet[i].position[0].latitude.ToString().Replace(",", "."); //string lng = Listtrajet[i].position[0].longitude.ToString().Replace(",", "."); //string adrD,adrF; // string adr1 = RetrieveFormatedAddress(lat, lng); // if (adr1.Contains("<formatted_address>")) // { // adr1 = adr1.Replace("<formatted_address>", "*"); // adr1 = adr1.Replace("</formatted_address>", "*"); // string[] s = adr1.Split('*'); // adrD = s[1]; // } // else // { // adrD = "pas d'adresse"; // } // // string adrF = RetrieveFormatedAddress("33.5992364201655", "-7.570799214941417"); // lat = Listtrajet[i].position[Listtrajet[i].position.Count - 1].latitude.ToString().Replace(",", "."); // lng = Listtrajet[i].position[Listtrajet[i].position.Count - 1].longitude.ToString().Replace(",", "."); // string adr11 = RetrieveFormatedAddress(lat, lng); // if (adr11.Contains("<formatted_address>")) // { // adr11 = adr11.Replace("<formatted_address>", "*"); // adr11 = adr11.Replace("</formatted_address>", "*"); // string[] ss = adr11.Split('*'); // adrF = ss[1]; // } // else // { // adrF = "pas d'adresse"; // } // Address[] addresses = geoCoder.ReverseGeoCode(38.8976777, -77.036517); TimeSpan duree = dd - d; string polyline = " "; for (int p = 0; p < Listtrajet[i].position.Count - 1; p++) { polyline += "new google.maps.LatLng(" + Listtrajet[i].position[p].latitude.ToString().Replace(",", ".") + "," + Listtrajet[i].position[p].longitude.ToString().Replace(",", ".") + ");"; } polyline += "new google.maps.LatLng(" + Listtrajet[i].position[Listtrajet[i].position.Count - 1].latitude.ToString().Replace(",", ".") + "," + Listtrajet[i].position[Listtrajet[i].position.Count - 1].longitude.ToString().Replace(",", ".") + ")"; object[] test = new object[12]; test[0] = vehiculeid; test[1] = c; test[2] = Listtrajet[i].position[0].adress.ToString(); test[3] = Listtrajet[i].position[0].GPSDateTime; test[4] = Listtrajet[i].position[Listtrajet[i].position.Count - 1].adress.ToString(); test[5] = Listtrajet[i].position[Listtrajet[i].position.Count - 1].GPSDateTime; test[6] = duree.ToString(); test[7] = Listtrajet[i].vitesse + " Km/H"; test[8] = polyline; test[9] = color[col]; test[10] = Listtrajet[i].km + " Km"; //{ c, "adrD", Listtrajet[i].position[0].GPSDateTime, "adrF", Listtrajet[i].position[Listtrajet[i].position.Count - 1].GPSDateTime, duree.ToString(), Listtrajet[i].vitesse + " Km/H", polyline, color[col], Listtrajet[i].km + " Km" }; lo.Add(test); // lo.Add(new object[] { c, adrD, Listtrajet[i].position[0].GPSDateTime, adrF, Listtrajet[i].position[Listtrajet[i].position.Count - 1].GPSDateTime, duree.ToString(), Listtrajet[i].vitesse + " Km/H", polyline, color[col], Listtrajet[i].km + " Km" } // ); // //Rows[i].Cells[j].Value = image_matric[i, j].monChamp; // Ext.Net.Column newCol = new Ext.Net.Column //{ //}; // newCol.AddCls("background-color :"+color[col]); // GridPanelVoyage.ColumnModel.Add(newCol); Column11.AddCls("background-color :" + color[col]); Column11.TdCls = "background-color :" + color[col]; if (col == 9) { col = 0; } else { col++; } } Store1.Add(lo); Store1.CommitChanges(); } } } } }
protected void HistoriqueArret(object sender, EventArgs e) { string userDate1 = this.DateField1.Value.ToString(); string[] du = userDate1.Split(' '); userDate1 = du[0] + " " + this.TimeField1.Value.ToString(); string userDate2 = this.DateField2.Value.ToString(); string[] du2 = userDate2.Split(' '); userDate2 = du2[0] + " " + this.TimeField2.Value.ToString(); string vehiculeid = ""; vehiculeid = this.MultiCombo1.SelectedItem.Value; if (vehiculeid == "" || userDate1 == "" || userDate2 == "") { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Veuillez choisir un véhicule, une date début et une date fin pour consulter les trajets", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { TimeSpan k = DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) - DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (k.TotalDays <= 0) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "La date début doit être inferieure à la date fin", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { string _reqTime = "select * from(select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid desc) a union select * from (select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid )b "; SqlDataReader drT = Select(_reqTime); int m = 0; while (drT.Read()) { du[m] = drT[0].ToString(); m++; } drT.Close(); DateTime dsup = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime dinf = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (dsup < dinf) { dinf = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); dsup = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); } if (DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf || DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup || DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf || DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Les dates début et fin doivent être comprises entre " + dinf + " et " + dsup, Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { int Compt = 0; int vites = 0; string c = ""; string _reqlist = "select d.GPSDateTime,d.latitude,d.longitude ,p.nom+' '+p.prenom as conducteur,d.speed ,d.contact,d.adress from Datatracker d inner join boitier b on b.imei=d.imei inner join affectation_vehicule_boitier abv on abv.boitierid=b.boitierid inner join vehicules v on v.vehiculeid = abv.vehiculeid inner join vehicule_personnel vp on vp.vehiculeid=v.vehiculeid inner join personnel p on p.personnelid=vp.personnelid where cast(d.GPSDateTime AS datetime) >= '" + userDate1 + "' AND cast(d.GPSDateTime AS datetime) < '" + userDate2 + "' and v.vehiculeid='" + vehiculeid + "' order by cast(d.GPSDateTime AS datetime)"; SqlDataReader drlist = Select(_reqlist); int ve = 0; int tr = 0; // while (drlist.Read()) // { // Datatracker t = new Datatracker(); // t.contact = Convert.ToInt32(drlist[5]); // t.GPSDateTime = drlist[0].ToString(); // t.latitude = (double)drlist[1]; // t.longitude = (double)drlist[2]; // if (t.contact == 0) // { // tr++; // if (tr == 1) // { // arret = new Arret(); // arret.SetDateD(DateTime.ParseExact(t.GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); // arret.setlatitude(t.latitude.ToString()); // arret.setlongitude(t.longitude.ToString()); // } // } // if (t.contact == 1 ) // { // if (tr != 0) // { // arret.SetDateF(DateTime.ParseExact(t.GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); // ListArret.Add(arret); // tr = 0; // } // } // } //drlist.Close(); while (drlist.Read()) { Datatracker t = new Datatracker(); t.contact = Convert.ToInt32(drlist[5]); t.GPSDateTime = drlist[0].ToString(); t.latitude = (double)drlist[1]; t.longitude = (double)drlist[2]; t.adress = drlist[6].ToString();; List.Add(t); } drlist.Close(); for (int s = 0; s < List.Count; s++) { if (List[s].contact == 0) { tr++; if (tr == 1) { arret = new Arret(); arret.SetDateD(DateTime.ParseExact(List[s].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); arret.setlatitude(List[s].latitude.ToString()); arret.setlongitude(List[s].longitude.ToString()); arret.setadr(List[s].adress.ToString()); } } if (List[s].contact == 1) { if (tr != 0) { arret.SetDateF(DateTime.ParseExact(List[s].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); ListArret.Add(arret); tr = 0; } } if (s == List.Count - 1 && List[s].contact == 0) { if (tr != 0) { arret.SetDateF(DateTime.ParseExact(List[s].GPSDateTime, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture)); ListArret.Add(arret); tr = 0; } } } List <object> lo = new List <object>(); if (ListArret.Count == 0) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Aucun arrêt n'a été fait", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { Store1.RemoveAll(); //Store Store1 = this.GridPanelVoyage.GetStore(); for (int i = 0; i < ListArret.Count; i++) { //string lat = ListArret[i].latitude; //string lng = ListArret[i].longitude; //string lat1 = ListArret[i].latitude.Replace(",","."); //string lng1 = ListArret[i].longitude.Replace(",", "."); //string adr1 = RetrieveFormatedAddress(lat1, lng1); //adr1 = adr1.Replace("<formatted_address>", "*"); //adr1 = adr1.Replace("</formatted_address>", "*"); //string[] s = adr1.Split('*'); //string adr = s[1]; DateTime d = DateTime.ParseExact(ListArret[i].GetDateD().ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime dd = DateTime.ParseExact(ListArret[i].GetDateF().ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); // Address[] addresses = geoCoder.ReverseGeoCode(38.8976777, -77.036517); TimeSpan duree = dd - d; object[] test = new object[6]; test[0] = ListArret[i].adr.ToString(); test[1] = ListArret[i].dateD.ToShortDateString() + " " + ListArret[i].dateD.ToLongTimeString(); test[2] = duree.ToString(); test[3] = ListArret[i].dateF.ToShortDateString() + " " + ListArret[i].dateF.ToLongTimeString(); test[4] = ListArret[i].latitude; test[5] = ListArret[i].longitude; //{ c, "adrD", Listtrajet[i].position[0].GPSDateTime, "adrF", Listtrajet[i].position[Listtrajet[i].position.Count - 1].GPSDateTime, duree.ToString(), Listtrajet[i].vitesse + " Km/H", polyline, color[col], Listtrajet[i].km + " Km" }; lo.Add(test); // lo.Add(new object[] { adr, ListArret[i].dateD.ToShortDateString() + " " + ListArret[i].dateD.ToLongTimeString(), duree.ToString(), ListArret[i].latitude, ListArret[i].longitude } //); } Store1.Add(lo); Store1.CommitChanges(); } } } } }
protected void HistoriquePoi(object sender, EventArgs e) { string userDate1 = this.DateField1.Value.ToString(); string[] du = userDate1.Split(' '); userDate1 = du[0] + " " + this.TimeField1.Value.ToString(); string userDate2 = this.DateField2.Value.ToString(); string[] du2 = userDate2.Split(' '); userDate2 = du2[0] + " " + this.TimeField2.Value.ToString(); string vehiculeid = ""; vehiculeid = this.MultiCombo1.SelectedItem.Value; if (vehiculeid == "" || userDate1 == "" || userDate2 == "") { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Veuillez choisir un véhicule, une date début et une date fin pour consulter les trajets", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { TimeSpan k = DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) - DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (k.TotalDays <= 0) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "La date début doit être inferieure à la date fin", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { string _reqTime = "select * from(select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid desc) a union select * from (select top 1 d.RTCDateTime from Datatracker d order by d.datatrackerid )b "; SqlDataReader drT = Select(_reqTime); int m = 0; while (drT.Read()) { du[m] = drT[0].ToString(); m++; } drT.Close(); DateTime dsup = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime dinf = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); if (dsup < dinf) { dinf = DateTime.ParseExact(du[1], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); dsup = DateTime.ParseExact(du[0], "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); } if (DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf || DateTime.ParseExact(userDate1, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup || DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) < dinf || DateTime.ParseExact(userDate2, "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture) > dsup) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Les dates début et fin doivent être comprises entre " + dinf + " et " + dsup, Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { int Compt = 0; int vites = 0; string c = ""; string _reqlist = "select * from " + " (select p.libelle as poi, p.type_poi ,p.longitude as lng ,p.latitude as lat,GPSDateTime as date," + " per.prenom+' '+per.nom as conducteur," + " geography::STGeomFromText('POINT('+convert(varchar(20),p.longitude)+' '+convert(varchar(20),p.latitude)+')',4326).STBuffer(p.tolerance).STIntersects " + " (geography::STGeomFromText('POINT('+convert(varchar(20),d.longitude)+' '+convert(varchar(20),d.latitude)+')',4326).STBuffer(10)) as inter" + " from Poi p CROSS JOIN Datatracker d " + " inner join boitier b on b.imei=d.imei " + " inner join affectation_vehicule_boitier abv on abv.boitierid=b.boitierid" + " inner join vehicules v on v.vehiculeid = abv.vehiculeid " + " inner join vehicule_personnel vp on vp.vehiculeid=v.vehiculeid" + " inner join personnel per on per.personnelid=vp.personnelid" + " where cast(d.GPSDateTime AS datetime) >= '" + userDate1 + "' " + " AND cast(d.GPSDateTime AS datetime) < '" + userDate2 + "'and v.vehiculeid='" + vehiculeid + "'" + " and p.actif='1' and p.clientid='" + this.getCurrentUser().getClientId() + "' and p.userid ='" + this.getCurrentUser().getUserId() + "' and d.speed=0) aff where aff.inter=1 "; SqlDataReader drlist = Select(_reqlist); while (drlist.Read()) { Pois t = new Pois(); t.nom = drlist[0].ToString(); t.lat = drlist[3].ToString(); t.lng = drlist[2].ToString(); t.type = drlist[1].ToString(); t.cond = drlist[5].ToString(); t.dateD = drlist[4].ToString(); Listpoi.Add(t); } drlist.Close(); for (int i = 0; i < Listpoi.Count - 1; i++) { Pois p = new Pois(); p.dateD = Listpoi[i].dateD; int j; for (j = i; j < Listpoi.Count - 1 && Listpoi[j].lat == Listpoi[j + 1].lat && Listpoi[j].lng == Listpoi[j + 1].lng; j++) { ; } i = j; p.dateF = Listpoi[i].dateD; if (i == Listpoi.Count - 1) { p.dateF = Listpoi[i].dateD; } p.nom = Listpoi[i].nom; p.lat = Listpoi[i].lat; p.lng = Listpoi[i].lng; p.type = Listpoi[i].type; p.cond = Listpoi[i].cond; DateTime d = DateTime.ParseExact(p.dateD.ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); DateTime dd = DateTime.ParseExact(p.dateF.ToString(), "dd'/'MM'/'yyyy HH:mm:ss", CultureInfo.InvariantCulture); TimeSpan duree = dd - d; p.duree = duree.ToString(); ListpoiAff.Add(p); } List <object> lo = new List <object>(); if (ListpoiAff.Count == 0) { X.Msg.Show(new MessageBoxConfig { Title = Resources.Resource.Information, Message = "Aucun trajet n'a été parcouru", Buttons = MessageBox.Button.OK, Icon = MessageBox.Icon.INFO }); } else { Store1.RemoveAll(); for (int i = 0; i < ListpoiAff.Count; i++) { object[] test = new object[9]; test[0] = ListpoiAff[i].cond; test[1] = ListpoiAff[i].nom; test[2] = ListpoiAff[i].type; test[3] = ListpoiAff[i].dateD; test[4] = ListpoiAff[i].dateF; test[5] = ListpoiAff[i].duree; test[6] = ListpoiAff[i].lat; test[7] = ListpoiAff[i].lng; //{ c, "adrD", Listtrajet[i].position[0].GPSDateTime, "adrF", Listtrajet[i].position[Listtrajet[i].position.Count - 1].GPSDateTime, duree.ToString(), Listtrajet[i].vitesse + " Km/H", polyline, color[col], Listtrajet[i].km + " Km" }; lo.Add(test); // lo.Add(new object[] { ListpoiAff[i].cond, ListpoiAff[i].nom,ListpoiAff[i].type, ListpoiAff[i].dateD, ListpoiAff[i].dateF, ListpoiAff[i].duree, ListpoiAff[i].lat, ListpoiAff[i].lng } //); } Store1.Add(lo); Store1.CommitChanges(); } } } } }