Esempio n. 1
0
        public List <int> GetLast20Scores(int memberNumber, string user, string password)
        {
            List <int> totalScoreList;

            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.SetBasePath(Directory.GetCurrentDirectory());
            configurationBuilder.AddJsonFile("appsettings.json");
            IConfiguration configuration       = configurationBuilder.Build();
            SqlConnection  ClubBaistConnection = new SqlConnection(configuration.GetConnectionString("BAIS3230"));

            ClubBaistConnection.Open();
            SqlCommand UpdateLast20Command = new SqlCommand();


            SqlCommand Last20Command = new SqlCommand
            {
                Connection  = ClubBaistConnection,
                CommandType = CommandType.StoredProcedure,
                CommandText = "GetLast20Scores"
            };
            SqlParameter ASampleCommandParameter = new SqlParameter
            {
                ParameterName = "@MemberNumber",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.Input,
                SqlValue      = memberNumber
            };

            Last20Command.Parameters.Add(ASampleCommandParameter);
            SqlDataReader ApplicationReader;

            ApplicationReader = Last20Command.ExecuteReader();
            totalScoreList    = new List <int>();
            if (ApplicationReader.HasRows)
            {
                Console.WriteLine("Columns:");
                Console.WriteLine("--------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    Console.WriteLine(ApplicationReader.GetName(index));
                }
                Console.WriteLine("Values:");
                Console.WriteLine("-------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    while (ApplicationReader.Read())
                    {
                        int newScore;
                        newScore = int.Parse(ApplicationReader.GetValue("TotalScore").ToString());
                        totalScoreList.Add(newScore);
                    }
                }
            }
            ApplicationReader.Close();
            ClubBaistConnection.Close();
            return(totalScoreList);
        }
Esempio n. 2
0
        public decimal GetHandicap(int memberNumber, string user, string password)
        {
            decimal handicap = 0;


            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.SetBasePath(Directory.GetCurrentDirectory());
            configurationBuilder.AddJsonFile("appsettings.json");
            IConfiguration configuration       = configurationBuilder.Build();
            SqlConnection  ClubBaistConnection = new SqlConnection(configuration.GetConnectionString("BAIS3230"));

            ClubBaistConnection.Open();
            SqlCommand UpdateMACommand = new SqlCommand();


            SqlCommand MACommand = new SqlCommand
            {
                Connection  = ClubBaistConnection,
                CommandType = CommandType.StoredProcedure,
                CommandText = "GetHandicapIndex"
            };
            SqlParameter ASampleCommandParameter = new SqlParameter
            {
                ParameterName = "@MemberNumber",
                SqlDbType     = SqlDbType.Int,
                Direction     = ParameterDirection.Input,
                SqlValue      = memberNumber
            };

            MACommand.Parameters.Add(ASampleCommandParameter);
            SqlDataReader ApplicationReader;

            ApplicationReader = MACommand.ExecuteReader();

            if (ApplicationReader.HasRows)
            {
                Console.WriteLine("Columns:");
                Console.WriteLine("--------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    Console.WriteLine(ApplicationReader.GetName(index));
                }
                Console.WriteLine("Values:");
                Console.WriteLine("-------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    while (ApplicationReader.Read())
                    {
                        handicap = decimal.Parse(ApplicationReader.GetValue("HandicapIndex").ToString());
                    }
                }
            }
            ApplicationReader.Close();
            ClubBaistConnection.Close();
            return(handicap);
        }
Esempio n. 3
0
        public List <StandingTeeTime> GetStandingTeeTimeRequests(string user, string password)
        {
            List <StandingTeeTime> standingTeeTimeRequests;

            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.SetBasePath(Directory.GetCurrentDirectory());
            configurationBuilder.AddJsonFile("appsettings.json");
            IConfiguration configuration       = configurationBuilder.Build();
            SqlConnection  ClubBaistConnection = new SqlConnection(configuration.GetConnectionString("BAIS3230"));

            ClubBaistConnection.Open();
            SqlCommand UpdateMACommand = new SqlCommand();


            SqlCommand MACommand = new SqlCommand
            {
                Connection  = ClubBaistConnection,
                CommandType = CommandType.StoredProcedure,
                CommandText = "GetStandingTeeTimes"
            };

            SqlDataReader ApplicationReader;

            ApplicationReader       = MACommand.ExecuteReader();
            standingTeeTimeRequests = new List <StandingTeeTime>();
            if (ApplicationReader.HasRows)
            {
                Console.WriteLine("Columns:");
                Console.WriteLine("--------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    Console.WriteLine(ApplicationReader.GetName(index));
                }
                Console.WriteLine("Values:");
                Console.WriteLine("-------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    while (ApplicationReader.Read())
                    {
                        StandingTeeTime tee = new StandingTeeTime();
                        tee.StandingTeeTimeID = int.Parse(ApplicationReader.GetValue("StandingTeeTimeID").ToString());
                        tee.ShareHolderNumber = int.Parse(ApplicationReader.GetValue("ShareHolderNumber").ToString());

                        tee.MemberNumber2 = int.Parse(ApplicationReader.GetValue("MemberNumber2").ToString());
                        tee.MemberNumber3 = int.Parse(ApplicationReader.GetValue("MemberNumber3").ToString());


                        tee.MemberNumber4 = int.Parse(ApplicationReader.GetValue("MemberNumber4").ToString());

                        tee.ShareHolderName = ApplicationReader.GetValue("ShareholderName").ToString();

                        tee.Member2Name = ApplicationReader.GetValue("MemberName2").ToString();

                        tee.Member3Name = ApplicationReader.GetValue("MemberName3").ToString();
                        tee.Member4Name = ApplicationReader.GetValue("MemberName4").ToString();
                        tee.DateStart   = DateTime.Parse(ApplicationReader.GetValue("StartDate").ToString());

                        tee.DateEnd = DateTime.Parse(ApplicationReader.GetValue("EndDate").ToString());

                        tee.TeeTimeTime = DateTime.Parse(ApplicationReader.GetValue("TeeTimeTime").ToString());


                        tee.RequestedDayOfWeek = int.Parse(ApplicationReader.GetValue("RequestedDayOfWeek").ToString());
                        tee.RequestedDayOfWeek = tee.RequestedDayOfWeek - 1;


                        tee.IsApproved = bool.Parse(ApplicationReader.GetValue("IsApproved").ToString());
                        standingTeeTimeRequests.Add(tee);
                    }
                }
            }
            ApplicationReader.Close();
            ClubBaistConnection.Close();
            return(standingTeeTimeRequests);
        }
