private void Window_Loaded(object sender, RoutedEventArgs e) { try { string uname = Application.Current.Properties["username"].ToString(); if (uname.Equals("Admin")) { btnDelete.Visibility = Visibility.Visible; } else { BuyerName = Application.Current.Properties["BuyerName"].ToString(); btnAddToCart.Visibility = Visibility.Visible; } propList = propertyBL.GetAllPropertyBL(); dgViewAllData.DataContext = propList; } catch (EasyHousingSolutionException ex) { MessageBox.Show("Error: " + ex); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } }
private void btnSearch_Click(object sender, RoutedEventArgs e) { try { string propName = txtPropertyName.Text; List <Property> prop = propertyBL.GetAllPropertyBL(); if (prop == null && prop.Count <= 0) { sb.Append("Enter valid property name"); } List <Property> pr = prop.Where(p => p.PropertyName == propName).ToList(); dgSearchProperty.DataContext = pr; } catch (EasyHousingSolutionException ex) { MessageBox.Show("Error: " + sb.ToString() + ex.Message); } }