コード例 #1
0
        /// <summary>
        /// Muestra la ventana detalle en modo edit
        /// </summary>
        /// <history>
        /// [emoguel] 19/04/2016 Created
        /// </history>
        private void Cell_DoubleClick(object sender, RoutedEventArgs e)
        {
            RoomType          roomType          = (RoomType)dgrRoomTypes.SelectedItem;
            frmRoomTypeDetail frmRoomTypeDetail = new frmRoomTypeDetail();

            frmRoomTypeDetail.Owner       = this;
            frmRoomTypeDetail.enumMode    = EnumMode.Edit;
            frmRoomTypeDetail.oldRoomType = roomType;
            if (frmRoomTypeDetail.ShowDialog() == true)
            {
                int             nIndex       = 0;
                List <RoomType> lstRoomTypes = (List <RoomType>)dgrRoomTypes.ItemsSource;
                if (ValidateFilter(frmRoomTypeDetail.roomType))                        //Validamos si cumple con los filtros actuales
                {
                    ObjectHelper.CopyProperties(roomType, frmRoomTypeDetail.roomType); //Actualizamos los datos del registro
                    lstRoomTypes.Sort((x, y) => string.Compare(x.rtN, y.rtN));         //Ordenamos la lista
                    nIndex = lstRoomTypes.IndexOf(roomType);                           //buscamos la posición del nuevo registro
                }
                else
                {
                    lstRoomTypes.Remove(roomType);                          //Quitamos el registro
                }
                dgrRoomTypes.Items.Refresh();                               //Actualizamos la vista
                GridHelper.SelectRow(dgrRoomTypes, nIndex);                 //Seleccionamos el registro nuevo
                StatusBarReg.Content = lstRoomTypes.Count + " Room Types."; //Actualizamos el contador
            }
        }
コード例 #2
0
        /// <summary>
        /// Abre la ventana detalle en modo Add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 19/04/2016
        /// </history>
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            frmRoomTypeDetail frmRoomTypeDetail = new frmRoomTypeDetail();

            frmRoomTypeDetail.Owner    = this;
            frmRoomTypeDetail.enumMode = EnumMode.Add;
            if (frmRoomTypeDetail.ShowDialog() == true)
            {
                RoomType roomType = frmRoomTypeDetail.roomType;
                if (ValidateFilter(roomType))//Validamos que cumpla con los filtros actuales
                {
                    List <RoomType> lstRoomTypes = (List <RoomType>)dgrRoomTypes.ItemsSource;
                    lstRoomTypes.Add(roomType);                                 //Agrega el registro nuevo a la lista
                    lstRoomTypes.Sort((x, y) => string.Compare(x.rtN, y.rtN));  //Ordenamos la lista
                    int nIndex = lstRoomTypes.IndexOf(roomType);                //Obtenemos la posicion del registro
                    dgrRoomTypes.Items.Refresh();                               //Actualizamos la vista
                    GridHelper.SelectRow(dgrRoomTypes, nIndex);                 //Seleccionamos el registro
                    StatusBarReg.Content = lstRoomTypes.Count + " Room Types."; //Actualizamos el contador
                }
            }
        }