public int UpdateHotel(int input) { System.Console.Write("Nama Hotel : "); string Hotel_name = System.Console.ReadLine(); System.Console.Write("Alamat : "); string Alamat_hotel = System.Console.ReadLine(); System.Console.Write("Kota : "); string City = System.Console.ReadLine(); System.Console.Write("Kecamatan : "); string Kecamatan = System.Console.ReadLine(); System.Console.Write("Jalan : "); string Jalan = System.Console.ReadLine(); System.Console.Write("Phone : "); string phone = System.Console.ReadLine(); System.Console.Write("Email : "); string email = System.Console.ReadLine(); System.Console.Write("Manager : "); string Manager = System.Console.ReadLine(); int hotelid = Convert.ToInt32(System.Console.ReadLine()); Console.WriteLine("\n"); Console.WriteLine("============================================="); System.Console.Write("MASUKKAN ULANG ID : "); string id_dpt = System.Console.ReadLine(); var getmhs = _context.H_Hotel.Find(Convert.ToInt16(id_dpt)); if (getmhs == null) { System.Console.Write("TIDAK ADA ID HOTEL : " + id_dpt); } else { H_Hotel call = GetById(input); call.Hotel_Name = Hotel_name; call.VillagesID = Alamat_hotel; call.Jalan = Jalan; call.Phone = phone; call.Email = email; call.Manager = Manager; call.Id = hotelid; _context.Entry(call).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } return(input); }
private void update_Click(object sender, RoutedEventArgs e) { int id = Convert.ToInt32(HotelId.Text); H_Hotel datax = SearchByIdHotel(id); datax.Hotel_Name = Nama_Hotel.Text; datax.VillagesID = Kecamatanbox.Text; datax.Jalan = Road.Text; datax.Phone = Hp.Text; datax.Email = Emails.Text; datax.Manager = Managers.Text; }
private void HapusButton_Click(object sender, RoutedEventArgs e) { if (MessageBox.Show("Are You Sure ?", "Information", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { object item = HotelGrid.SelectedItem; string temp_id = (HotelGrid.SelectedCells[0].Column.GetCellContent(item) as TextBlock).Text; int id = Convert.ToInt32(temp_id); H_Hotel datadel = SearchByIdHotel(id); _context.Entry(datadel).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); clearhotel(); this.viewHotelGrid(HotelGrid); } else { } }
// =========================================== INSERT ============================================= public void InsertHotel(string Hotel_name, string Kecamatan, string Jalan, string phone, string email, string Manager) { H_Hotel call = new H_Hotel(); { call.Hotel_Name = Hotel_name; call.VillagesID = Kecamatan; call.Jalan = Jalan; call.Phone = phone; call.Email = email; call.Manager = Manager; }; try { _context.H_Hotel.Add(call); var result = _context.SaveChanges(); } catch (Exception ex) { System.Console.Write(ex.InnerException); } }