コード例 #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
            }
        }
コード例 #2
0
        /// <summary>
        /// Valida que un registro cumpla con los filtros de grid
        /// </summary>
        /// <param name="hotelGroup">onjeto a valida</param>
        /// <returns>True. Si cumple | False. No cumple</returns>
        /// <history>
        /// [emoguel] created 12/05/2016
        /// </history>
        private bool ValidateFilter(HotelGroup hotelGroup)
        {
            if (_nStatus != -1)
            {
                if (hotelGroup.hgA != Convert.ToBoolean(_nStatus))
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_hotelGroupFilter.hgID))
            {
                if (hotelGroup.hgID != _hotelGroupFilter.hgID)
                {
                    return(false);
                }
            }

            if (!string.IsNullOrWhiteSpace(_hotelGroupFilter.hgN))
            {
                if (!hotelGroup.hgN.Contains(_hotelGroupFilter.hgN, StringComparison.OrdinalIgnoreCase))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: BRHotelGroups.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Agrega|Actualiza registros en el catalogo HotelGroup
        /// Asigan|Desasigna Hotels de HotelGroups
        /// </summary>
        /// <param name="hotelGrooup">Objeto a guardar</param>
        /// <param name="blnUpdate">True. Actualiza | False. Inserta</param>
        /// <param name="lstAdd">Lista a asignar al Hotel Group</param>
        /// <param name="lstDel">Lista a Eliminar del grupo</param>
        /// <returns>-1. Existe un registro con el mismo ID | 0. No se pudo guardar | 1. Se guardó correctamente</returns>
        /// <history>
        /// [emoguel] created 13/05/2016
        /// [emoguel] modified 27/06/2016
        /// </history>
        public async static Task <int> SaveHotelGroup(HotelGroup hotelGrooup, bool blnUpdate, List <Hotel> lstAdd, List <Hotel> lstDel)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    using (var transacction = dbContext.Database.BeginTransaction(System.Data.IsolationLevel.Serializable))
                    {
                        try
                        {
                            #region Update
                            if (blnUpdate)
                            {
                                dbContext.Entry(hotelGrooup).State = EntityState.Modified;
                            }
                            #endregion

                            #region Add
                            else
                            {
                                if (dbContext.HotelsGroups.Where(hoo => hoo.hgID == hotelGrooup.hgID).FirstOrDefault() != null)
                                {
                                    return -1;
                                }
                                else
                                {
                                    dbContext.HotelsGroups.Add(hotelGrooup);
                                }
                            }
                            #endregion

                            #region List Add
                            dbContext.Hotels.AsEnumerable().Where(ho => lstAdd.Any(hoo => hoo.hoID == ho.hoID)).ToList().ForEach(ho =>
                            {
                                ho.hoGroup = hotelGrooup.hgID;
                                dbContext.Entry(ho).State = EntityState.Modified;
                            });
                            #endregion

                            #region ListDel
                            dbContext.Hotels.AsEnumerable().Where(ho => lstDel.Any(hoo => hoo.hoID == ho.hoID)).ToList().ForEach(ho =>
                            {
                                ho.hoGroup = null;
                                dbContext.Entry(ho).State = EntityState.Modified;
                            });
                            #endregion

                            int nRes = dbContext.SaveChanges();
                            transacction.Commit();
                            return nRes;
                        }
                        catch
                        {
                            transacction.Rollback();
                            return 0;
                        }
                    }
                }
            }));
        }
コード例 #4
0
ファイル: BRHotelGroups.cs プロジェクト: jackjet870/IM-2
        /// <summary>
        /// Obtiene registros del catalogo HotelGroups
        /// </summary>
        /// <param name="hotelGroup">Objeto con filtros adicionales</param>
        /// <param name="nStatus">-1. Todos los registros | 0. Registros inactivos | 1. Registros Activos</param>
        /// <returns>Lista de tipo HotelGroup</returns>
        /// <history>
        /// [emoguel] created 29/03/2016
        /// [emoguel] modified 27/06/2016 se volvió async
        /// </history>
        public async static Task <List <HotelGroup> > GetHotelGroups(HotelGroup hotelGroup = null, int nStatus = -1)
        {
            return(await Task.Run(() =>
            {
                using (var dbContext = new IMEntities(ConnectionHelper.ConnectionString()))
                {
                    var query = from hg in dbContext.HotelsGroups
                                select hg;

                    if (nStatus != -1)//Filtro por estatus
                    {
                        bool blnEstatus = Convert.ToBoolean(nStatus);
                        query = query.Where(hg => hg.hgA == blnEstatus);
                    }

                    if (hotelGroup != null)                              //Verificamos si tenemos un objeto
                    {
                        if (!string.IsNullOrWhiteSpace(hotelGroup.hgID)) //Filtro por ID
                        {
                            query = query.Where(hg => hg.hgID == hotelGroup.hgID);
                        }

                        if (!string.IsNullOrWhiteSpace(hotelGroup.hgN))//Filtro por descripcion
                        {
                            query = query.Where(hg => hg.hgN.Contains(hotelGroup.hgN));
                        }
                    }

                    return query.OrderBy(hg => hg.hgN).ToList();
                }
            }));
        }
