Example #1
0
        public static Leader getLeaderById(int leaderId)
        {
            Leader l     = null;
            string query = @"select * from Leader l left join PartTime p ON l.id = p.leaderId left join FullTime f on l.id = f.leaderId where l.id = @leaderId";

            using (SqlConnection connection = new SqlConnection(Database.conString))
            {
                connection.Open();
                SqlCommand   cmd   = new SqlCommand(query, connection);
                SqlParameter param = new SqlParameter();
                param.ParameterName = "@leaderId";
                param.Value         = leaderId;
                cmd.Parameters.Add(param);
                SqlDataReader sdr = cmd.ExecuteReader();

                while (sdr.Read())
                {
                    if (sdr["fullId"].ToString() == "")
                    {
                        l = new PartTimeStaff()
                        {
                            id               = (int)sdr["id"],
                            name             = (string)sdr["name"],
                            contactNumber    = (string)sdr["contactNumber"],
                            email            = (string)sdr["email"],
                            dailyRate        = (int)sdr["dailyRate"],
                            destinationOpted = (string)sdr["destinationOpted"]
                        };
                    }
                    else
                    {
                        l = new FullTimeStaff()
                        {
                            id            = (int)sdr["id"],
                            name          = (string)sdr["name"],
                            contactNumber = (string)sdr["contactNumber"],
                            email         = (string)sdr["email"],
                            staffRank     = (string)sdr["staffRank"]
                        };
                    }
                }
            }

            return(l);
        }
Example #2
0
        public static List <Leader> getAllLeaders()
        {
            List <Leader> leaders = new List <Leader>();

            string query = @"select * from Leader l left join PartTime p ON l.id = p.leaderId left join FullTime f on l.id = f.leaderId";

            using (SqlConnection connection = new SqlConnection(Database.conString))
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand(query, connection);

                SqlDataReader sdr = cmd.ExecuteReader();

                while (sdr.Read())
                {
                    if (sdr["fullId"].ToString() == "")
                    {
                        PartTimeStaff pS = new PartTimeStaff()
                        {
                            id   = (int)sdr["id"],
                            name = (string)sdr["name"],
                        };

                        leaders.Add(pS);
                    }
                    else
                    {
                        FullTimeStaff fS = new FullTimeStaff()
                        {
                            id   = (int)sdr["id"],
                            name = (string)sdr["name"],
                        };
                        leaders.Add(fS);
                    }
                }
            }

            return(leaders);
        }
Example #3
0
        static void Main(string[] args)
        {
            decimal hourWorked;
            decimal wage;
            string  question = "What is hours worked for ";

            Staff jane = new FullTimeStaff(123);

            Console.WriteLine(question + "Jane:");
            hourWorked = Convert.ToDecimal(Console.ReadLine());
            wage       = jane.CalWage(hourWorked);
            Console.WriteLine($"Employee Code: {jane.EmployeeCode} \nEmployee ID: {jane.EmployeeID} \nTotal amount of hours worked: {hourWorked} \nTotal pay check wage: {(wage.ToString("C"))} \n");



            Staff jake = new PartTimeStaff(456);

            Console.WriteLine(question + "Jake:");
            hourWorked = Convert.ToDecimal(Console.ReadLine());
            wage       = jake.CalWage(hourWorked);
            Console.WriteLine($"Employee Code: {jake.EmployeeCode} \nEmployee ID: {jake.EmployeeID} \nTotal amount of hours worked: {hourWorked} \nTotal pay check wage: {(wage.ToString("C"))} \n");

            Console.ReadLine();
        }