Example #1
0
        /// <summary>
        /// Carga los componentes y la informacion inicial
        /// </summary>
        /// <history>
        /// [vipacheco] [vipacheco] 12/Mayo/2016 Created
        /// </history>
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            CollectionViewSource _dsGiftsReceiptsAdditional = ((CollectionViewSource)(this.FindResource("dsGiftsReceiptsAdditional")));

            // Obtenemos los Gifts Adicionales
            _lstGiftsAdditional = BRGiftsReceipts.GetGiftsReceiptsAdditional(_GuestID);

            // Veririficamos si se encontro alguna informacion
            if (_lstGiftsAdditional != null)
            {
                if (_lstGiftsAdditional.Count > 0)
                {
                    _dsGiftsReceiptsAdditional.Source = _lstGiftsAdditional;
                }
                else
                {
                    btnCancel.Visibility = Visibility.Collapsed;
                    btnSave.Visibility   = Visibility.Collapsed;
                }
            }
            else
            {
                btnCancel.Visibility = Visibility.Collapsed;
                btnSave.Visibility   = Visibility.Collapsed;
            }
        }
Example #2
0
        /// <summary>
        /// Guarda el recibo de regalos exchange
        /// </summary>
        /// <history>
        /// [vipacheco] 27/Mayo/2016 Created
        /// </history>
        private async Task SaveReceiptExchange()
        {
            // obtenemos los datos del recibo
            GiftsReceipt _GRResult = await BRGiftsReceipts.GetGiftReceipt(_ReceiptID);

            // Construimos el nuevo GiftsReceipts
            GiftsReceipt _GiftsReceipt = new GiftsReceipt()
            {
                grNum            = txtgrNum.Text,
                grD              = frmHost.dtpServerDate,
                grgu             = _GRResult.grgu,
                grExchange       = true,
                grGuest          = _GRResult.grGuest,
                grPax            = _GRResult.grPax,
                grHotel          = _GRResult.grHotel,
                grRoomNum        = _GRResult.grRoomNum,
                grpe             = _GRResult.grpe,
                grlo             = _GRResult.grlo,
                grls             = _GRResult.grls,
                grsr             = _GRResult.grsr,
                grWh             = _GRResult.grWh,
                grMemberNum      = _GRResult.grMemberNum,
                grHost           = _GRResult.grHost,
                grComments       = txtgrComments.Text,
                grDeposit        = 0,
                grDepositTwisted = 0,
                grcu             = "US",
                grcxcPRDeposit   = 0,
                grcucxcPRDeposit = "US",
                grCxCClosed      = false,
                grExchangeRate   = 0,
                grct             = _GRResult.grct,
                grMaxAuthGifts   = _GRResult.grMaxAuthGifts,
                grcxcGifts       = 0,
                grcxcComments    = null,
                grTaxiIn         = 0,
                grTaxiOut        = 0,
                grCancel         = false,
                grClosed         = false,
                grCxCAppD        = null,
                grTaxiOutDiff    = 0,
                grGuest2         = _GRResult.grGuest2,
                grcucxcTaxiOut   = _GRResult.grcucxcTaxiOut,
                grpt             = _GRResult.grpt
            };

            // Guardamos el Gift Receipt
            ReceiptExchangeID = await BRGiftsReceipts.SaveGiftReceipt(_GiftsReceipt);

            // Guardamos el historico del recibo
            await BRGiftsReceiptLog.SaveGiftsReceiptsLog(ReceiptExchangeID, Context.User.User.peID);
        }
        /// <summary>
        /// Obtiene el Gift y envie los datos modificados en el grid
        /// </summary>
        /// <param name="cxcData">Registro del grid modificado</param>
        /// <returns></returns>
        /// <history>
        /// [michan] 17/06/2016 Created
        /// </history>
        public async Task <GiftsReceipt> SetCxCDataToGiftsReceipt(CxCData cxcData)
        {
            GiftsReceipt giftsReceipt = await BRGiftsReceipts.GetGiftReceipt(cxcData.grID);

            //var cxcGR = lstCxCData.SingleOrDefault(cxc => cxc.grID == giftsReceipt.grID);
            giftsReceipt.grCxCAppD         = cxcData.grCxCAppD;
            giftsReceipt.grAuthorizedBy    = (String.IsNullOrEmpty(cxcData.grAuthorizedBy)) ? null : cxcData.grAuthorizedBy;
            giftsReceipt.grAmountToPay     = cxcData.grAmountToPay;
            giftsReceipt.grup              = cxcData.grup;
            giftsReceipt.grcxcAuthComments = cxcData.grcxcAuthComments;
            giftsReceipt.grBalance         = cxcData.grBalance;
            return(giftsReceipt);
        }
