Beispiel #1
0
        private void LoadPasssenger()
        {
            BackgroundWorker Bw = new BackgroundWorker();

            Bw.WorkerSupportsCancellation = true;
            Bw.WorkerReportsProgress      = true;
            Bw.DoWork += new DoWorkEventHandler(delegate(object sender, DoWorkEventArgs e)
            {
                string url     = "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getpassengerJson";
                string content = HttpHelper.GetResponse(url, "GET", "");
                pList          = JsonHelper.DeserializeToObj <PassengerList>(content);
                int controlX   = 6;
                int controlY   = 6;
                int i          = 0;
                foreach (Passenger key in pList.passengerJson)
                {
                    CheckBox cbox        = new CheckBox();
                    cbox.Checked         = false;
                    cbox.Text            = key.passenger_name;
                    cbox.Tag             = key;
                    cbox.Location        = new Point(controlX, controlY);
                    controlX            += 70;
                    cbox.Size            = new Size(70, 16);
                    cbox.CheckedChanged += new EventHandler(cboxChange);
                    cbox.Name            = "cbox" + i;
                    i++;
                    this.panleUSER.Controls.Add(cbox);
                }
            });
            Bw.RunWorkerAsync();
        }
Beispiel #2
0
 private void LoadPasssenger()
 {
     BackgroundWorker Bw = new BackgroundWorker();
     Bw.WorkerSupportsCancellation = true;
     Bw.WorkerReportsProgress = true;
     Bw.DoWork += new DoWorkEventHandler(delegate(object sender, DoWorkEventArgs e)
     {
         string url = "https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getpassengerJson";
         string content = HttpHelper.GetResponse(url, "GET", "");
         pList = JsonHelper.DeserializeToObj<PassengerList>(content);
         int controlX = 6;
         int controlY = 6;
         int i = 0;
         foreach (Passenger key in pList.passengerJson)
         {
             CheckBox cbox = new CheckBox();
             cbox.Checked = false;
             cbox.Text = key.passenger_name;
             cbox.Tag = key;
             cbox.Location = new Point(controlX, controlY);
             controlX += 70;
             cbox.Size = new Size(70, 16);
             cbox.CheckedChanged += new EventHandler(cboxChange);
             cbox.Name = "cbox" + i;
             i++;
             this.panleUSER.Controls.Add(cbox);
         }
     });
     Bw.RunWorkerAsync();
 }