Ejemplo n.º 1
0
 public static bool CreateReservation(IEmployee employee, IMachine machine, DateTime day, 
     DateTime start, DateTime end, string jamType, string description)
 {
     bool result;
         try
         {
             ReservationEntity reservationEntity = new ReservationEntity(employee.Id, machine.Id,
             day, start, end, jamType, description);
             result = Persistens.CreateReservationEntity(reservationEntity);
             return result;
         }
         catch (Exception)
         {
             return false;
         }
 }
Ejemplo n.º 2
0
        public static bool CreateReservationEntity(ReservationEntity re)
        {
            try
            {
                connectDB();
                command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "int_group1_create_reservation";

                command.Parameters.AddWithValue("@day", re.Day);
                command.Parameters.AddWithValue("@time_start", re.Start);
                command.Parameters.AddWithValue("@time_end", re.End);
                command.Parameters.AddWithValue("@jam_type", re.JamType);
                command.Parameters.AddWithValue("@description", re.Description);
                command.Parameters.AddWithValue("@employee_id", re.User);
                command.Parameters.AddWithValue("@machine_id", re.Machine);
                command.ExecuteNonQuery();
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
Ejemplo n.º 3
0
        public static List<ReservationEntity> GetAllReservationEntities()
        {
            List<ReservationEntity> reservationList = new List<ReservationEntity>();

            try
            {
                connectDB();
                command = connection.CreateCommand();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "int_group1_get_reservation";

                dataReader = command.ExecuteReader();
                while (dataReader.Read())
                {
                    int reservation_id = int.Parse(dataReader["reservation_id"].ToString());
                    DateTime day = DateTime.Parse(dataReader["day"].ToString());
                    DateTime time_start = DateTime.Parse(dataReader["time_start"].ToString());
                    DateTime time_end = DateTime.Parse(dataReader["time_end"].ToString());
                    string jam_type = dataReader["jam_type"].ToString();
                    string description = dataReader["description"].ToString();
                    int employee_id = int.Parse(dataReader["employee_id"].ToString());
                    int machine_id = int.Parse(dataReader["machine_id"].ToString());

                    ReservationEntity reservation = new ReservationEntity(employee_id, machine_id, day, time_start,
                        time_end, jam_type, description, reservation_id);

                    reservationList.Add(reservation);
                }
                closeDB();
                return reservationList;
            }
            catch (Exception)
            {
                closeDB();
                return reservationList;
            }
        }
Ejemplo n.º 4
0
 public static bool UpdateReservation(IEmployee employee, IMachine machine, DateTime day,
     DateTime start, DateTime end, string jamType, string description, int reservationId)
 {
     try
     {
          ReservationEntity resEnt = new ReservationEntity(employee.Id, machine.Id,
             day, start, end, jamType, description, reservationId);
          Persistens.UpdateReservationEntity(resEnt);
          return true;
     }
     catch (Exception)
     {
         return false;
     }
 }