コード例 #1
0
ファイル: Form1.cs プロジェクト: XenaMac/MTC
 private void LoadPlaybackByBeat()
 {
     try
     {
         gvData.DataSource = null;
         gvData.Rows.Clear();
         bool LogonOnly = false;
         if (chkLogon.Checked == true)
         {
             LogonOnly = true;
         }
         DateTime dtStart = Convert.ToDateTime(dtpStart.Text + " 00:00:00");
         DateTime dtEnd   = Convert.ToDateTime(dtpEnd.Text + " 23:59:59");
         SQLCode  mySQL   = new SQLCode();
         mySQL.LoadTrackingDataByBeat(cboBeats.Text, dtStart, dtEnd, LogonOnly);
         gvData.DataSource = GlobalData.allTrack;
         GPSTrack firstTrack = GlobalData.allTrack[0];
         gMapControl1.Position = new PointLatLng(firstTrack.Lat, firstTrack.Lon);
         gMapControl1.Overlays.Clear();
         GMapOverlay           overlay = new GMapOverlay(gMapControl1, "base");
         GMapMarkerGoogleGreen home    = new GMapMarkerGoogleGreen(new PointLatLng(firstTrack.Lat, firstTrack.Lon));
         overlay.Markers.Add(home);
         gMapControl1.Overlays.Add(overlay);
         iEventCount = GlobalData.allTrack.Count - 1;
         foreach (DataGridViewRow row in gvData.Rows)
         {
             row.DefaultCellStyle.BackColor = Color.White;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: XenaMac/MTC
        private void PlaybackTickTock()
        {
            GPSTrack currentTrack = GlobalData.allTrack[iNum];

            gMapControl1.Position = new PointLatLng(currentTrack.Lat, currentTrack.Lon);
            if (chkLeaveTrail.Checked == false)
            {
                gMapControl1.Overlays.Clear();
            }
            GMapOverlay           overlay = new GMapOverlay(gMapControl1, "base");
            GMapMarkerGoogleGreen home    = new GMapMarkerGoogleGreen(new PointLatLng(currentTrack.Lat, currentTrack.Lon));

            overlay.Markers.Add(home);
            gMapControl1.Overlays.Add(overlay);
            foreach (DataGridViewRow row in gvData.Rows)
            {
                if (Convert.ToInt32(row.Cells[0].Value) == iNum)
                {
                    row.DefaultCellStyle.BackColor = Color.Red;
                }
                else if (Convert.ToInt32(row.Cells[0].Value) < iNum)
                {
                    row.DefaultCellStyle.BackColor = Color.Gray;
                }
            }
        }
コード例 #3
0
ファイル: SQLCode.cs プロジェクト: XenaMac/MTC
        public void LoadTrackingDataByBeat(string BeatNumber, DateTime dtStart, DateTime dtEnd, bool OnlyLoggedOn)
        {
            try
            {
                GlobalData.allTrack.Clear();
                using (SqlConnection conn = new SqlConnection(strConn))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("GetPlaybackByBeat", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    int LogonVal = 0;
                    if (OnlyLoggedOn == true)
                    {
                        LogonVal = 1;
                    }

                    cmd.Parameters.AddWithValue("@BeatNumber", BeatNumber);
                    cmd.Parameters.AddWithValue("@dtStart", dtStart.ToString());
                    cmd.Parameters.AddWithValue("@dtEnd", dtEnd.ToString());
                    cmd.Parameters.AddWithValue("@logonOnly", LogonVal.ToString());
                    cmd.CommandTimeout = 0;
                    SqlDataReader rdr = cmd.ExecuteReader();
                    int           i   = 0;
                    while (rdr.Read())
                    {
                        GPSTrack thisGPS = new GPSTrack();
                        thisGPS.ID                  = i;
                        thisGPS.Direction           = double.Parse(rdr["Direction"].ToString());
                        thisGPS.VehicleStatus       = rdr["VehicleStatus"].ToString();
                        thisGPS.timeStamp           = Convert.ToDateTime(rdr["timeStamp"].ToString());
                        thisGPS.VehicleID           = rdr["VehicleID"].ToString();
                        thisGPS.Speed               = double.Parse(rdr["Speed"].ToString());
                        thisGPS.DriverName          = rdr["Driver Name"].ToString();
                        thisGPS.ContractCompanyName = rdr["ContractCompanyName"].ToString();
                        thisGPS.IPAddress           = rdr["IPAddress"].ToString();
                        thisGPS.Lat                 = double.Parse(rdr["Lat"].ToString());
                        thisGPS.Lon                 = double.Parse(rdr["Lon"].ToString());
                        thisGPS.SpeedingValue       = double.Parse(rdr["SpeedingValue"].ToString());
                        thisGPS.SpeedingTime        = Convert.ToDateTime(rdr["SpeedingTime"].ToString());
                        thisGPS.OutOfBoundsMessage  = rdr["OutofBoundsMessage"].ToString();
                        thisGPS.BeatNumber          = rdr["Beat"].ToString();
                        i += 1;
                        GlobalData.allTrack.Add(thisGPS);
                    }
                    rdr.Close();
                    rdr = null;
                    cmd = null;
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: XenaMac/MTC
        void gvData_SelectionChanged(object sender, EventArgs e)
        {
            var gv = (DataGridView)sender;

            foreach (DataGridViewRow row in gv.SelectedRows)
            {
                int      id           = Convert.ToInt32(row.Cells[0].Value);
                GPSTrack currentTrack = GlobalData.allTrack[id];
                gMapControl1.Position = new PointLatLng(currentTrack.Lat, currentTrack.Lon);
                gMapControl1.Overlays.Clear();
                GMapOverlay           overlay = new GMapOverlay(gMapControl1, "base");
                GMapMarkerGoogleGreen home    = new GMapMarkerGoogleGreen(new PointLatLng(currentTrack.Lat, currentTrack.Lon));
                overlay.Markers.Add(home);
                gMapControl1.Overlays.Add(overlay);
            }
        }