예제 #1
0
        // Retrieves all teams assigned to a service manager
        public List <ITeamDO> GetAllSMTeams()
        {
            var teams = new List <ITeamDO>();

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    using (SqlCommand com = new SqlCommand("sp_GetAllSMTeams", con))
                    {
                        com.CommandType    = CommandType.StoredProcedure;
                        com.CommandTimeout = 35;

                        con.Open();
                        using (SqlDataReader reader = com.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                ITeamDO newTeam = new TeamDO();
                                newTeam.TeamID  = (int)reader["TeamID"];
                                newTeam.Name    = reader["Team"].ToString();
                                newTeam.Comment = reader["Comment"].ToString();
                                teams.Add(newTeam);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLogger.LogError(e, "GetAllSMTeams", "nothing");
            }
            return(teams);
        }
        public static ITeamDO MapTeamPOtoDO(TeamPO teamPO)
        {
            ITeamDO oTeam = new TeamDO();

            oTeam.TeamID       = teamPO.TeamID;
            oTeam.Name         = teamPO.Name;
            oTeam.Comment      = teamPO.Comment;
            oTeam.Active       = teamPO.Active;
            oTeam.RunningTotal = teamPO.RunningTotal;

            return(oTeam);
        }
예제 #3
0
        // TODO: Find a better way if time allows
        //GetTeamByID
        public ITeamDO GetTeamNameByID(int teamID)
        {
            ITeamDO newTeam = new TeamDO();

            try
            {
                using (SqlConnection con = new SqlConnection(conString))
                {
                    using (SqlCommand com = new SqlCommand("sp_getTeamNameByID", con))
                    {
                        try
                        {
                            com.CommandType    = CommandType.StoredProcedure;
                            com.CommandTimeout = 35;

                            com.Parameters.Add(new SqlParameter("@TeamID", teamID));
                            con.Open();
                            using (SqlDataReader reader = com.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    newTeam.Name = reader.GetString(0);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrorLogger.LogError(ex, "GetTeamByID", "nothing");
                        }
                        finally
                        {
                            con.Close();
                            con.Dispose();
                            con.Dispose();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ErrorLogger.LogError(e, "GetTeamByID", "nothing");
            }

            return(newTeam);
        }
예제 #4
0
        // Retrieves all SM teams
        public List <ITeamDO> GetAllSMTeamsByUserID(int userID)
        {
            var listOfTeams = new List <ITeamDO>();
            var newTeam     = new TeamDO();

            try
            {
                using (SqlConnection connection = new SqlConnection(conString))
                {
                    using (SqlCommand command = new SqlCommand("sp_GetAllSMTeamsByUserID", connection))
                    {
                        try
                        {
                            command.CommandType    = CommandType.StoredProcedure;
                            command.CommandTimeout = 35;

                            command.Parameters.Add(new SqlParameter("@UserId", userID));
                            connection.Open();
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    newTeam.TeamID       = reader.GetInt32(0);
                                    newTeam.Name         = reader.GetString(1);
                                    newTeam.RunningTotal = reader.GetDecimal(2);
                                    listOfTeams.Add(newTeam);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrorLogger.LogError(ex, "GetAllSMTeamAbsencesByUserID", "nothing");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex, "GetAllSMTeamAbsencesByUserID", "nothing");
            }
            return(listOfTeams);
        }