public frmHotelEditor(int hotelId) { ctbo = new BO.CityBO(); InitializeComponent(); hbo = new BO.HotelBO(); _hotel = hbo.GetHotel(hotelId); InitializeDataView(); }
public frmHotelEditor() { InitializeComponent(); hbo = new BO.HotelBO(); _hotel = new Models.Hotel(); InitializeDataView(); ctbo = new BO.CityBO(); }
void BindCities() { var cbo = new BO.CityBO(); var cc = cbo.GetQueryable().ToList(); var bs = new BindingSource(); bs.DataSource = cc; dgCities.DataSource = bs; }
public frmCityEditor(int id) { InitializeComponent(); cbo = new BO.CityBO(); _city = cbo.GetCity(id); }
public frmCityEditor() { InitializeComponent(); cbo = new BO.CityBO(); _city = new Models.City(); }
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"); }