Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Get the id of the employee from the url and pass it to the employee object
            // Also we are saving the object in the class because we need to use it in all the moethds.
            try
            {
                int position_id = int.Parse(Request.QueryString["id"]);
                position = new Position(position_id);

                if (!Page.IsPostBack) {
                    TextBox1.Text = position.Name;
                    ArrayList departments = new ArrayList();
                    departments = Department.getALL();

                    foreach (Department d in departments) {
                        ListItem item = new ListItem(d.Name, d.ID.ToString());
                        DropDownList1.Items.Add(item);
                    }

                    // Make sure to show the department of the position as the selected value
                    DropDownList1.Items.FindByValue(position.Department.ID.ToString()).Selected = true;
                }

            }
            catch (Exception exce)
            {
                Response.Redirect("departments.aspx");
            }
        }
Exemplo n.º 2
0
        public Job(bool workingStatus, string contract, int hoursPerDay, DateTime firstDayAtWork, int positionID)
        {
            this.contract = contract;
            this.workingStatus = workingStatus;
            this.hoursPerDay = hoursPerDay;
            this.firstDayAtWork = firstDayAtWork;

            this.position = new Position(positionID);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This will return an arraylist that contains the name and id and the department for each 
        /// </summary>
        /// <returns></returns>
        public static ArrayList getALL()
        {
            ArrayList list = new ArrayList();

            DatabaseHandler handler = new DatabaseHandler();
            handler.setSQL("SELECT * FROM Position ORDER BY position_department");
            handler.queryExecute();
            while (handler.reader.Read()) {

                int id = int.Parse(handler.reader["position_id"].ToString());
                string name = handler.reader["position_name"].ToString();
                int department_id = int.Parse(handler.reader["position_department"].ToString());
                Position p = new Position(id,name,new Department(department_id));
                list.Add(p);
            }

            return list;
        }
Exemplo n.º 4
0
        /// <summary>
        /// This will return an arraylist that contains the name and id and the department for each 
        /// </summary>
        /// <returns></returns>
        public static ArrayList getByDepartmentID(int department_id)
        {
            ArrayList list = new ArrayList();

            DatabaseHandler handler = new DatabaseHandler();
            handler.setSQL("SELECT * FROM Position WHERE position_department = @id");
            handler.addParameter("@id", department_id.ToString());
            handler.queryExecute();
            while (handler.reader.Read())
            {

                int id = int.Parse(handler.reader["position_id"].ToString());
                string name = handler.reader["position_name"].ToString();
                Position p = new Position(id, name, new Department(department_id));
                list.Add(p);
            }

            return list;
        }