public List <User> search(MatchingSeeking MS) { SqlCommand User_Seach = new SqlCommand("spSearch_User_information", connection); User_Seach.CommandType = CommandType.StoredProcedure; User_Seach.Parameters.AddWithValue("First_name", MS.First_name); User_Seach.Parameters.AddWithValue("Last_name", MS.Last_name); User_Seach.Parameters.AddWithValue("Birthdate1", MS.Date); User_Seach.Parameters.AddWithValue("Birthdate2", MS.Date1); User_Seach.Parameters.AddWithValue("Gender", MS.Gender); User_Seach.Parameters.AddWithValue("Seeking", MS.Seeking); User_Seach.Parameters.AddWithValue("@FK_Post_Code1", MS.Postcode); User_Seach.Parameters.AddWithValue("@FK_Post_Code2", MS.Postcode1); User_Seach.Parameters.AddWithValue("Status", MS.Status); User_Seach.Parameters.AddWithValue("Sexual_orientation", MS.SexualOrientation); User_Seach.Parameters.AddWithValue("Height1", MS.Height); User_Seach.Parameters.AddWithValue("Height2", MS.Height1); User_Seach.Parameters.AddWithValue("Weight1", MS.Weight); User_Seach.Parameters.AddWithValue("Weight2", MS.Weight1); User_Seach.Parameters.AddWithValue("Eyecolor", MS.Eyecolor); User_Seach.Parameters.AddWithValue("Haircolor", MS.Haircolor); User_Seach.Parameters.AddWithValue("Children", MS.Children); User_Seach.Parameters.AddWithValue("Body_Type", MS.Body_Type); User_Seach.Parameters.AddWithValue("FK_Profile_name", MS.FK_profile_name); SqlDataAdapter adapt = new SqlDataAdapter(User_Seach); DataSet ds = new DataSet(); adapt.Fill(ds); connection.Close(); var User_list = ds.Tables[0].AsEnumerable().Select(dataRow => new User { FK_profile_name = dataRow.Field <string>("FK_Profile_name"), First_name = dataRow.Field <string>("First_Name"), Last_name = dataRow.Field <string>("Last_Name"), Date = dataRow.Field <DateTime>("Birthdate"), Gender = dataRow.Field <string>("Gender"), Seeking = dataRow.Field <string>("Seeking"), Postcode = dataRow.Field <int>("FK_Post_Code"), Status = dataRow.Field <string>("Status"), SexualOrientation = dataRow.Field <string>("Sexual_orientation"), Height = dataRow.Field <int>("Height"), Weight = dataRow.Field <int>("Weight"), Eyecolor = dataRow.Field <string>("Eyecolor"), Haircolor = dataRow.Field <string>("Haircolor"), Children = dataRow.Field <string>("Children"), Body_Type = dataRow.Field <string>("Body_Type"), }).ToList(); return(User_list); }
private void Søg_Button_Click(object sender, RoutedEventArgs e) { if (HøjdeMin_Textbox.Text == "") { ms.Height = 0; } else { ms.Height = int.Parse(HøjdeMin_Textbox.Text); } if (HøjdeMax_Textbox.Text == "") { ms.Height1 = 2147483647; } else { ms.Height1 = int.Parse(HøjdeMax_Textbox.Text); } if (VægtMin_Textbox.Text == "") { ms.Weight = 0; } else { ms.Weight = int.Parse(VægtMin_Textbox.Text); } if (VægtMax_Textbox.Text == "") { ms.Weight1 = 2147483647; } else { ms.Weight1 = int.Parse(VægtMax_Textbox.Text); } if (FødselsdagMin_Datepicker.Text == "") { ms.Date = Convert.ToDateTime("1800-01-01"); } else { ms.Date = DateTime.Parse(FødselsdagMin_Datepicker.Text); } if (FødeelsdagMax_datepicker.Text == "") { ms.Date1 = Convert.ToDateTime("9000-01-01"); } else { ms.Date1 = DateTime.Parse(FødeelsdagMax_datepicker.Text); } if (PostnrMin_ComboBox.Text == "") { ms.Postcode = 1000; } else { ms.Postcode = int.Parse(PostnrMin_ComboBox.Text); } if (PostnrMax_ComboBox.Text == "") { ms.Postcode1 = 9990; } else { ms.Postcode1 = int.Parse(PostnrMax_ComboBox.Text); } ms.First_name = Fornavn_textbox.Text; ms.Last_name = Efternavn_textbox.Text; ms.Gender = Køn_combobox.Text; ms.Seeking = Søger_combobox.Text; ms.Status = Status_Combobox.Text; ms.SexualOrientation = IntereseretI_Combobox.Text; ms.Eyecolor = Øjenfarve_combobox.Text; ms.Haircolor = Hårfarve_combobox.Text; ms.Children = Børn_Combobox.Text; ms.Body_Type = Kropstype_Combobox.Text; ms.FK_profile_name = Dating_App.Model.User.CurrentUser.Profile_name; List <User> ms1 = new List <User>(); ms1 = ms.search(ms); ms = null; ResultaterForSøgning_datagrid.ItemsSource = ms1; //ResultaterForSøgning_datagrid.UpdateLayout(); }