コード例 #1
0
        private void frmDeviceAdd_Load(object sender, EventArgs e)
        {
            if (form_mode == FormMode.Add)
            {
                lblDesc.Text = "New Device";
                btnSave.Text = "&Save";
            }
            else
            {
                lblDesc.Text = "Edit Device";
                btnSave.Text = "&Update";

                string query = "SELECT * FROM devices" +
                               " WHERE id = '" + device_id + "'";
                DataTable dt = SqliteDal.getData(query);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        oldmcc        = dr["mcc"].ToString();
                        oldmnc        = dr["mnc"].ToString();
                        oldssi        = dr["ssi"].ToString();
                        txtMcc.Text   = oldmcc;
                        txtMnc.Text   = oldmnc;
                        txtSsi.Text   = oldssi;
                        txtImage.Text = dr["image"].ToString();
                    }
                }
            }
        }
コード例 #2
0
ファイル: frmDevice.cs プロジェクト: renciebautista/gmap
        private void bind_Devices()
        {
            DataTable dt = SqliteDal.getData("SELECT * FROM devices");

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.DataSource          = dt;


            ToggleAdd();
        }
コード例 #3
0
        private void plotTrain()
        {
            this.Text      = DateTime.Now.ToString();
            timer1.Enabled = false;

            List <PointLatLng> positions = new List <PointLatLng>();
            List <int>         list      = selected();

            #region Read File Data

            if (list.Count > 0)
            {
                string query = "SELECT * FROM logs" +
                               " inner join devices on devices.id = logs.device_id" +
                               " WHERE device_id IN(" + String.Join(",", list.ToArray()) + ") " +
                               " GROUP BY device_id ORDER BY id DESC";
                DataTable dt = SqliteDal.getData(query);

                foreach (DataRow row in dt.Rows) // Loop over the rows.
                {
                    PointLatLng p = new PointLatLng
                    {
                        Lat = float.Parse(row["lat"].ToString()),
                        Lng = float.Parse(row["lng"].ToString())
                    };

                    Image markerImage = Image.FromFile(config.MyDirectory() + @"\marker\" + row["image"].ToString());


                    /* Bitmap bmp = new Bitmap(markerImage.Width, markerImage.Height);
                     * using (Graphics g = Graphics.FromImage(bmp))
                     * {
                     *   g.Clear(Color.SkyBlue);
                     *   g.InterpolationMode = InterpolationMode.NearestNeighbor;
                     *   g.PixelOffsetMode = PixelOffsetMode.None;
                     *   g.DrawImage(markerImage, Point.Empty);
                     * }
                     */

                    GMapMarkerImage marker = new GMapMarkerImage(p, markerImage);
                    objects.Markers.Add(marker);

                    // marker.ToolTipMode = MarkerTooltipMode.Always; enable tooltip
                    marker.ToolTipText = row["subscriber_name"].ToString();
                }
            }
            MainMap.Refresh();
            #endregion
            timer1.Enabled = true;
        }
コード例 #4
0
        private void frmMap_Load(object sender, EventArgs e)
        {
            // Add a DataGridViewImageColumn to display the images
            DataGridViewImageColumn img = new DataGridViewImageColumn();

            img.Name = "Image";
            dataGridView1.Columns.Insert(2, img);
            dataGridView1.Columns[2].Width      = 60;
            dataGridView1.Columns[2].HeaderText = "Icon";

            DataTable dt = SqliteDal.getData("SELECT * FROM devices");

            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.DataSource          = dt;
        }
コード例 #5
0
ファイル: frmDevice.cs プロジェクト: renciebautista/gmap
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete this  record?", this.Text,
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                int id     = Int32.Parse(dataGridView1.CurrentRow.Cells["id"].Value.ToString());
                int retVal = SqliteDal.execNQ("DELETE FROM devices where id ='" + id + "'");
                if (retVal == 1)
                {
                    bind_Devices();
                }
                else
                {
                    MessageBox.Show("Erorr deleting record.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #6
0
        public void logDevice(Device device)
        {
            DataTable dt = SqliteDal.getData(string.Format("SELECT id FROM devices WHERE mcc='{0}' AND mnc='{1}' AND ssi='{2}' LIMIT 1", device.Mcc, device.Mnc, device.Ssi));

            if (dt.Rows.Count > 0)
            {
                using (SQLiteConnection conn = new SQLiteConnection(config.DataSource))
                {
                    using (SQLiteCommand cmd = new SQLiteCommand())
                    {
                        conn.Open();
                        cmd.Connection = conn;

                        SQLiteHelper sh = new SQLiteHelper(cmd);

                        try
                        {
                            var d = new Dictionary <string, object>();
                            d["device_id"]          = Int32.Parse(dt.Rows[0]["id"].ToString());
                            d["subscriber_name"]    = device.Name;
                            d["uplink"]             = device.Rssi;
                            d["speed"]              = device.Speed;
                            d["course"]             = device.Course;
                            d["altitude"]           = device.Altitude;
                            d["max_position_error"] = device.Error;
                            d["lat"]        = device.Lat;
                            d["lng"]        = device.Lng;
                            d["created_at"] = DateTime.Now;
                            sh.Insert("logs", d);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }

                        conn.Close();
                    }
                }
            }
        }
コード例 #7
0
ファイル: frmDevice.cs プロジェクト: renciebautista/gmap
        private void btnFind_Click(object sender, EventArgs e)
        {
            int       result;
            DataTable dt = SqliteDal.getData("SELECT id, mcc, mnc, ssi FROM devices");

            string[] fields     = new string[] { "ID", "MCC", "MNC", "SSI" };
            int[]    fieldsSize = new int[] { 50, 100, 100, 300 };

            frmFilter filter = new frmFilter();

            filter.DataSource = dt;
            filter.SearchFor  = "Devices";
            filter.FieldId    = "id";
            filter.Fields     = fields;
            filter.FieldsSize = fieldsSize;
            if (filter.ShowDialog() == DialogResult.OK)
            {
                result = filter.FilterValue;
                bind_Devices();
                filter.MoveCursor(result, dataGridView1);
            }
            filter.Dispose();
            btnAdd.Focus();
        }
コード例 #8
0
        private void plotTrain_old()
        {
            this.Text      = DateTime.Now.ToString();
            timer1.Enabled = false;

            List <PointLatLng> positions = new List <PointLatLng>();
            List <int>         list      = selected();

            #region Read File Data

            if (list.Count > 0)
            {
                string query = "SELECT * FROM logs" +
                               " inner join devices on devices.id = logs.device_id" +
                               " WHERE device_id IN(" + String.Join(",", list.ToArray()) + ") " +
                               " GROUP BY device_id ORDER BY id DESC";
                DataTable dt = SqliteDal.getData(query);

                foreach (DataRow row in dt.Rows) // Loop over the rows.
                {
                    PointLatLng p = new PointLatLng
                    {
                        Lat = float.Parse(row["lat"].ToString()),
                        Lng = float.Parse(row["lng"].ToString())
                    };
                    //positions.Add(p);
                    //GMapCustomImageMarker marker = new GMapCustomImageMarker(markerImage, p);
                    Image           markerImage = Image.FromFile(config.MyDirectory() + @"\marker\" + row["image"]);
                    GMapMarkerImage marker      = new GMapMarkerImage(p, markerImage);
                    objects.Markers.Add(marker);

                    //add marker
                }
            }

            /*TextReader file = new StreamReader(config.MyDirectory() + @"\data\data.csv");
             * string aLine;
             * while ((aLine = file.ReadLine()) != null)
             * {
             *  string[] pos = aLine.Split(',');
             *  PointLatLng p = new PointLatLng
             *  {
             *      Lat = float.Parse(pos[1]),
             *      Lng = float.Parse(pos[2])
             *  };
             *  //positions.Add(p);
             *  //GMarkerGoogle m = new GMarkerGoogle(p, GMarkerGoogleType.green);
             *  Image markerImage = Image.FromFile(config.MyDirectory() + @"\marker\train_red.png");
             *  //GMapCustomImageMarker marker = new GMapCustomImageMarker(markerImage, p);
             *  GMapMarkerImage marker = new GMapMarkerImage(p, markerImage);
             *  objects.Markers.Add(marker);
             *
             *  //add marker
             *
             *
             * }*/

            MainMap.Refresh();



            #endregion



            //Random rnd = new Random();
            //int index = rnd.Next(1, positions.Count); // creates a number between 1 and 12

            //GMarkerGoogle m = new GMarkerGoogle(positions[index], GMarkerGoogleType.orange);
            //objects.Markers.Add(m);
            timer1.Enabled = true;
        }