Ejemplo n.º 1
0
        /// <summary>
        /// Abre la ventana detalle en modo "detalle" o "edición" dependiendo de sus permisos
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 12/05/2016
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            HotelGroup          hotelGroup          = (HotelGroup)dgrHotelGroups.SelectedItem;
            frmHotelGroupDetail frmHotelGroupDetail = new frmHotelGroupDetail();

            frmHotelGroupDetail.Owner         = this;
            frmHotelGroupDetail.oldHotelGroup = hotelGroup;
            frmHotelGroupDetail.enumMode      = (_blnEdit) ? EnumMode.Edit : EnumMode.Add;
            if (frmHotelGroupDetail.ShowDialog() == true)
            {
                List <HotelGroup> lstHotelGroup = (List <HotelGroup>)dgrHotelGroups.ItemsSource;
                int nIndex = 0;
                if (ValidateFilter(frmHotelGroupDetail.hotelGroup))
                {
                    ObjectHelper.CopyProperties(hotelGroup, frmHotelGroupDetail.hotelGroup); //Actualizar los datos
                    lstHotelGroup.Sort((x, y) => string.Compare(x.hgN, y.hgN));              //Ordenar la lista
                    nIndex = lstHotelGroup.IndexOf(hotelGroup);                              //Buscamos la posición del registro
                }
                else
                {
                    lstHotelGroup.Remove(hotelGroup);
                }
                dgrHotelGroups.Items.Refresh();                                //Actualizar la vista
                GridHelper.SelectRow(dgrHotelGroups, nIndex);                  //Seleccionamos l registro
                StatusBarReg.Content = lstHotelGroup.Count + " Hotel Groups."; //Actualizar el contador
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmHotelGroupDetail frmHotelGroupDetail = new frmHotelGroupDetail();

            frmHotelGroupDetail.Owner    = this;
            frmHotelGroupDetail.enumMode = EnumMode.Add;
            if (frmHotelGroupDetail.ShowDialog() == true)
            {
                if (ValidateFilter(frmHotelGroupDetail.hotelGroup))
                {
                    List <HotelGroup> lstHotelGroup = (List <HotelGroup>)dgrHotelGroups.ItemsSource;
                    lstHotelGroup.Add(frmHotelGroupDetail.hotelGroup);                  //Agregamos el registro
                    lstHotelGroup.Sort((x, y) => string.Compare(x.hgN, y.hgN));         //Ordenamos la lista
                    int nIndex = lstHotelGroup.IndexOf(frmHotelGroupDetail.hotelGroup); //Buscamos la posición del registro
                    dgrHotelGroups.Items.Refresh();
                    GridHelper.SelectRow(dgrHotelGroups, nIndex);                       //Seleccionamos el registro
                    StatusBarReg.Content = lstHotelGroup.Count + " Hotel Groups.";      //Actualizamos el contador
                }
            }
        }