Exemple #1
0
        /// <summary>
        /// Adds a team_employee to the database using the given information
        /// </summary>
        /// <param name="team_employee">Object team_employee that has all the information to add to the database</param>
        /// <returns></returns>
        public bool AddTeam_Employee(Team_Employee team_employee)
        {
            InsertID = GetInsertID("EmpID", "Team_Employee");
            IDGet    = GetIDFromName(team_employee.AssistentName, "Team_Employee", "EmpID", "EmpName");
            string sql = "INSERT INTO Team_Employee (EmpID, EmpName, College, Function, Assistent, TeamEmp) VALUES (" +
                         ":parEmpID, :parEmpName, :parCollege, :parFunction, :parAssistent, :parTeamEmp)";

            OracleCommand PlayerCommand = new OracleCommand(sql, conn);

            PlayerCommand.Parameters.Add(new OracleParameter(":parEmpID", InsertID));
            PlayerCommand.Parameters.Add(new OracleParameter(":parEmpName", team_employee.EmployeeName));
            PlayerCommand.Parameters.Add(new OracleParameter(":parCollege", team_employee.College));
            PlayerCommand.Parameters.Add(new OracleParameter(":parFunction", team_employee.Function));
            PlayerCommand.Parameters.Add(new OracleParameter(":parAssistent", IDGet));
            PlayerCommand.Parameters.Add(new OracleParameter(":parTeamEmp", team_employee.TeamName));

            try
            {
                if (conn.State == System.Data.ConnectionState.Closed)
                {
                    conn.Open();
                }
                PlayerCommand.ExecuteNonQuery();
                return(true);
            }
            catch (OracleException)
            {
            }
            finally
            {
                conn.Close();
            }
            return(false);
        }
        /// <summary>
        /// Adds a team-employee to the database when all fields have been filled in correctly
        /// or else a error message is shown.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddEConfirm_Click(object sender, EventArgs e)
        {
            string EmployeeName = tbEmployeeName.Text;
            string College      = tbCollege.Text;
            string Function     = tbFunction.Text;

            if (EmployeeName != string.Empty && Function != string.Empty)
            {
                string Assistent = string.Empty;
                string TeamName  = ddlEmpTeam.SelectedValue;
                if (ddlAssistent.SelectedValue != "No Assistent")
                {
                    Assistent = ddlAssistent.SelectedValue;
                }
                Team_Employee newEmployee = new Team_Employee(EmployeeName, College, Function, Assistent, TeamName);
                if (db.AddTeam_Employee(newEmployee))
                {
                    lblError.Visible = false;
                    FillDropDown();
                }
            }
            else
            {
                lblError.Visible = true;
            }
        }
Exemple #3
0
        /// <summary>
        /// Searches for multiple objects using a searchterm and a filter
        /// </summary>
        /// <param name="searchterm">Text the database will search on</param>
        /// <param name="filter">Tabel in which the database will search in</param>
        /// <param name="searchon">Namecolumn to search on</param>
        /// <returns></returns>
        public List <ISearchable> SearchMultipleObjects(string searchterm, string filter, string searchon)
        {
            string        sql        = "SELECT * FROM " + filter + " Where " + searchon + " LIKE '%' || :parTerm || '%'";
            OracleCommand NBACommand = new OracleCommand(sql, conn);

            NBACommand.Parameters.Add(":parTerm", searchterm);
            List <ISearchable> SearchFound = new List <ISearchable>();

            try
            {
                conn.Open();
                OracleDataReader NBAReader = NBACommand.ExecuteReader();
                while (NBAReader.Read())
                {
                    if (filter == "Team")
                    {
                        string FoundName     = NBAReader["TeamName"].ToString();
                        string City          = NBAReader["City"].ToString();
                        int    Founded       = Convert.ToInt32(NBAReader["Founded"].ToString());
                        int    Championships = Convert.ToInt32(NBAReader["Championships"].ToString());
                        string Conference    = NBAReader["Conference"].ToString();
                        string Division      = NBAReader["Division"].ToString();
                        string NewStadium    = NBAReader["StadiumName"].ToString();
                        Team   NewTeam       = new Team(FoundName, City, Founded, Conference, Division, NewStadium);
                        SearchFound.Add(NewTeam);
                    }
                    else if (filter == "Player")
                    {
                        string          FoundName     = NBAReader["Name"].ToString();
                        int             Length        = Convert.ToInt32(NBAReader["Length"].ToString());
                        int             Weight        = Convert.ToInt32(NBAReader["Weight"].ToString());
                        string          SchoolCountry = NBAReader["Weight"].ToString();
                        string          BirthDate     = Convert.ToDateTime(NBAReader["BirthDate"]).ToString("dd-MM-yyyy");
                        int             Pro_Year      = Convert.ToInt32(NBAReader["Pro_Year"].ToString());
                        Player.Position Position;
                        Enum.TryParse(NBAReader["Position"].ToString(), out Position);
                        string Team      = NBAReader["Team_Name"].ToString();
                        Player NewPlayer = new Player(FoundName, Length, Weight, SchoolCountry, BirthDate, Pro_Year, Position, Team);
                        SearchFound.Add(NewPlayer);
                    }
                    else if (filter == "Team_Employee")
                    {
                        string FoundName   = NBAReader["EmpName"].ToString();
                        string College     = NBAReader["College"].ToString();
                        string Function    = NBAReader["Function"].ToString();
                        string TeamName    = NBAReader["TeamEmp"].ToString();
                        string AssistentID = NBAReader["Assistent"].ToString();
                        if (AssistentID != "")
                        {
                            GetIDFromName(AssistentID, "Team_Employee", "EmpName", "EmpID");
                        }
                        string        Assistent = NameGet;
                        Team_Employee NewEmp    = new Team_Employee(FoundName, College, Function, Assistent, TeamName);
                        SearchFound.Add(NewEmp);
                    }
                    else if (filter == "Event")
                    {
                        string EventName = NBAReader["EventName"].ToString();
                        string BeginDate = NBAReader["BeginDate"].ToString();
                        Event  NewEvent  = new Event(EventName, BeginDate);
                        SearchFound.Add(NewEvent);
                    }
                    else if (filter == "Stadium")
                    {
                        string  Name       = NBAReader["Stadium_Name"].ToString();
                        string  Location   = NBAReader["Location"].ToString();
                        int     MaxPeople  = Convert.ToInt32(NBAReader["Max_People"].ToString());
                        Stadium NewStadium = new Stadium(Name, Location, MaxPeople);
                        SearchFound.Add(NewStadium);
                    }
                }


                return(SearchFound);
            }
            catch
            {
            }
            finally
            {
                conn.Close();
            }
            return(null);
        }