예제 #1
0
        void DeletePicture(int id)
        {
            ViewModel.WinMessageBoxItem wmsb = new ViewModel.WinMessageBoxItem((rm as ResourceManager).GetString("Message_Delete_Title"), (rm as ResourceManager).GetString("Message_DeletePics"), PackIconKind.WarningCircle);
            Windows.WinMessageBox       msb  = new Windows.WinMessageBox(wmsb, (rm as ResourceManager), ResourceNames, true);

            if (msb.ShowDialog() == true)
            {
                System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                if (WPE.WeddingVenueImages.Any(x => x.ID.Equals(id)))
                {
                    WPE.Dispose();
                    WPE = new Models.WeddingPlannerEntities();
                    Models.WeddingVenueImages wvi = WPE.WeddingVenueImages.FirstOrDefault(x => x.ID.Equals(id));
                    WPE.WeddingVenueImages.Attach(wvi);
                    WPE.WeddingVenueImages.Remove(wvi);
                    WPE.SaveChanges();
                    int delindex = p.FindIndex(x => x.ID.Equals(wvi.ID));
                    p.Remove(p.FirstOrDefault(x => x.ID.Equals(wvi.ID)));
                    Bitimages.RemoveAt(delindex);
                    PicsBox.ItemsSource = null;
                    PicsBox.ItemsSource = p;
                }
            }
            System.Windows.Input.Mouse.OverrideCursor = null;
        }
예제 #2
0
 void insertImageData(string[] imageNames)
 {
     try
     {
         if (imageNames != null)
         {
             System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
             FileStream fs = null;
             for (int i = 0; i < imageNames.Length; i++)
             {
                 fs = new FileStream(imageNames[i], FileMode.Open, FileAccess.Read);
                 byte[] imgByteArr = new byte[fs.Length];
                 fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
                 Models.WeddingVenueImages wvi = new Models.WeddingVenueImages();
                 wvi.WeddingVenueID = VenueIDs[CB_Venue.SelectedIndex];
                 wvi.Image          = imgByteArr;
                 wvi.ImageName      = imageNames[i].Split(new[] { @"\" }, StringSplitOptions.None).Last();
                 WPE.WeddingVenueImages.Add(wvi);
                 WPE.SaveChanges();
             }
             fs.Close();
             ShowPics((rm as ResourceManager));
             System.Windows.Input.Mouse.OverrideCursor = null;
         }
     }
     catch (Exception ex)
     {
         ViewModel.WinMessageBoxItem wmsb = new ViewModel.WinMessageBoxItem("Error", ex.Message, PackIconKind.Error);
         Windows.WinMessageBox       msb  = new Windows.WinMessageBox(wmsb, (rm as ResourceManager), ResourceNames, false);
         msb.Show();
         System.Windows.Input.Mouse.OverrideCursor = null;
     }
 }