예제 #1
0
        /// <summary>
        /// Constructor no.3 that builds a project object from an existing project in the db
        /// if LoadPositions = true => the project creates the Project positions aswell as the other fields.
        /// </summary>
        public Project(int ID, bool LoadPositions)
        {
            DataRow row = ProjectDB.ReturnProject(ID);

            this.ProjectID        = (int)row["ProjectID"];
            this.AdminUSID        = (int)row["AdminUSID"];
            this.MinAge           = (int)row["MinAge"];
            this.ProjectStatus    = (int)row["ProjectStatus"];
            this.NumRateVoters    = (int)row["NumRateVoters"];
            this.ProjectRate      = (int)row["ProjectRate"];
            this.ProjectContent   = (string)row["ProjectContent"];
            this.DateCreated      = (DateTime)row["DateCreated"];
            this.ProjectPositions = new List <ProjectPos>();
            DataTable dtPos = ProjectDB.ReturnProjectPositions(ProjectID);

            if (dtPos != null && LoadPositions)
            {
                foreach (DataRow posRow in dtPos.Rows)
                {
                    ProjectPos position = new ProjectPos((int)posRow["ID"], (int)posRow["UserID"], (int)posRow["Profession"]);
                    ProjectPositions.Add(position);
                }
            }
        }