예제 #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            label4.Visible       = false;
            radioButton1.Checked = false;
            radioButton2.Checked = false;
            radioButton3.Checked = false;

            selectedPost = comboBox1.SelectedItem as Postes;

            textBox1.Text = selectedPost.longitude.ToString() + " , " + selectedPost.latitude.ToString();
            textBox2.Text = selectedPost.message;


            if (selectedPost.icon == 0)
            {
                radioButton1.Checked = true;
                textBox2.Enabled     = true;
            }
            else if (selectedPost.icon == 1)
            {
                radioButton2.Checked = true;
            }
            else
            {
                radioButton3.Checked = true;
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            selectedPost = comboBox1.SelectedItem as Postes;

            HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("http://localhost:8080/Postes/" + selectedPost.id);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.MediaType   = "application/json";
            httpWebRequest.Accept      = "application/json";
            httpWebRequest.Method      = "PUT";

            int status = 0;

            if (radioButton1.Checked == true)
            {
                status = 0;
            }
            else if (radioButton2.Checked == true)
            {
                status = 1;
            }
            else
            {
                status = 2;
            }



            using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write("{\"longitude\" : " + selectedPost.longitude + "," +
                                   "\"latitude\" : " + selectedPost.latitude + "," +
                                   "\"message\" : \"" + textBox2.Text + "\"," +
                                   "\"icon\" : " + status +
                                   "}");
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
                string json = streamReader.ReadToEnd();
            }

            response      = client.GetAsync("Postes").Result;
            posts         = response.Content.ReadAsAsync <IEnumerable <Postes> >().Result;
            bs.DataSource = posts;

            label4.Visible = true;
        }