Ejemplo n.º 1
0
        public string AddReserveDetails(ReservationDetails res)
        {
            string msg;

            SqlConnection con = new SqlConnection(connString);

            con.Open();

            SqlCommand command = new SqlCommand("Main.AddReservationDetailsAndUpdateCourtSchedule", con);

            command.CommandType = CommandType.StoredProcedure;
            var date = DateTime.Now;

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add("@sched", SqlDbType.NVarChar, 50).Value     = res.schedId.ToDbParameter();
            command.Parameters.Add("@user", SqlDbType.NVarChar, 15).Value      = res.userId.ToDbParameter();
            command.Parameters.AddWithValue("@date", SqlDbType.DateTime).Value = date;

            command.ExecuteNonQuery();

            con.Close();


            msg = "You have Reserve a Court!";

            return(msg);
        }
Ejemplo n.º 2
0
        public List <ReservationDetails> DisplayReservation(int user_id)
        {
            List <ReservationDetails> log = new List <ReservationDetails>();

            using (SqlConnection con = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand("Main.GetActiveReserveDetailsByUserID", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("user", user_id);

                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    TimeSpan?          time = new TimeSpan();
                    DateTime           date = new DateTime();
                    ReservationDetails p    = new ReservationDetails();
                    p.Name     = rdr.SafeGetString(0);
                    p.Province = rdr.SafeGetString(1);
                    p.City     = rdr.SafeGetString(2);

                    time        = rdr.SafeGetTime(3);
                    p.StartTime = time.ToString();

                    time      = rdr.SafeGetTime(4);
                    p.EndTime = time.ToString();

                    date            = rdr.SafeGetDateTime(5);
                    p.DateEffective = date.ToString("d");

                    p.Address   = rdr.SafeGetString(6);
                    p.Status    = rdr.SafeGetString(7);
                    p.reserveId = rdr.SafeGetInt32(8);

                    log.Add(p);
                }
                con.Close();
            }
            return(log);
        }