//нажатие на кнопку поиска private void bttnSearch_Click(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(tbSearch.Text)) { Database.Apartment apartment = DBWork.Instance.SearchApart(tbSearch.Text); if (apartment != null) { tbTitle.Text = apartment.Title; tbArea.Text = apartment.Area.ToString(); tbCountRoom.Text = apartment.CountRoom.ToString(); tbFloor.Text = apartment.Floor.ToString(); tbNumberApart.Text = apartment.Number.ToString(); tbPrice.Text = apartment.Price.ToString(); tbAddress.Text = apartment.Address.ToString(); index = apartment.Id; bt = DBWork.Instance.SearchApart(apartment.Id); if (bt != null) { using (var ms = new MemoryStream(bt)) { var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.StreamSource = ms; bitmapImage.EndInit(); using (MemoryStream outStream = new MemoryStream()) { BitmapEncoder enc = new BmpBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create(bitmapImage)); enc.Save(outStream); Bitmap bitmap = new System.Drawing.Bitmap(outStream); pbPictureApartment.Image = bitmap; } //Отличная кв в центре г. Киева } } } else { MessageBox.Show("Нет соответствий!"); } } }
//Загрузка данных в панели public void Init(Label lblTitle, Label lblAge, Label lblTheme, Label lblAuthor, Label lblPrice, PictureBox pctrBx, Database.Apartment ap) { lblPrice.Text = ap.Price + "₴ "; lblTitle.Text = ap.Address; lblAuthor.Text = "Этаж: " + ap.Floor.ToString(); lblTheme.Text = "S: " + ap.Area.ToString(); lblAge.Text = "Кол комнт:" + ap.CountRoom.ToString(); bt = DBWork.Instance.SearchApart(ap.Id); if (bt != null) { using (var ms = new MemoryStream(bt)) { var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.CacheOption = BitmapCacheOption.OnLoad; bitmapImage.StreamSource = ms; bitmapImage.EndInit(); using (MemoryStream outStream = new MemoryStream()) { BitmapEncoder enc = new BmpBitmapEncoder(); enc.Frames.Add(BitmapFrame.Create(bitmapImage)); enc.Save(outStream); Bitmap bitmap = new System.Drawing.Bitmap(outStream); pctrBx.Image = bitmap; } //Отличная кв в центре г. Киева } } }
public ControlSale(Database.Apartment ap) { InitializeComponent(); this.ap = ap; }