public void AfterEdit(string field, string oldValue, string newValue, VaoRaCaInfo oj) { try { if (oldValue != "") { bool check = true; string[] item = newValue.Split(':'); if (item.Length > 0) { if (int.Parse("0" + item[0]) > 24) { Dialog.ShowError("Giờ không hợp lệ"); check = false; } else if (int.Parse("0" + item[1]) > 59) { Dialog.ShowError("Phút không hợp lệ"); check = false; } else if (int.Parse("0" + item[2]) > 59) { Dialog.ShowError("Giây không hợp lệ"); check = false; } } if (check == true) { DAL.VaoRaCa data = new DAL.VaoRaCa(); data.MaChamCong = oj.MaChamCong; if (!SoftCore.Util.GetInstance().IsDateNull(dfNgayChamCong.SelectedDate)) { data.NgayChamCong = DateTime.Parse(dfNgayChamCong.SelectedDate.ToString("yyyy-MM-dd") + " " + oldValue); } data.Time = newValue; DateTime ngayChamCong = DateTime.Parse(dfNgayChamCong.SelectedDate.ToString("yyyy-MM-dd") + " " + newValue); new VaoRaCaController().UpdateTime(data, oldValue, ngayChamCong); Store1.CommitChanges(); } else { Store1.CommitChanges(); this.grpVaoRaCa.Reload(); } } } catch (Exception ex) { Dialog.ShowError(ex.Message); } }
protected void tt(object sender, DirectEventArgs e) { Ext.Net.ChangeRecords <EXAM_RESULT_LOG> sdh = new StoreDataHandler(e.ExtraParams["data"]).BatchObjectData <EXAM_RESULT_LOG>(); foreach (EXAM_RESULT_LOG created in sdh.Created) { created.EXAM_DATE = created.EXAM_DATE.Substring(0, 10); Common._NotificationShow("新增<br>" + created.EXAM_DATE + "<br>" + created.EXAM_NO + "<br>" + created.EXAM_RESULT); string sSQL = ""; sSQL = "INSERT INTO zinfo_a_diag (EXAM_DATE, EXAM_NO, EXAM_RESULT, EXAM_DOCTOR, EXAM_HOSPITAL, KIN_DATE, KIN_USER, PAT_NO) " + "VALUE ('" + created.EXAM_DATE.Substring(0, 10) + "', " + "'" + created.EXAM_NO + "', " + "'" + created.EXAM_RESULT + "', " + "'" + created.EXAM_DOCTOR + "', " + "'" + created.EXAM_HOSPITAL + "', " + "'" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', " + "'" + _UserID + "', " + "'" + _PAT_ID + "')"; db.Excute(sSQL); created.NEW_ID = null; } foreach (EXAM_RESULT_LOG updated in sdh.Updated) { updated.EXAM_DATE = updated.EXAM_DATE.Substring(0, 10); Common._NotificationShow("修改<br>" + updated.EXAM_DATE + "<br>" + updated.EXAM_NO + "<br>" + updated.EXAM_RESULT); string sSQL = ""; sSQL = "UPDATE zinfo_a_diag " + "SET EXAM_DATE='" + updated.EXAM_DATE.Substring(0, 10) + "', " + "EXAM_NO='" + updated.EXAM_NO + "', " + "EXAM_RESULT='" + updated.EXAM_RESULT + "', " + "EXAM_DOCTOR='" + updated.EXAM_DOCTOR + "', " + "EXAM_HOSPITAL='" + updated.EXAM_HOSPITAL + "', " + "KIN_DATE='" + System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', " + "KIN_USER='******', " + "PAT_NO='" + _PAT_ID + "' " + "WHERE ROW_ID=" + updated.ROW_ID.ToString() + " "; db.Excute(sSQL); } //似乎無此刪除功能 foreach (EXAM_RESULT_LOG deleted in sdh.Deleted) { Common._NotificationShow("删除<br>" + deleted.EXAM_DATE + "<br>" + deleted.EXAM_NO + "<br>" + deleted.EXAM_RESULT); string sSQL = ""; sSQL = "DELETE FROM zinfo_a_diag WHERE ROW_ID=" + deleted.ROW_ID.ToString() + " "; db.Excute(sSQL); } Store1.CommitChanges(); }
protected void cmdSAVE(object sender, DirectEventArgs e) { string sSQL = ""; string GroupUsed = "N"; ChangeRecords <ITEM_GROUP> sdh = new StoreDataHandler(e.ExtraParams["data"]).BatchObjectData <ITEM_GROUP>(); foreach (ITEM_GROUP updated in sdh.Created) { if (updated.USED.ToString() == "true") { GroupUsed = "Y"; } sSQL = "INSERT INTO a_item_group "; sSQL += "(GROUP_CODE, GROUP_NAME, GROUP_NAME_E, GROUP_CLASS, GROUP_USED) "; sSQL += "VALUES ('" + updated.GROUP_CODE + "', "; sSQL += "'" + updated.GROUP_NAME + "', "; sSQL += "'" + updated.GROUP_NAME_E + "', "; sSQL += "'" + updated.GROUP_CLASS + "', "; sSQL += "'" + GroupUsed + "') "; db.Excute(sSQL); } foreach (ITEM_GROUP updated in sdh.Updated) { if (updated.USED.ToString() == "true") { GroupUsed = "Y"; } sSQL = "UPDATE a_item_group "; sSQL += "SET GROUP_NAME='" + updated.GROUP_NAME + "', "; sSQL += "GROUP_NAME_E='" + updated.GROUP_NAME_E + "', "; sSQL += "GROUP_CLASS='" + updated.GROUP_CLASS + "', "; sSQL += "GROUP_USED='" + GroupUsed + "' "; sSQL += "WHERE GROUP_CODE='" + updated.GROUP_CODE + "'; "; db.Excute(sSQL); } Store1.CommitChanges(); Store1.Reload(); btnCancel.Disabled = true; btnSave.Disabled = true; btnDelete.Disabled = true; btnAdd.Disabled = false; }
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(); } } } } }
public void AfterEdit(string field, string oldValue, string newValue, TongHopCongTheoNgayInfo oj) { try { if (oldValue != "" && field.Substring(0, 3) == "Lan") { bool check = true; string[] item = newValue.Split(':'); if (item.Length != 3) { Dialog.ShowError("Dữ liệu cập nhật không hợp lệ."); check = false; } else //if (int.Parse("0" + item[0]) > 24m || item[0] == "") //{ // Dialog.ShowError("Giờ không hợp lệ"); // check = false; //} //else if (int.Parse("0" + item[1]) > 59 || item[1] == "") { Dialog.ShowError("Phút không hợp lệ"); check = false; } else if (int.Parse("0" + item[2]) > 59 || item[2] == "") { Dialog.ShowError("Giây không hợp lệ"); check = false; } if (check == true) { DAL.VaoRaCa data = new DAL.VaoRaCa(); data.MaChamCong = oj.MaChamCong; if (!SoftCore.Util.GetInstance().IsDateNull(dfNgayChamCong.SelectedDate)) { data.NgayChamCong = DateTime.Parse(dfNgayChamCong.SelectedDate.ToString("yyyy-MM-dd")); } data.Time = newValue; if (int.Parse("0" + item[0]) > 24m || item[0] == "") { newValue = "23:59:00"; } DateTime ngayChamCong = DateTime.Parse(dfNgayChamCong.SelectedDate.ToString("yyyy-MM-dd") + " " + newValue); new VaoRaCaController().UpdateTime(data, oldValue, ngayChamCong); Store1.CommitChanges(); } else { Store1.CommitChanges(); this.grpVaoRaCa.Reload(); } } else { if (string.IsNullOrEmpty(newValue) && string.IsNullOrEmpty(oldValue)) { Store1.CommitChanges(); } else { if (string.IsNullOrEmpty(newValue) && field != "KyHieuChamCong" && field != "GhiChu") { newValue = "0"; } else if (string.IsNullOrEmpty(newValue) && (field == "KyHieuChamCong" || field == "GhiChu")) { newValue = ""; } new TongHopCongTheoNgayController().Update(oj.ID, field, newValue); Store1.CommitChanges(); } } } catch (Exception ex) { Dialog.ShowError(ex.Message); } }
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(); } } } } }