List <BindItem> GetBindItemList()
        {
            var entities = new Models.PriceCheckerEntities();
            var arbo     = new BO.AllotmentRecordBO(entities);
            var rtbo     = new BO.AllotmentRoomTypeBO(entities);
            var hbo      = new BO.HotelBO(entities);

            var rr  = arbo.GetQueryable();
            var rts = rtbo.GetQueryable();
            var hh  = hbo.GetQueryable(null);
            var qq  = from r in rr
                      join rt in rts on r.AllotmentRoomTypeId equals rt.RecordId
                      join h in hh on rt.HotelId equals h.HotelId
                      where h.CheckAllotment & r.CurrentAllotment < rt.DefaultAllotment && !r.Acknowledged & !rt.IgnoreThisRoomType
                      select new BindItem
            {
                Acknowledged  = r.Acknowledged,
                HotelId       = h.HotelId,
                HotelName     = h.HotelName,
                AllotmentDate = r.AllotmentDate,
                RecordId      = r.RecordId,
                RoomName      = rt.RoomName,
                //    Allotment = r.CurrentAllotment
            };
            var lst = qq.OrderBy(q => q.HotelName).ThenBy(q => q.RoomName).ToList();

            return(lst);
        }
        void BindAllotmentHotels()
        {
            var hbo = new BO.HotelBO();
            var hh  = hbo.GetQueryable(null).Where(h => h.CheckAllotment).OrderBy(h => h.HotelName).ToList();

            dgAllotmentHotels.DataSource = hh;
        }
Esempio n. 3
0
        void BindHotels()
        {
            hbo = new BO.HotelBO();
            var hh = hbo.GetQueryable(null).Where(h => h.CheckAllotment).OrderBy(h => h.HotelName).ToList();

            lstHotelList.DataSource = hh;
            lstHotelList.ClearSelected();
        }
Esempio n. 4
0
        void BindHotels()
        {
            var star    = string.IsNullOrEmpty(txtStar.Text) ? 0 : int.Parse(txtStar.Text);
            var hbo     = new BO.HotelBO();
            var ihotels = hbo.GetQueryable(null).Where(h => h.StarRating >= star);

            if (cxActiveOnly.Checked)
            {
                ihotels = ihotels.Where(h => !h.IsDuplicated);
            }

            var bs = new BindingSource();

            bs.DataSource       = ihotels.OrderBy(x => x.HotelName).ToList();
            dgHotels.DataSource = bs;
        }
Esempio n. 5
0
 private void btnRun_Click(object sender, EventArgs e)
 {
     if (!Modules.BrowserSupport.BrowserIsOpenned())
     {
         MessageBox.Show("Open browser first and Login first");
         return;
     }
     if (cxAllHotels.Checked)
     {
         _selectedHotels = hbo.GetQueryable(null).Where(h => h.CheckAllotment).ToList();
     }
     else
     {
         _selectedHotels = new List <Models.Hotel>();
         foreach (var item in lstHotelList.SelectedItems)
         {
             _selectedHotels.Add((Models.Hotel)item);
         }
     }
     InitializeWorker();
     _wk.RunWorkerAsync();
 }
Esempio n. 6
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            var dlg = new OpenFileDialog();

            dlg.ShowDialog();
            var path = dlg.FileName;

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            var dicColumns = new Dictionary <string, int>();
            var csv        = new CsvReader(File.OpenText(path));

            csv.Read();
            csv.ReadHeader();
            var headerRow = csv.Context.HeaderRecord;

            for (var i = 0; i < headerRow.Count(); i++)
            {
                var name = headerRow[i];
                dicColumns.Add(name, i);
            }
            var records = csv.GetRecords <CsvRow>();

            foreach (var record in records)
            {
                var hbo = new BO.HotelBO();

                var hotel = hbo.GetHotel(record.HotelName);
                if (hotel == null)
                {
                    hotel = hbo.GetQueryable(null).SingleOrDefault(h => h.HMSID == record.Id);
                }
                if (hotel == null)
                {
                    hotel = new Models.Hotel();
                    hotel.CheckAllotment = true;
                }
                hotel.HotelName  = record.HotelName;
                hotel.HMSID      = record.Id;
                hotel.StarRating = decimal.Parse(record.StarRating);
                if (hotel.CityId == 43 || hotel.CityId == 0)//43 is unknown
                {
                    var cbo = new BO.CityBO();
                    var c   = cbo.GetQueryable().FirstOrDefault(f => f.CityCode == record.CityCode);
                    if (c == null)
                    {
                        c            = new Models.City();
                        c.CityCode   = record.CityCode;
                        c.CityName   = record.CityCode;
                        c.HasAirport = false;
                        cbo.Add(c);
                    }
                    hotel.CityId = c.CityId;
                }
                if (hotel.HotelId == 0)
                {
                    hbo.Add(hotel);
                }
                else
                {
                    hbo.Save();
                }
            }
            MessageBox.Show("Done");
        }