public Reservation getReservation() { Reservation model = new Reservation(); SqlCeCommand cmd = new SqlCeCommand("Select * from Reservation " + "inner join RoomInformation on Reservation.RoomID = RoomInformation.RoomID " + "inner join UserInformation on Reservation.UserID = UserInformation.User_ID where Reservation.ReservationID = @ReservationID", conn); cmd.Parameters.AddWithValue("@ReservationID", this._reservation.ReservationID); SqlCeDataAdapter adapter = new SqlCeDataAdapter(); adapter.SelectCommand = cmd; DataSet setdata = new DataSet(); adapter.Fill(setdata, "Reservation"); model.AppointmentID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[0].ToString()); model.UserID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[1].ToString()); model.RoomID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[2].ToString()); model.ReservationDate = DateTime.Parse(setdata.Tables[0].Rows[0].ItemArray[3].ToString()); model.ReservationAmount = setdata.Tables[0].Rows[0].ItemArray[4].ToString(); model.ValidTill = DateTime.Parse(setdata.Tables[0].Rows[0].ItemArray[5].ToString()); model.ReservationType = setdata.Tables[0].Rows[0].ItemArray[6].ToString(); model.RoomAccount.RoomID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[2].ToString()); model.RoomAccount.ApartmentName = setdata.Tables[0].Rows[0].ItemArray[8].ToString(); model.RoomAccount .FullAddress= setdata.Tables[0].Rows[0].ItemArray[19].ToString(); model.RoomAccount.RoomType = setdata.Tables[0].Rows[0].ItemArray[12].ToString(); model.RoomAccount.RoomForRent = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[11].ToString()); model.RoomAccount.RoomForSale = bool.Parse(setdata.Tables[0].Rows[0].ItemArray[10].ToString()); model.RoomAccount.RoomPrice = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[14].ToString()); model.RoomAccount .RoomStatus= setdata.Tables[0].Rows[0].ItemArray[23].ToString(); model.RoomAccount.Username = setdata.Tables[0].Rows[0].ItemArray[51].ToString(); Account AccountModel = new Account(); AccountModel.ID = model.UserID; AccountRepository _accountRepository = new AccountRepository(AccountModel); model.Reserver = _accountRepository.getDataByID().username; return model; }
public Appointment getAppointment() { Appointment model = new Appointment(); SqlCeCommand cmd = new SqlCeCommand("Select * from Appointment " + "inner join RoomInformation on Appointment.RoomID = RoomInformation.RoomID " + "inner join UserInformation on Appointment.UserID = UserInformation.User_ID where Appointment.AppointmentID = @AppointmentID", conn); cmd.Parameters.AddWithValue("@AppointmentID", this._appointment.AppointmentID); SqlCeDataAdapter adapter = new SqlCeDataAdapter(); adapter.SelectCommand = cmd; DataSet setdata = new DataSet(); adapter.Fill(setdata, "Appointment"); model.AppointmentID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[0].ToString()); model.RoomID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[1].ToString()); model.UserID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[2].ToString()); model.AppointmentDate = DateTime.Parse(setdata.Tables[0].Rows[0].ItemArray[3].ToString()); model.Status = setdata.Tables[0].Rows[0].ItemArray[4].ToString(); model.Respond = setdata.Tables[0].Rows[0].ItemArray[5].ToString(); model.RoomAcc.RoomID = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[1].ToString()); model.RoomAcc.ApartmentName = setdata.Tables[0].Rows[0].ItemArray[7].ToString(); model.RoomAcc.RoomForSale = bool.Parse (setdata.Tables[0].Rows[0].ItemArray[8].ToString()); model.RoomAcc.RoomForRent = bool.Parse (setdata.Tables[0].Rows[0].ItemArray[9].ToString()); model.RoomAcc.RoomPrice = Int64.Parse(setdata.Tables[0].Rows[0].ItemArray[12].ToString()); model.RoomAcc.Username = setdata.Tables[0].Rows[0].ItemArray [49].ToString (); Account AccountModel = new Account(); AccountModel.ID = model.UserID; AccountRepository _accountRepository = new AccountRepository(AccountModel); model.Appointee = _accountRepository.getDataByID().username; return model; }