Ejemplo n.º 1
0
        private void btnUpdGpsData_Click(object sender, EventArgs e)
        {
            try
            {
                coordonneespr gpre = new coordonneespr();
                gpre.Idpr      = txtg_Id_Pr.Text.Trim();
                gpre.Wptpr     = int.Parse(txtwpt.Text.Trim());
                gpre.Latitude  = txtlat.Text.Trim();
                gpre.Longitude = txtlong.Text.Trim();
                gpre.Altitude  = int.Parse(txtalt.Text.Trim());
                gpre.Epepr     = int.Parse(txtepe.Text.Trim());

                string strx = dtggpsdata["wptpr", dtggpsdata.CurrentRow.Index].Value.ToString();

                if (xConn.State.ToString().Equals("Closed"))
                {
                    xConn.Open();
                }
                gCmd             = xConn.CreateCommand();
                gCmd.CommandText = "update COORDONNEESPR set id_pr=@id_pr,wptpr=@wptpr,latitude=@latitude,longitude=@longitude,altitude=@altitude,epepr=@epepr where wptpr='" + strx + "'";

                gCmd.Parameters.Add("id_pr", SqlDbType.VarChar, 25, "@id_pr").Value         = gpre.Idpr;
                gCmd.Parameters.Add("wptpr", SqlDbType.Int, 10, "@wptpr").Value             = gpre.Wptpr;
                gCmd.Parameters.Add("latitude", SqlDbType.VarChar, 20, "@latitude").Value   = gpre.Latitude;
                gCmd.Parameters.Add("longitude", SqlDbType.VarChar, 20, "@longitude").Value = gpre.Longitude;
                gCmd.Parameters.Add("altitude", SqlDbType.Int, 10, "@altitude").Value       = gpre.Altitude;
                gCmd.Parameters.Add("epepr", SqlDbType.Int, 10, "@epepr").Value             = gpre.Epepr;

                int y = gCmd.ExecuteNonQuery();
            }
            catch (SqlException x)
            {
                MessageBox.Show(this, x.Message, "Error");
            }
            xConn.Close();
            _EmptyGpsTextBox();
            _FillBindingNavigator();
        }
Ejemplo n.º 2
0
        private void btnAddGpsData_Click(object sender, EventArgs e)
        {
            try
            {
                coordonneespr gpr = new coordonneespr();
                gpr.Idpr      = txtg_Id_Pr.Text.Trim();
                gpr.Wptpr     = int.Parse(txtwpt.Text.Trim());
                gpr.Latitude  = txtlat.Text.Trim();
                gpr.Longitude = txtlong.Text.Trim();
                gpr.Altitude  = int.Parse(txtalt.Text.Trim());
                gpr.Epepr     = int.Parse(txtepe.Text.Trim());

                if (xConn.State.ToString().Equals("Closed"))
                {
                    xConn.Open();
                }
                gCmd             = xConn.CreateCommand();
                gCmd.CommandText = "insert into COORDONNEESPR(id_pr,wptpr,latitude,longitude,altitude,epepr) values(@id_pr,@wptpr,@latitude,@longitude,@altitude,@epepr)";

                gCmd.Parameters.Add("id_pr", SqlDbType.VarChar, 25, "@id_pr").Value         = gpr.Idpr;
                gCmd.Parameters.Add("wptpr", SqlDbType.Int, 10, "@wptpr").Value             = gpr.Wptpr;
                gCmd.Parameters.Add("latitude", SqlDbType.VarChar, 20, "@latitude").Value   = gpr.Latitude;
                gCmd.Parameters.Add("longitude", SqlDbType.VarChar, 20, "@longitude").Value = gpr.Longitude;
                gCmd.Parameters.Add("altitude", SqlDbType.Int, 10, "@altitude").Value       = gpr.Altitude;
                gCmd.Parameters.Add("epepr", SqlDbType.Int, 10, "@epepr").Value             = gpr.Epepr;

                int y = gCmd.ExecuteNonQuery();
            }
            catch (SqlException x)
            {
                MessageBox.Show(this, x.Message, "Error");
            }
            xConn.Close();
            _EmptyGpsTextBox();
            _FillBindingNavigator();
        }