コード例 #5
0
        // GET: Hotels/Create
        public async Task <IActionResult> Create(Guid id)
        {
            HotelGroup hotelgroup = await _context.HotelGroups.SingleOrDefaultAsync(s => s.HotelGroupID == id);

            if (hotelgroup == null)
            {
                return(NotFound());
            }
            Hotel newhotel = new Hotel {
                HotelGroupID = id, HotelDate = DateTime.Today, ExpirationDate = DateTime.Today.AddMonths(6), Dealer = "Netera Software", Name = hotelgroup.Name
            };

            return(View(newhotel));
        }
コード例 #6
0
        // GET: Branches/Edit/5
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var branch = await _context.Branches.Include(r => r.Vardata).AsNoTracking().Include(r => r.VardataReservations).AsNoTracking().SingleOrDefaultAsync(m => m.BranchID == id);

            if (branch == null)
            {
                return(NotFound());
            }
            Hotel      hotel      = _context.Hotels.Include(r => r.HotelGroup).SingleOrDefault(r => r.HotelID == branch.HotelID);
            HotelGroup hotelgroup = await _context.HotelGroups.Include(r => r.Hotels).SingleOrDefaultAsync(s => s.HotelGroupID == hotel.HotelGroupID);

            ViewData["HotelID"]            = new SelectList(hotelgroup.Hotels, "HotelID", "Name", branch.HotelID);
            ViewData["UsualNationalityID"] = new SelectList(_context.Nationalities.OrderBy(m => m.GreekName).AsEnumerable(), "NationalityID", "GreekName", branch.HotelID);
            return(View(branch));
        }
コード例 #7
0
        /// <summary>
        /// Llena el grid de Hotel Groups
        /// </summary>
        /// <param name="hotelGroup">Objeto a seleccionar</param>
        /// <history>
        /// [emoguel] created 12/05/2016
        /// </history>
        private async void LoadHotelGroups(HotelGroup hotelGroup = null)
        {
            try
            {
                status.Visibility = Visibility.Visible;
                List <HotelGroup> lstHotelsGroup = await BRHotelGroups.GetHotelGroups(_hotelGroupFilter, _nStatus);

                dgrHotelGroups.ItemsSource = lstHotelsGroup;
                int nIndex = 0;
                if (lstHotelsGroup.Count > 0 && hotelGroup != null)
                {
                    hotelGroup = lstHotelsGroup.Where(ho => ho.hgID == hotelGroup.hgID).FirstOrDefault();
                    nIndex     = lstHotelsGroup.IndexOf(hotelGroup);
                }
                GridHelper.SelectRow(dgrHotelGroups, nIndex);
                StatusBarReg.Content = lstHotelsGroup.Count + " Hotel Groups";
                status.Visibility    = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                UIHelper.ShowMessage(ex);
            }
        }
コード例 #8
0
        /// <summary>
        /// Actualiza los registros del grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <history>
        /// [emoguel] created 12/05/2016
        /// </history>
        private void btnRef_Click(object sender, RoutedEventArgs e)
        {
            HotelGroup hotelGroup = (HotelGroup)dgrHotelGroups.SelectedItem;

            LoadHotelGroups(hotelGroup);
        }
