//Hotel's actions private void doHotelRate() { Model.HotelRate mAirport = new Model.HotelRate(); Controller.HotelRate cAirport = new Controller.HotelRate(); if (cmbHotelRateActions.SelectedIndex == 0)//insert { MessageBox.Show("Please, choose an action!"); } else if (cmbHotelRateActions.SelectedIndex == 1)//insert { saveHotelRate(); } else if (cmbHotelRateActions.SelectedIndex == 2)//delete { int select = dgvHotelRate.CurrentCell.RowIndex; mAirport.id = Convert.ToInt32(dgvHotelRate.Rows[select].Cells["cHotelRateId"].Value.ToString()); cAirport = new Controller.HotelRate(mAirport); cAirport.delete(); refreshHotelRate(); } else if (cmbHotelRateActions.SelectedIndex == 3)//update { dgvHotelRate.Enabled = true; saveHotelRate(); } else if (cmbHotelRateActions.SelectedIndex == 4)//refresh { refreshHotelRate(); } }
//saves an hotel's rate private void saveHotelRate() { try { if (!cmbHotelRate.Enabled) { Model.HotelRate mAirport = new Model.HotelRate(); int select = dgvHotelRate.CurrentCell.RowIndex; mAirport.id_hotel = Convert.ToInt32(dgvHotelRate.Rows[select].Cells["cHotelRateHotel"].Value.ToString()); mAirport.price = Convert.ToInt32(dgvHotelRate.Rows[select].Cells["cHotelRatePrice"].Value.ToString()); mAirport.id = Convert.ToInt32(dgvHotelRate.Rows[select].Cells["cHotelRateId"].Value.ToString()); Controller.HotelRate cAirport = new Controller.HotelRate(mAirport); cAirport.insert(); refreshHotelRate(); return; } else { Model.HotelRate mAirport = new Model.HotelRate(); mAirport.id_hotel = Convert.ToInt32(cmbHotelRate.SelectedValue); mAirport.price = Convert.ToInt32(dgvHotelRate.Rows[dgvHotelRate.Rows.Count - 1].Cells["cHotelRatePrice"].Value.ToString()); Controller.HotelRate cAirport = new Controller.HotelRate(mAirport); cAirport.insert(); } refreshHotelRate(); } catch { } }
public HotelRate(Model.HotelRate hotel) { this.hotel = hotel; }
public HotelRate() { this.hotel = new Model.HotelRate(); }