Exemplo n.º 1
0
        private void updatefkamar_Click(object sender, RoutedEventArgs e)
        {
            int id = Convert.ToInt32(Id_Tipehotel.Text);
            H_Roomtype_Facility datax = SearchByIdFkamar(id);

            datax.H_FacilityID = Convert.ToInt32(Fkamarbox.SelectedValue);
            datax.H_RoomtypeID = Convert.ToInt32(Nkamarbox.SelectedValue);

            //try
            //{
            //    _context.Entry(datax).State = System.Data.Entity.EntityState.Modified;
            //    _context.SaveChanges();
            //    clearhotel();
            //    this.viewFkamarGrid(FkamarGrid);
            //    MessageBox.Show("Update Success !", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
            //}
            //catch (DbEntityValidationException ex)
            //{
            //    foreach (var eve in ex.EntityValidationErrors)
            //    {
            //        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
            //            eve.Entry.Entity.GetType().Name, eve.Entry.State);
            //        foreach (var ve in eve.ValidationErrors)
            //        {
            //            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
            //                ve.PropertyName, ve.ErrorMessage);
            //        }
            //    }
            //    throw;
            //}
        }
Exemplo n.º 2
0
 private void Hapusfkamar_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("Are You Sure ?", "Information", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes)
     {
         object item    = FkamarGrid.SelectedItem;
         string temp_id = (FkamarGrid.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text;
         int    id      = Convert.ToInt32(temp_id);
         H_Roomtype_Facility datadel = SearchByIdFkamar(id);
         _context.Entry(datadel).State = System.Data.Entity.EntityState.Deleted;
         _context.SaveChanges();
         clearhotel();
         this.viewFkamarGrid(FkamarGrid);
     }
     else
     {
     }
 }
        public void InsertFasilitaskamar(int IdFasilitas, int IdKamar)
        {
            H_Roomtype_Facility call = new H_Roomtype_Facility();

            {
                call.H_FacilityID = IdFasilitas;
                call.H_RoomtypeID = IdKamar;
            };
            try
            {
                _context.H_Roomtype_Facility.Add(call);
                var result = _context.SaveChanges();
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.InnerException);
            }
        }