Esempio n. 1
0
 public frmHotelEditor(int hotelId)
 {
     ctbo = new BO.CityBO();
     InitializeComponent();
     hbo    = new BO.HotelBO();
     _hotel = hbo.GetHotel(hotelId);
     InitializeDataView();
 }
        private void frmAllotmentRoomTypeEditor_Load(object sender, EventArgs e)
        {
            if (_rt.RecordId != 0)
            {
                txtDefaultAllotment.Text = _rt.DefaultAllotment.ToString();
                txtRoomName.Text         = _rt.RoomName;
                cxIgnoreThis.Checked     = _rt.IgnoreThisRoomType;
                btnAction.Text           = "Update";
            }
            else
            {
                btnAction.Text           = "Add";
                btnDelete.Enabled        = false;
                txtDefaultAllotment.Text = "1";
            }
            var hbo = new BO.HotelBO();

            _hotel            = hbo.GetHotel(_rt.HotelId);
            lblHotelName.Text = _hotel.HotelName;
        }
Esempio n. 3
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");
        }