//====================================================================================================
        public string DisplayPastReservation(string user_id)
        {
            string json;
            List <ReservationDetails> log = new List <ReservationDetails>();

            using (SqlConnection con = new SqlConnection(connString))
            {
                SqlCommand cmd = new SqlCommand("Main.GetPastReserveDetailsByUserID", 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);
                    p.courtId   = rdr.SafeGetInt32(9);
                    p.schedId   = rdr.SafeGetInt32(10);

                    log.Add(p);
                }
                con.Close();
            }
            json = JsonConvert.SerializeObject(log);

            return(json);
        }
        //==============================================================================================
        public string UpdateScheduleDates()
        {
            string json = string.Empty;
            string timeToday_s;

            DateTime today = DateTime.Today;

            DateTime t = DateTime.Now;

            timeToday_s = t.ToString("HH:mm:ss");
            TimeSpan timeToday = TimeSpan.Parse(timeToday_s);

            DateTime scheduleDate;

            List <ReservationDetails> log = new List <ReservationDetails>();

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

                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    TimeSpan?          time = new TimeSpan();
                    DateTime           date = new DateTime();
                    ReservationDetails p    = new ReservationDetails();

                    p.schedId = rdr.SafeGetInt32(0);

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

                    p.reserveId = rdr.SafeGetByte(2);

                    time      = rdr.SafeGetTime(3);
                    p.EndTime = time.ToString();
                    log.Add(p);
                }
                con.Close();


                for (int i = 0; i < log.Count; i++)
                {
                    scheduleDate = DateTime.Parse(log[i].DateEffective);
                    TimeSpan end = TimeSpan.Parse(log[i].EndTime);
                    if (today > scheduleDate) // if schedule time is already past to date
                    {
                        if (log[i].reserveId == 2 || log[i].reserveId == 1)
                        {
                            cmd             = new SqlCommand("Main.SetReservationStatusAndReservationDetails", con);
                            cmd.CommandType = CommandType.StoredProcedure;

                            con.Open();
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("res", SqlDbType.TinyInt).Value = log[i].reserveId.ToDbParameter();
                            cmd.Parameters.Add("sched", SqlDbType.Int).Value   = log[i].schedId.ToDbParameter();

                            cmd.ExecuteNonQuery();
                            con.Close();
                        }
                    }
                    else if (today == scheduleDate) // if date is same check time
                    {
                        int a = TimeSpan.Compare(end, timeToday);

                        if (a < 0) // if schedule endtime is already past to date
                        {
                            if (log[i].reserveId == 2 || log[i].reserveId == 1)
                            {
                                cmd             = new SqlCommand("Main.SetReservationStatusAndReservationDetails", con);
                                cmd.CommandType = CommandType.StoredProcedure;

                                con.Open();
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.Add("res", SqlDbType.TinyInt).Value = log[i].reserveId.ToDbParameter();
                                cmd.Parameters.Add("sched", SqlDbType.Int).Value   = log[i].schedId.ToDbParameter();

                                cmd.ExecuteNonQuery();
                                con.Close();
                            }
                        }
                    }
                    else // if date is not same not past
                    {
                        json = "nothing";
                    }
                }
            }

            return(json);
        }