/// <summary> /// Muestra la ventana detalle en modo edit /// </summary> /// <history> /// [emoguel] created 29/03/2016 /// </history> private void Cell_DoubleClick(object sender, RoutedEventArgs e) { Hotel hotel = (Hotel)dgrHotels.SelectedItem; frmHotelDetail frmHotelDetail = new frmHotelDetail(); frmHotelDetail.Owner = this; frmHotelDetail.oldHotel = hotel; frmHotelDetail.enumMode = ((_blnEdit == true) ? EnumMode.Edit : EnumMode.ReadOnly); if (frmHotelDetail.ShowDialog() == true) { int nIndex = 0; List <Hotel> lstHotels = (List <Hotel>)dgrHotels.ItemsSource; if (!ValidateFilter(frmHotelDetail.hotel)) //Verificamos que cumpla con los registros actuales { lstHotels.Remove(hotel); //Quitamos el registro } else { ObjectHelper.CopyProperties(hotel, frmHotelDetail.hotel, true);//Actualizamos los datos del registro en el grid lstHotels.Sort((x, y) => string.Compare(x.hoID, y.hoID)); nIndex = dgrHotels.SelectedIndex; } dgrHotels.Items.Refresh(); GridHelper.SelectRow(dgrHotels, nIndex); StatusBarReg.Content = lstHotels.Count + " Hotels."; } }
/// <summary> /// Abre la ventana de busqueda /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoguel] created 29/03/2016 /// </history> private void btnSearch_Click(object sender, RoutedEventArgs e) { frmHotelDetail frmHotelDetail = new frmHotelDetail(); frmHotelDetail.Owner = this; frmHotelDetail.oldHotel = _hotelFilter; frmHotelDetail.enumMode = EnumMode.Search; frmHotelDetail.nStatus = _nStatus; if (frmHotelDetail.ShowDialog() == true) { _nStatus = frmHotelDetail.nStatus; _hotelFilter = frmHotelDetail.hotel; LoadHotels(); } }
/// <summary> /// Abre la ventana detalle en modo Add /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <history> /// [emoquel] created 29/03/2016 /// </history> private void btnAdd_Click(object sender, RoutedEventArgs e) { frmHotelDetail frmHotelDetail = new frmHotelDetail(); frmHotelDetail.Owner = this; frmHotelDetail.enumMode = EnumMode.Add; if (frmHotelDetail.ShowDialog() == true) { if (ValidateFilter(frmHotelDetail.hotel))//Validamos que cumpla con los filtros actuales { List <Hotel> lstHotels = (List <Hotel>)dgrHotels.ItemsSource; lstHotels.Add(frmHotelDetail.hotel); //Agregar el registro lstHotels.Sort((x, y) => string.Compare(x.hoID, y.hoID)); //Ordenamos la lista dgrHotels.Items.Refresh(); //Actualizamos la vista de grid int nIndex = lstHotels.IndexOf(frmHotelDetail.hotel); //Obtenemos el index GridHelper.SelectRow(dgrHotels, nIndex); //Seleccionamos el registro StatusBarReg.Content = lstHotels.Count + " Hotels."; //Actualizamos el contador } } }