Example #4
0
        /// <summary>
        /// Guarda los datos
        /// </summary>
        /// <history>
        /// [vipacheco] 26/Mayo/2016 Created
        /// </history>
        private async Task Save()
        {
            List <string> aGiftsCancelled = await CancelGifts();

            // si se cancelo al menos un regalo
            if (aGiftsCancelled.Count > 0)
            {
                _Cancelled = true;

                // si se debe generar un recibo exchange
                if (_Exchange)
                {
                    // guardamos el recibo de regalos exchange
                    await SaveReceiptExchange();

                    dtgExchange.IsReadOnly = true;
                    // si tiene regalos de intercambio
                    if (dtgExchange.Items.Count > 0)
                    {
                        // guardamos los regalos de intercambio
                        GiftsExchange.Save(ReceiptExchangeID, dtgExchange);

                        // Guardamos las promociones en Sistur
                        string msjSavePromotionsSistur = await SisturHelper.SavePromotionsSistur(ReceiptExchangeID, "", Context.User.User.peID);

                        if (!string.IsNullOrEmpty(msjSavePromotionsSistur))
                        {
                            UIHelper.ShowMessage(msjSavePromotionsSistur, MessageBoxImage.Information, "Save promotions in sistur");
                        }
                    }
                }

                // guardamos los regalos cancelados
                await GiftsCancel.Save(_ReceiptID, ReceiptExchangeID, aGiftsCancelled, useCxCCost, _giftsDataContext, _obsGifts, _obsGiftsCancel, _Exchange, _CancelField);

                // si se maneja el monto maximo de regalos
                if (_ValidateMaxAuthGifts)
                {
                    // actualizamos el cargo del recibo de regalos
                    decimal Charge     = Convert.ToDecimal(txtgrcxcGifts.Text.TrimStart('$'));
                    decimal Adjustment = Convert.ToDecimal(txtgrcxcAdj.Text.TrimStart('$'));
                    await BRGiftsReceipts.UpdateCharge(_GuestID, Charge, Adjustment);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Cancela los regalos
        /// </summary>
        /// <param name="GiftsCancelled"></param>
        /// <returns></returns>
        /// <history>
        /// [vipacheco] 26/Mayo/2016 Created
        /// </history>
        private async Task <List <string> > CancelGifts()
        {
            string        strGift = "", GiftsCancellled = "", GiftsNotCancellled = "";
            List <string> aGiftsToCancel = new List <string>();
            List <string> GiftsCancelled = new List <string>();

            // recorremos los regalos
            foreach (var item in dtgCancel.Items)
            {
                Type type     = item.GetType();
                var  property = type.GetProperties(BindingFlags.Public | BindingFlags.Instance).ToList();

                // Si el regalo se desea cancelar
                if (((bool)type.GetProperty(_CancelField).GetValue(item, null)) == true)
                {
                    strGift = (string)type.GetProperty("gegi").GetValue(item, null);

                    // si el regalo es manejado por un sistema externo
                    // y no es un paquete (solo aplica para el monedero electronico)
                    Gift _Gift = null;
                    if ((Common.IsExternalProduct(_EnumExternalProduct, strGift, ref _Gift)) && (_EnumExternalProduct != EnumExternalProduct.expElectronicPurse || _EnumExternalProduct == EnumExternalProduct.expElectronicPurse && _Gift.giPack))
                    {
                        // agregamos el regalo a la lista de regalos por cancelar
                        aGiftsToCancel.Add(strGift);

                        // Si es el monedero electronico
                        if (_EnumExternalProduct != EnumExternalProduct.expElectronicPurse)
                        {
                            if (await SisturHelper.CancelPromotionSistur(strGift, (string)type.GetProperty("gePVPPromotion").GetValue(item, null), cboProgram.SelectedValue.ToString(),
                                                                         cboLeadSource.SelectedValue.ToString(), PropertyOpera, _ReceiptID, txtReservation, GiftsCancelled))
                            {
                                // Cancelamos el regalo en origos
                                await BRGiftsReceipts.CancelGiftPromotionSistur(_ReceiptID, strGift);
                            }
                        }
                    }
                }
            }

            // si se cancelaron todos los regalos
            if (aGiftsToCancel.Count == GiftsCancelled.Count)
            {
                UIHelper.ShowMessage("Gifts were successfully cancelled", MessageBoxImage.Information, "Intelligence Marketing");
            }
            // si no se cancelaron todos los regalos
            else
            {
                // si no se pudo cancelar ningun regalo
                if (GiftsCancelled.Count <= 0)
                {
                    UIHelper.ShowMessage("Gifts were not cancelled", MessageBoxImage.Information, "Intelligence Marketing");
                }
                // si se pudo cancelar al menos un regalo
                else
                {
                    // recorremos los regalos que se deseaban cancelar
                    foreach (string _Gift in aGiftsToCancel)
                    {
                        // localizamos el regalo
                        Gift _giftResult = frmHost._lstGifts.Where(x => x.giID == _Gift).Single();

                        // buscamos el regalo en el arreglo de regalos cancelados
                        int iIndex = GiftsCancelled.IndexOf(_Gift);

                        // si el regalo fue cancelado
                        if (iIndex > 0)
                        {
                            GiftsCancellled += _giftResult.giN + "\r\n";
                        }
                        // si el regalo no fue cancelado
                        else
                        {
                            GiftsNotCancellled += _giftResult.giN + "\r\n";
                        }
                    }
                    UIHelper.ShowMessage("The following gifts were cancelled from the account: \r\n" + GiftsCancellled + "\r\n\r\n" + "But the following gifts were not cancelled from the account: \r\n" + GiftsNotCancellled, MessageBoxImage.Exclamation, "Intelligence Marketing");
                }
            }

            return(GiftsCancelled);
        }
Example #6
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;
            }
        }
Example #7
0
        /// <summary>
        /// Agrega un recibo de regalos
        /// </summary>
        /// <param name="GuestID"></param>
        /// <returns></returns>
        /// <history>
        /// [vipacheco] 13/Mayo/2016 Created
        /// </history>
        private async Task <int> AddReceipt(int GuestID)
        {
            // Obtenemos los datos del huesped
            Guest _Guest = await BRGuests.GetGuest(GuestID);

            string _FullName  = Common.GetFullName(_Guest.guLastName1 ?? "", _Guest.guFirstName1 ?? "");
            string _FullName2 = Common.GetFullName(_Guest.guLastname2 ?? "", _Guest.guFirstName2 ?? "");

            bool boolTemp = false;

            // Creamos el recibo de regalos
            GiftsReceipt _GiftsReceipt = new GiftsReceipt
            {
                grNum             = null,
                grD               = _frmGiftsReceipt.dtpgrD.Value.Value,
                grgu              = _Guest.guID,
                grGuest           = _FullName.Length > _frmGiftsReceipt.txtgrGuest.MaxHeight ? _FullName.Substring(0, 20) : _FullName,
                grPax             = _Guest.guPax,
                grHotel           = _Guest.guHotel,
                grRoomNum         = _Guest.guRoomNum,
                grpe              = (_frmGiftsReceipt.cmbgrpe.SelectedItem as PersonnelShort).peID,
                grlo              = _frmGiftsReceipt.cmbgrlo.SelectedValue.ToString(),
                grls              = _frmGiftsReceipt.cmbgrlo.SelectedValue.ToString(),
                grsr              = _frmGiftsReceipt.cmbSalesRoom.SelectedValue.ToString(),
                grWh              = _frmGiftsReceipt.cmbSalesRoom.SelectedValue.ToString(),
                grMemberNum       = null,
                grHost            = (_frmGiftsReceipt.cmbgrHost.SelectedItem as PersonnelShort).peID,
                grComments        = null,
                grDeposit         = 0,
                grDepositTwisted  = 0,
                grcu              = "US",
                grcxcPRDeposit    = 0,
                grcucxcPRDeposit  = "US",
                grCxCClosed       = false,
                grExchangeRate    = 0,
                grct              = _frmGiftsReceipt.cmbgrct.SelectedValue.ToString(),
                grMaxAuthGifts    = _frmGiftsReceipt.CalculateMaxAuthGifts(_frmGiftsReceipt.cmbgrct.SelectedValue.ToString(), _Guest.guls, ref boolTemp),
                grcxcGifts        = 0,
                grcxcAdj          = 0,
                grcxcComments     = null,
                grTaxiIn          = 0,
                grTaxiOut         = 0,
                grCancel          = false,
                grClosed          = false,
                grCxCAppD         = null,
                grTaxiOutDiff     = 0,
                grGuest2          = _FullName2.Length > _frmGiftsReceipt.txtgrGuest2.MaxHeight ? _FullName2.Substring(0, 20) : _FullName2,
                grpt              = "CS",
                grReimpresion     = 0,
                grrm              = null,
                grAuthorizedBy    = null,
                grAmountToPay     = null,
                grup              = null,
                grcxcTaxiOut      = 0,
                grcucxcTaxiOut    = "US",
                grcxcAuthComments = null,
                grCancelD         = null,
                grAmountPaid      = 0,
                grBalance         = 0
            };

            // Guardamos el ReceiptGifts y Obtenemos el ID generado.
            return(await BRGiftsReceipts.SaveGiftReceipt(_GiftsReceipt));
        }