Exemplo n.º 1
0
        private async void buttonSearch_Click(object sender, EventArgs e)
        {
            bool           ok        = false;
            List <History> histories = await RentalCarsAPI.GetHistoryAsync();

            foreach (var history in histories)
            {
                if (comboBoxHistory.SelectedIndex == 0)
                {
                    if (!ok)
                    {
                        dataGridView.Rows.Clear();
                        ok = !ok;
                    }
                    dataGridView.Rows.Add(history.PersonId, history.FirstName, history.LastName, history.CNP, history.Counter);
                }
                if (comboBoxHistory.SelectedIndex == 1)
                {
                    if (!ok)
                    {
                        dataGridView.Rows.Clear();
                        ok = !ok;
                    }
                    if (history.FirstName == textBoxSearch.Text)
                    {
                        dataGridView.Rows.Add(history.PersonId, history.FirstName, history.LastName, history.CNP, history.Counter);
                    }
                }
                if (comboBoxHistory.SelectedIndex == 2)
                {
                    if (!ok)
                    {
                        dataGridView.Rows.Clear();
                        ok = !ok;
                    }
                    if (history.LastName == textBoxSearch.Text)
                    {
                        dataGridView.Rows.Add(history.PersonId, history.FirstName, history.LastName, history.CNP, history.Counter);
                    }
                }
                if (comboBoxHistory.SelectedIndex == 3)
                {
                    if (!ok)
                    {
                        dataGridView.Rows.Clear();
                        ok = !ok;
                    }
                    if (history.CNP == textBoxSearch.Text)
                    {
                        dataGridView.Rows.Add(history.PersonId, history.FirstName, history.LastName, history.CNP, history.Counter);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private async void LoadDataGridView()
        {
            List <History> histories = await RentalCarsAPI.GetHistoryAsync();

            comboBoxHistory.Items.Add("ALL");
            comboBoxHistory.Items.Add("Prenume");
            comboBoxHistory.Items.Add("Nume");
            comboBoxHistory.Items.Add("CNP");

            foreach (var history in histories)
            {
                dataGridView.Rows.Add(history.PersonId, history.FirstName, history.LastName, history.CNP, history.Counter);
            }
            comboBoxHistory.SelectedIndex = 0;
        }