Beispiel #1
0
        public TeeTime GetTeeTime(DateTime RequestedDate, DateTime timeslot)
        {
            SqlConnection ClubBaistConnection = new SqlConnection();

            ClubBaistConnection.ConnectionString = @"Data Source= (LocalDB)\MSSQLLocalDB; 
                                Initial Catalog = aspnet-ClubBaistGolfManagement-53bc9b9d-9d6a-45d4-8429-2a2761773502;
                                                     Integrated Security = True; MultipleActiveResultSets=True";

            SqlCommand thecommand = new SqlCommand();

            thecommand.CommandType = CommandType.StoredProcedure;
            thecommand.Connection  = ClubBaistConnection;
            thecommand.CommandText = "FindTeeTime";

            SqlParameter date = new SqlParameter();

            date.ParameterName = "@date";

            date.SqlDbType = SqlDbType.DateTime;
            date.Value     = RequestedDate;
            date.Direction = ParameterDirection.Input;

            thecommand.Parameters.Add(date);

            SqlParameter time = new SqlParameter();

            time.ParameterName = "@time";

            time.SqlDbType = SqlDbType.DateTime;
            time.Value     = timeslot;
            time.Direction = ParameterDirection.Input;

            thecommand.Parameters.Add(time);

            ClubBaistConnection.Open();

            SqlDataReader theDataReader;

            theDataReader = thecommand.ExecuteReader();

            TeeTime requestedteetime = new TeeTime();

            if (theDataReader.HasRows)
            {
                while (theDataReader.Read())
                {
                    requestedteetime.Date             = DateTime.Parse(theDataReader["Date"].ToString());
                    requestedteetime.TimeSlot         = DateTime.Parse(theDataReader["TimeSlot"].ToString());
                    requestedteetime.Player1          = !DBNull.Value.Equals(theDataReader["Player1Number"]) ? (Player)UserManager.GetUser((String)theDataReader["Player1Number"]) : new Shareholder();
                    requestedteetime.Player2          = !DBNull.Value.Equals(theDataReader["Player2Number"]) ? (Player)UserManager.GetUser((String)theDataReader["Player2Number"]) : new Shareholder();
                    requestedteetime.Player3          = !DBNull.Value.Equals(theDataReader["Player3Number"]) ? (Player)UserManager.GetUser((String)theDataReader["Player3Number"]) : new Shareholder();
                    requestedteetime.Player4          = !DBNull.Value.Equals(theDataReader["Player4Number"]) ? (Player)UserManager.GetUser((String)theDataReader["Player4Number"]) : new Shareholder();
                    requestedteetime.BookerNumber     = theDataReader["BookerNumber"].ToString();
                    requestedteetime.Player1CheckedIn = bool.Parse(theDataReader["Player1CheckedIn"].ToString());
                    requestedteetime.Player2CheckedIn = bool.Parse(theDataReader["Player2CheckedIn"].ToString());
                    requestedteetime.Player3CheckedIn = bool.Parse(theDataReader["Player3CheckedIn"].ToString());
                    requestedteetime.Player4CheckedIn = bool.Parse(theDataReader["Player4CheckedIn"].ToString());
                }
            }
            theDataReader.Close();

            ClubBaistConnection.Close();

            return(requestedteetime);
        }
Beispiel #2
0
        public StandingTeeTimeRequest GetReservedStandingTeeTime(string DayOfWeek, DateTime requestedTime,
                                                                 DateTime requestedStartDate, DateTime requestedEndDate)
        {
            StandingTeeTimeRequest standingteetimerequest = new StandingTeeTimeRequest();

            SqlConnection ClubBaistConnection = new SqlConnection();

            ClubBaistConnection.ConnectionString = @"Data Source= (LocalDB)\MSSQLLocalDB; 
                                  Initial Catalog = aspnet-ClubBaistGolfManagement-53bc9b9d-9d6a-45d4-8429-2a2761773502;
                                                     Integrated Security = True; MultipleActiveResultSets=True";

            SqlCommand thecommand = new SqlCommand();

            thecommand.CommandType = CommandType.StoredProcedure;
            thecommand.Connection  = ClubBaistConnection;
            thecommand.CommandText = "GetReservedStandingTeeTime";

            SqlParameter day = new SqlParameter();

            day.ParameterName = "@dayofweek";
            day.SqlDbType     = SqlDbType.VarChar;
            day.Value         = DayOfWeek;
            day.Direction     = ParameterDirection.Input;
            thecommand.Parameters.Add(day);

            SqlParameter time = new SqlParameter();

            time.ParameterName = "@time";
            time.SqlDbType     = SqlDbType.Time;
            time.Value         = requestedTime;
            time.Direction     = ParameterDirection.Input;
            thecommand.Parameters.Add(time);

            SqlParameter startDate = new SqlParameter();

            startDate.ParameterName = "@startDate";
            startDate.SqlDbType     = SqlDbType.Date;
            startDate.Value         = requestedStartDate;
            startDate.Direction     = ParameterDirection.Input;
            thecommand.Parameters.Add(startDate);

            SqlParameter endDate = new SqlParameter();

            endDate.ParameterName = "@endDate";
            endDate.SqlDbType     = SqlDbType.Date;
            endDate.Value         = requestedEndDate;
            endDate.Direction     = ParameterDirection.Input;
            thecommand.Parameters.Add(endDate);

            ClubBaistConnection.Open();

            SqlDataReader theDataReader;

            theDataReader = thecommand.ExecuteReader();

            CBSUsers UserManager = new CBSUsers();

            if (theDataReader.HasRows)
            {
                while (theDataReader.Read())
                {
                    standingteetimerequest.RequestedTime    = DateTime.Parse(theDataReader["RequestedTeeTime"].ToString());
                    standingteetimerequest.DayofWeek        = theDataReader["DayofWeek"].ToString();
                    standingteetimerequest.RequestedEndDate = DateTime.Parse(theDataReader["RequestedEndDate"].ToString());
                    standingteetimerequest.Shareholder1     = !string.IsNullOrEmpty(theDataReader["Shareholder1Number"].ToString())
                                                            ? UserManager.GetUser((string)(theDataReader["Shareholder1Number"]))
                                                            : new Shareholder();
                    standingteetimerequest.Shareholder2 = !string.IsNullOrEmpty(theDataReader["Shareholder2Number"].ToString())
                                                            ? UserManager.GetUser((string)(theDataReader["Shareholder2Number"]))
                                                            : new Shareholder();
                    standingteetimerequest.Shareholder3 = !string.IsNullOrEmpty(theDataReader["Shareholder3Number"].ToString())
                                                            ? UserManager.GetUser((string)(theDataReader["Shareholder3Number"]))
                                                            : new Shareholder();
                    standingteetimerequest.Shareholder4 = !string.IsNullOrEmpty(theDataReader["Shareholder4Number"].ToString())
                                                            ? UserManager.GetUser((string)(theDataReader["Shareholder4Number"]))
                                                            : new Shareholder();
                }
                theDataReader.Close();

                ClubBaistConnection.Close();
            }

            return(standingteetimerequest);
        }