コード例 #9
0
        public async Task <IActionResult> Create([Bind("Name")] HotelGroup hotelGroup)
        {
            if (ModelState.IsValid)
            {
                hotelGroup.HotelGroupID = Guid.NewGuid();
                _context.Add(hotelGroup);

                Hotel hotel = new Hotel
                {
                    HotelGroup     = hotelGroup,
                    HotelID        = Guid.NewGuid(),
                    ExpirationDate = DateTime.Today.AddMonths(6),
                    Name           = hotelGroup.Name,
                    HotelDate      = DateTime.Today
                };

                _context.Add(hotel);

                //----------------------------------------------------------------
                Department Room = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Δωμάτια", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.13M, DisplayOrder = 1
                };
                Department Breakfast = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Πρωϊνό", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 2
                };
                Department Lunch = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Γεύμα", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 3
                };
                Department Dinner = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "Δείπνο", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 4
                };
                Department AllInclusive = new Department {
                    DepartmentID = Guid.NewGuid(), Hotel = hotel, Name = "All Inclusive", IsActive = true, TaxPrcentage = 0.005M, VatPercentage = 0.24M, DisplayOrder = 5
                };

                _context.AddRange(new[] { Room, Breakfast, Lunch, Dinner, AllInclusive });

                Board RR = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "RR", Name = "Room Rate", DisplayOrder = 1
                };
                Board BB = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "BB", Name = "Bed n' breakfast", DisplayOrder = 2
                };
                Board HL = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "HL", Name = "Half Lunch", DisplayOrder = 3
                };
                Board HB = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "HB", Name = "Half Board", DisplayOrder = 4
                };
                Board FB = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "FB", Name = "Full Board", DisplayOrder = 5
                };
                Board AI = new Board {
                    BoardID = Guid.NewGuid(), Hotel = hotel, Abbrevation = "AL", Name = "All Inclusive", DisplayOrder = 6
                };

                _context.AddRange(new[] { RR, BB, HL, HB, FB, AI });

                BoardPart RR_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = RR, Department = Room, ParticipationRate = 1
                };

                BoardPart BB_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = BB, Department = Room, ParticipationRate = 0.95d
                };
                BoardPart BB_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = BB, Department = Breakfast, ParticipationRate = 0.05d
                };

                BoardPart HL_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HL, Department = Room, ParticipationRate = 0.85d
                };
                BoardPart HL_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HL, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart HL_Lunch = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HL, Department = Lunch, ParticipationRate = 0.1d
                };

                BoardPart HB_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HB, Department = Room, ParticipationRate = 0.85d
                };
                BoardPart HB_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HB, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart HB_Dinner = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = HB, Department = Dinner, ParticipationRate = 0.1d
                };

                BoardPart FB_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Room, ParticipationRate = 0.75d
                };
                BoardPart FB_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart FB_Lunch = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Lunch, ParticipationRate = 0.1d
                };
                BoardPart FB_Dinner = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = FB, Department = Dinner, ParticipationRate = 0.1d
                };

                BoardPart AI_Room = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Room, ParticipationRate = 0.7d
                };
                BoardPart AI_Breakfast = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Breakfast, ParticipationRate = 0.05d
                };
                BoardPart AI_Lunch = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Lunch, ParticipationRate = 0.1d
                };
                BoardPart AI_Dinner = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = Dinner, ParticipationRate = 0.1d
                };
                BoardPart AI_AI = new BoardPart {
                    BoardPartID = Guid.NewGuid(), Board = AI, Department = AllInclusive, ParticipationRate = 0.05d
                };

                _context.AddRange(new[] { RR_Room,
                                          BB_Room, BB_Breakfast,
                                          HL_Room, HL_Breakfast, HL_Lunch,
                                          HB_Room, HB_Breakfast, HB_Dinner,
                                          FB_Room, FB_Breakfast, FB_Lunch, FB_Dinner,
                                          AI_Room, AI_Breakfast, AI_Lunch, AI_Dinner, AI_AI });
                //----------------------------------------------------------------

                HotelVardataPlan hotelvardataplan = new HotelVardataPlan {
                    Hotel = hotel
                };
                _context.Add(hotelvardataplan);

                HotelVardataInvoice hotelvardatainvoice = new HotelVardataInvoice {
                    Hotel = hotel
                };
                _context.Add(hotelvardatainvoice);

                Branch branch = new Branch {
                    Hotel = hotel, Name = hotel.Name
                };
                _context.Add(branch);

                BranchVardata branchvardata = new BranchVardata {
                    Branch = branch
                };
                _context.Add(branchvardata);

                Nationality usualnationality = await _context.Nationalities.FirstOrDefaultAsync();

                BranchVardataReservation branchvardatareservation = new BranchVardataReservation {
                    Branch = branch, UsualNationality = usualnationality
                };
                _context.Add(branchvardatareservation);

                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(hotelGroup));
        }