Exemplo n.º 1
0
        private async void LoadTabs()
        {
            try
            {
                var answer_L_Clients = await Client.Remote.Communication.GetClients();

                var answer_L_Employees = await Client.Remote.Communication.GetEmployees();

                var answer_L_Products = await Client.Remote.Communication.GetProducts();


                if (answer_L_Clients != null && answer_L_Clients.Count > 0)
                {
                    this.Hide();

                    //Récupérer le contenu des trois GridView aprés authentification

                    var bindingListClient   = new BindingList <Mapping.Client>(answer_L_Clients);
                    var sourceClientBinding = new BindingSource(bindingListClient, null);

                    var bindingListEmployee   = new BindingList <Mapping.Employee>(answer_L_Employees);
                    var sourceEmployeeBinding = new BindingSource(bindingListEmployee, null);

                    var bindingListProduct   = new BindingList <Mapping.Product>(answer_L_Products);
                    var sourceProductBinding = new BindingSource(bindingListProduct, null);

                    var clientForm = new ClientForm(sourceClientBinding, sourceProductBinding, sourceEmployeeBinding);

                    clientForm.Show();
                    clientForm.GetDataGridViewClient().DataSource   = sourceClientBinding;
                    clientForm.GetDataGridViewEmployee().DataSource = sourceEmployeeBinding;
                    clientForm.GetDataGridViewProduct().DataSource  = sourceProductBinding;
                }
                else
                {
                    MessageBox.Show("Remote access Error: The API returned an empty list", "Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Couldn't communicate with the API: " + ex.Message, "Server Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }