コード例 #1
0
ファイル: Search.xaml.cs プロジェクト: Arenzic/PAS
        public Search(string query)
        {
            InitializeComponent();

            SqliteDataAccess sqlData = new SqliteDataAccess();

            if (query == null)
            {
                DataTable Table = sqlData.DataTableQuery("SELECT person.surName, person.GivenName, person.Height, person.Gender, person.status, " +
                                                         "person.EyeColor, person.id, doctor.doctorId FROM person LEFT JOIN doctor ON person.id = doctor.doctorId");
                SearchResults.ItemsSource = Table.DefaultView;
            }
            else
            {
                DataTable Table = sqlData.DataTableQuery(query);
                SearchResults.ItemsSource = Table.DefaultView;
            }
        }
コード例 #2
0
ファイル: Search.xaml.cs プロジェクト: Arenzic/PAS
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            string           query      = "SELECT * FROM person";
            int              queryCount = 0;
            SqliteDataAccess sqlData    = new SqliteDataAccess();

            string StringGender   = null;
            string StringEyeColor = null;

            if (FNameInput.Text != "")
            {
                //concatenating a query string based on user demands
                if (queryCount < 1)
                {
                    query = query + " WHERE GivenName LIKE '" + FNameInput.Text + "'";
                    queryCount++;
                }
                else
                {
                    query = query + " AND GivenName LIKE '" + FNameInput.Text + "'";
                }
            }

            if (SurnameInput.Text != "")
            {
                if (queryCount < 1)
                {
                    query = query + " WHERE SurName LIKE '" + SurnameInput.Text + "'";
                    queryCount++;
                }
                else
                {
                    query = query + " AND SurName LIKE '" + SurnameInput.Text + "'";
                }
            }

            if (GenderCombo.SelectedItem != null)
            {
                ComboBoxItem GenderItem = (ComboBoxItem)GenderCombo.SelectedItem;
                StringGender = GenderItem.Content.ToString();
                if (queryCount < 1)
                {
                    query = query + " WHERE Gender LIKE '" + StringGender + "'";
                    queryCount++;
                }
                else
                {
                    query = query + " AND Gender LIKE '" + StringGender + "'";
                }
            }


            if (EyeColorCombo.SelectedItem != null)
            {
                ComboBoxItem EyeItem = (ComboBoxItem)EyeColorCombo.SelectedItem;
                StringEyeColor = EyeItem.Content.ToString();

                if (queryCount < 1)
                {
                    query = query + " WHERE EyeColor LIKE '" + StringEyeColor + "'";
                    queryCount++;
                }
                else
                {
                    query = query + " AND EyeColor LIKE '" + StringEyeColor + "'";
                    queryCount++;
                }
            }

            if (HeightInput.Text != "")
            {
                string height    = HeightInput.Text;
                string decHeight = height.ToString(System.Globalization.CultureInfo.InvariantCulture);

                if (queryCount < 1)
                {
                    query = query + " WHERE Height LIKE '" + decHeight + "'";
                    queryCount++;
                }
                else
                {
                    query = query + " AND Height LIKE '" + decHeight + "'";
                }
            }

            //returning the results to the datatable
            DataTable Table = sqlData.DataTableQuery(query);

            SearchResults.ItemsSource = Table.DefaultView;
        }