private void lstimages_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (lstimages.SelectedIndex > 0) { selectedImage = imageList.ElementAt(lstimages.SelectedIndex); } }
private int SaveImage(DBLibrary.Image image) { db.Entry(image).State = System.Data.Entity.EntityState.Added; int saveSuccess2 = db.SaveChanges(); return(saveSuccess2); //db.Entry(image).State = System.Data.Entity.EntityState.Added; //int saveSuccess = db.SaveChanges(); //return saveSuccess; }
private void btnaddImage_Click(object sender, RoutedEventArgs e) { bool inputscorrect = ImagesInputCheck(); if (inputscorrect) { DBLibrary.Image savedimage = new DBLibrary.Image(); savedimage.ImageName = txtImageName.Text.Trim(); savedimage.Notes = txtImageNotes.Text.Trim(); savedimage.VendorID = cbovendor.SelectedIndex + 1; savedimage.UseCaseID = cbousedIn.SelectedIndex + 1; savedimage.date = DateTime.Now; int saveSuccess = SaveImage(savedimage); if (saveSuccess == 1) { MessageBox.Show("Image Details Saved", "Image save", MessageBoxButton.OK); CreateLogEntry(loggedInUser.UserID, ("added image" + savedimage.ImageName), loggedInUser.Username); ClearImagesInputs(); Dashboard dashboard = new Dashboard(); dashboard.ImageFrameChange(); } } }