示例#1
0
        /// <summary>
        /// Carga e incializa las variables
        /// </summary>
        /// <history>
        /// [jorcanche] 02/02/2016 Created
        /// [erosado] 19/05/2016  Modified. Se agregó asincronía
        /// </history>
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //Indicamos al statusbar que me muestre cierta informacion cuando oprimimos cierto teclado
            KeyboardHelper.CkeckKeysPress(StatusBarCap, Key.Capital);
            KeyboardHelper.CkeckKeysPress(StatusBarIns, Key.Insert);
            KeyboardHelper.CkeckKeysPress(StatusBarNum, Key.NumLock);
            //Cargamos los datos del huesped
            _guest = await BRGuests.GetGuest(_guestId);

            EnabledControls(true, true, false);
            //Cargamos los PR
            cbopnPR.ItemsSource = await BRPersonnel.GetPersonnel(Context.User.Location.loID, "ALL", "PR");

            // desplegamos los datos del huesped
            txtguID.Text         = _guest.guID.ToString();
            txtguLastName1.Text  = _guest.guLastName1;
            txtguFirstName1.Text = _guest.guFirstName1;
            txtguCheckInD.Text   = _guest.guCheckInD.ToString("dd/MM/yyyy");
            txtguCheckOutD.Text  = _guest.guCheckOutD.ToString("dd/MM/yyyy");

            //Cargamos el datagrid
            _pRNoteViewSource        = (CollectionViewSource)FindResource("pRNoteViewSource");
            _pRNoteViewSource.Source = await BRNotes.GetNoteGuest(_guestId);

            //Si no tiene ninguna nota se inhabilita el control
            if (dgNotes.Items.Count < 1)
            {
                btnShowInfo.IsEnabled = false;
            }
        }
示例#2
0
        /// <summary>
        /// Guarda la nota
        /// </summary>
        /// <history>
        /// [jorcanche] created 07/04/2016
        /// </history>
        public async void Save()
        {
            try
            {
                EnabledControls(true, true, false);
                if (AfterValidate())
                {
                    //Agregamos la nota
                    var note = new PRNote
                    {
                        pnDT   = Convert.ToDateTime(txtpnDT.Text),
                        pngu   = _guestId,
                        pnPR   = txtpnPR.Text,
                        pnText = txtpnText.Text
                    };

                    //Actualizamos el guest si no tiene ninguna nota
                    Guest guest = null;
                    if (!await BRNotes.GetCountNoteGuest(_guestId))
                    {
                        guest = await BRGuests.GetGuest(_guestId);

                        guest.guPRNote = true;
                        SaveNote       = true;
                    }
                    else
                    {
                        SaveNote = false;
                    }
                    //Enviamos los parametros para que agregue la nueva nota y modificamos el guest.
                    //Si hubo un erro al ejecutar el metodo SaveNoteGuest nos devolvera 0, indicando que ningun paso
                    //se realizo, es decir ni se agrego la nota y se modifico el guest, y siendo así ya no modificamos la variable
                    //_saveNote que es el que indica que se guardo el Avail.
                    if (await BRNotes.SaveNoteGuest(note, guest) != 0)
                    {
                        //Actualizamos el datagrid
                        _pRNoteViewSource.Source = await BRNotes.GetNoteGuest(_guestId);

                        DgNotes_OnSelectedCellsChanged(dgNotes, null);
                    }
                    else
                    {
                        //De no ser así informamos que no se guardo la información por algun motivo
                        UIHelper.ShowMessage("There was an error saving the information, consult your system administrator",
                                             MessageBoxImage.Error, "Information can not keep");
                    }
                    CleanControls();
                    _creatingNote = false;
                }
                else
                {
                    EnabledControls(false, false, true);
                }
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }