예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _dsSalesRoom  = ((CollectionViewSource)(this.FindResource("dsSalesRoom")));
            _dsPrograms   = ((CollectionViewSource)(this.FindResource("dsPrograms")));
            _dsLeadSource = ((CollectionViewSource)(this.FindResource("dsLeadSource")));
            _dsGifts      = ((CollectionViewSource)(this.FindResource("dsGifts")));

            _dsGiftsReceiptDetailCancel = ((CollectionViewSource)(this.FindResource("dsGiftsReceiptDetailCancel")));
            _dsGiftsReceiptDetail       = ((CollectionViewSource)(this.FindResource("dsGiftsReceiptDetail")));

            // Cargamos los Sales Room
            _dsSalesRoom.Source = frmHost._lstSalesRoom;
            //Cargamos los Programs
            _dsPrograms.Source = frmHost._lstPrograms;
            // Cargamos los LeadSources
            _dsLeadSource.Source = frmHost._lstLeadSources;
            // Cargamos los Gifts
            _dsGifts.Source = frmHost._lstGifts;

            // Obtenemos los regalos a cancelar.
            List <GiftsReceiptDetailCancel> lstResultCancel = BRGiftsReceiptDetail.GetGiftsReceiptDetailCancel(_ReceiptID, _EnumExternalProduct);

            _obsGiftsCancel = new ObservableCollection <GiftsReceiptDetailCancel>(lstResultCancel);
            _dsGiftsReceiptDetailCancel.Source = _obsGiftsCancel;

            //Obtenemos los datos del Huesped.
            _Guest = await BRGuests.GetGuestShort(_GuestID);

            txtReceipt.Text            = $"{_ReceiptID}";
            txtGuestID.Text            = $"{ _GuestID}";
            txtNameInvitation.Text     = _Guest.Name;
            cboSalesRoom.SelectedValue = _Guest.gusr;

            // Si es Inhouse
            if (_Guest.lspg.Equals("IH"))
            {
                // Si es una invitacion inhouse externa
                if (string.IsNullOrEmpty(_Guest.guHReservID))
                {
                    PropertyOpera = _Guest.lsPropertyOpera;
                }
            }
            // Si es OutHouse
            else
            {
                PropertyOpera = _Guest.srPropertyOpera;
            }

            cboProgram.SelectedValue    = _Guest.lspg;
            cboLeadSource.SelectedValue = _Guest.gulsOriginal;
            txtReservation.Text         = _Guest.guHReservID == "" ? null : _Guest.guHReservID;
            dtpArrival.Value            = _Guest.guCheckInD;
            dtpDeparture.Value          = _Guest.guCheckOutD;
            txtQtyEPurses.Text          = $"{_Guest.guQtyGiftsCard}";
            txtAccountInvitation.Text   = _Guest.guAccountGiftsCard == "" ? null : _Guest.guAccountGiftsCard;

            // Monto maximo de reagalos
            txtMaxAuthGifts.Text = string.Format("{0:C2}", _MaxAuthGifts);

            // Totales de regalos
            txtTotalGiftsInvitation.Text = string.Format("{0:C2}", BRGiftsReceipts.CalculateTotalsGiftsInvitation(_GuestID));

            // Si se genera un recibo Exchange
            if (_Exchange)
            {
                txtTotalGiftsCancel.Text = string.Format("{0:C2}", 0.00);
            }
            // si se desea cancelar el recibo
            else
            {
                txtTotalGiftsCancel.Text = string.Format("{0:C2}", _TotalGifts);
            }

            txtTotalGiftsExchange.Text = string.Format("{0:C2}", 0.00);
            CalculateTotalGifts();

            // Totales del cargo
            txtgrcxcAdj.Text = string.Format("{0:C2}", _CurAdjustment);

            // Activamos la bandera para saber si se ajustaran costos CxC
            _applicationAdj = _CurAdjustment > 0 ? true : false;

            ReceiptsGifts.CalculateCharge(_GuestID, _FrmGiftsReceipt.cmbgrct.SelectedItem as ChargeTo, txtTotalCost, _isExchangeReceipt, ref txtgrcxcGifts,
                                          ref txtTotalCxC, ref _FrmGiftsReceipt.txtgrCxCAdj, ref _FrmGiftsReceipt._validateMaxAuthGifts, _Guest.gulsOriginal,
                                          ref _FrmGiftsReceipt.txtgrMaxAuthGifts, ref _FrmGiftsReceipt.txbgrMaxAuthGifts);

            // Si se desea cancelar el recibo
            if (!_Exchange)
            {
                stkGiftsExchange.Visibility = Visibility.Collapsed;
                WindowMain.Height           = 424; // Ajustamos la ventana
            }

            // Impedimos modificar los datos si el sistema esta en modo de solo lectura
            if (ConfigHelper.GetString("ReadOnly").ToUpper().Equals("TRUE"))
            {
                btnSave.Visibility = Visibility.Hidden;
            }

            // si se debe generar un recibo exchange
            if (_Exchange)
            {
                List <GiftsReceiptDetail> lstResult = await BRInvitsGifts.GetGiftsInvitationWithoutReceipt(0);

                _obsGifts                    = new ObservableCollection <GiftsReceiptDetail>(lstResult);
                _obsGiftsComplet             = new ObservableCollection <GiftsReceiptDetail>(lstResult);
                _dsGiftsReceiptDetail.Source = _obsGifts;
            }
            // Si se desea cancelar el recibo
            else
            {
                CheckAllCell(ref dtgCancel, _CancelField);
                TextBox x = null;
                ReceiptsGifts.CalculateTotalGifts(dtgCancel, EnumGiftsType.ReceiptGifts, ref txtTotalCost, ref x, ref x);
                dtgCancel.IsReadOnly = true;
            }
        }