Esempio n. 1
0
        private async void button11_ClickAsync(object sender, EventArgs e)
        {
            if (dataGridView.SelectedRows.Count == 0)
            {
                MessageBox.Show("Please select a classroom");
            }
            else
            {
                int row         = dataGridView.SelectedRows[0].Index;
                int classroomID = list[row].ClassroomID;
                var client      = Helper.CreateClient();
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                //var tuple = new { sessionID = LoginInfo.sessionID, classroomID = classroomID };
                HttpResponseMessage response = await client.GetAsync("api/Operation/ClassroomInfo?classroomID=" + classroomID + "&sessionID=" + LoginInfo.sessionID);

                if (response.IsSuccessStatusCode)
                {
                    ClassroomInfoView classroomInfoView = await response.Content.ReadAsAsync <ClassroomInfoView>();

                    ClassroomInfoForm classroomInfoForm = new ClassroomInfoForm(classroomInfoView);
                    classroomInfoForm.Show();
                }
                else
                {
                    //MessageBox.Show(response.Content.ReadAsStringAsync().Result);
                    MessageBox.Show("failure!");
                }
            }
        }
 public ClassroomInfoForm(ClassroomInfoView classroomInfoView)
 {
     InitializeComponent();
     propertyGrid1.SelectedObject = classroomInfoView;
 }