Esempio n. 4
0
        public List <MembershipApplication> GetMembershipApplications(string searchParam, string user, string password)
        {
            List <MembershipApplication> membershipApplicationList;

            ConfigurationBuilder configurationBuilder = new ConfigurationBuilder();

            configurationBuilder.SetBasePath(Directory.GetCurrentDirectory());
            configurationBuilder.AddJsonFile("appsettings.json");
            IConfiguration configuration       = configurationBuilder.Build();
            SqlConnection  ClubBaistConnection = new SqlConnection(configuration.GetConnectionString("BAIS3230"));

            ClubBaistConnection.Open();
            SqlCommand UpdateMACommand = new SqlCommand();


            SqlCommand MACommand = new SqlCommand
            {
                Connection  = ClubBaistConnection,
                CommandType = CommandType.StoredProcedure,
                CommandText = "GetMembershipApplications"
            };
            SqlParameter ASampleCommandParameter = new SqlParameter
            {
                ParameterName = "@SearchParam",
                SqlDbType     = SqlDbType.VarChar,
                Direction     = ParameterDirection.Input,
                SqlValue      = searchParam.ToUpper()
            };

            MACommand.Parameters.Add(ASampleCommandParameter);
            SqlDataReader ApplicationReader;

            ApplicationReader         = MACommand.ExecuteReader();
            membershipApplicationList = new List <MembershipApplication>();
            if (ApplicationReader.HasRows)
            {
                Console.WriteLine("Columns:");
                Console.WriteLine("--------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    Console.WriteLine(ApplicationReader.GetName(index));
                }
                Console.WriteLine("Values:");
                Console.WriteLine("-------");
                for (int index = 0; index < ApplicationReader.FieldCount; index++)
                {
                    while (ApplicationReader.Read())
                    {
                        MembershipApplication membershipApplication = new MembershipApplication();
                        membershipApplication.MembershipApplicationID = int.Parse(ApplicationReader.GetValue("MembershipApplicationID").ToString());
                        membershipApplication.FirstName          = ApplicationReader.GetValue("FirstName").ToString();
                        membershipApplication.LastName           = ApplicationReader.GetValue("LastName").ToString();
                        membershipApplication.Occupation         = ApplicationReader.GetValue("Occupation").ToString();
                        membershipApplication.CompanyName        = ApplicationReader.GetValue("CompanyName").ToString();
                        membershipApplication.HomeAddress        = ApplicationReader.GetValue("HomeAddress").ToString();
                        membershipApplication.CompanyAddress     = ApplicationReader.GetValue("CompanyAddress").ToString();
                        membershipApplication.HomePostalCode     = ApplicationReader.GetValue("HomePostalCode").ToString();
                        membershipApplication.CompanyPostalCode  = ApplicationReader.GetValue("CompanyPostalCode").ToString();
                        membershipApplication.HomePhone          = ApplicationReader.GetValue("HomePhone").ToString();
                        membershipApplication.CompanyPhone       = ApplicationReader.GetValue("CompanyPhone").ToString();
                        membershipApplication.HomeAlternatePhone = ApplicationReader.GetValue("HomeAlternatePhone").ToString();
                        membershipApplication.Email            = ApplicationReader.GetValue("Email").ToString();
                        membershipApplication.DateOfBirth      = DateTime.Parse(ApplicationReader.GetValue("DateOfBirth").ToString());
                        membershipApplication.DateCompleted    = DateTime.Parse(ApplicationReader.GetValue("DateCompleted").ToString());
                        membershipApplication.ShareholderName1 = ApplicationReader.GetValue("ShareholderName1").ToString();
                        membershipApplication.ShareholderName2 = ApplicationReader.GetValue("ShareholderName2").ToString();
                        membershipApplicationList.Add(membershipApplication);
                    }
                }
            }
            ApplicationReader.Close();
            ClubBaistConnection.Close();
            return(membershipApplicationList);
        }