private void buttonSell_Click(object sender, EventArgs e) { int price; bool boolResult = int.TryParse(textBoxPrice.Text, out price); if (imageListView1.SelectedItems[0] != null && boolResult) { Photo selectedPhotoForSell = LogggedInUser.PhotosCollection.ListOfPhotos.Find(x => x.photoId == (int)imageListView1.SelectedItems[0].Tag); MarketPhoto marketPhoto = new MarketPhoto() { userId = LogggedInUser.ID, photoId = selectedPhotoForSell.photoId, price = price, description = textBoxDescription.Text, Date = DateTime.Now.ToString() }; DataBaseProxy.InsertNewMarketPhoto(marketPhoto); LogggedInUser.PhotosCollection.deletePhoto(selectedPhotoForSell); imageListView1.Items.Remove(imageListView1.SelectedItems[0]); UpdaterChecker.IsMarketDataHasChanged = true; } panel1.Visible = false; textBoxPrice.Clear(); }
public void InitForm(MarketPhoto i_MarketPhoto, List <User> i_Users, User i_LoggedInUser) { Users = i_Users; LoggedInUser = i_LoggedInUser; MarketPhoto = i_MarketPhoto; Photo = DataBaseProxy.GetPhoto(MarketPhoto.photoId); UserSeller = Users.Find(x => x.ID == MarketPhoto.userId); if (Photo != null) { if (!File.Exists(Photo.photoId + ".jpg")) { downloadPhoto(Photo.URL); } else // this file is exist. { m_BitmapPhoto = new Bitmap(Photo.photoId + ".jpg"); } displayPhoto(); displayData(); } }
public void InsertNewMarketPhoto(MarketPhoto marketPhoto) { Connect(); m_MySqlConnection.Execute($"insert into market values('{marketPhoto.userId}','{marketPhoto.photoId}','{marketPhoto.price}','{marketPhoto.description}','{marketPhoto.Date}');"); CloseConnection(); }