Example #1
0
        public static List <ProjectInfo> getUserProjects(string Username, bool OnlyActive)
        {
            if (!User.UsernameExists(Username))
            {
                throw new ArgumentException("Username doesn't exist");
            }

            ProjectTableAdapter projectAdapter = new ProjectTableAdapter();

            NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetData();

            List <ProjectInfo> result = new List <ProjectInfo>();

            foreach (NuRacingDataSet.ProjectRow projectRow in projectTable.Rows)
            {
                if (!(
                        (OnlyActive && (!projectRow.Project_Active)) ||
                        !(Project.userInvolvedIn(Username, projectRow.Project_UID))))
                {
                    result.Add(new ProjectInfo(projectRow));
                }
            }

            return(result);
        }
Example #2
0
        public static void AddCar(string CarName, int YearMade, string CarDescription, List <string> CarParts, bool IsCarActive = true)
        {
            AddProject(CarName, YearMade, CarDescription, IsCarActive);

            int ProjectID = -1;

            ProjectTableAdapter projectAdapter = new ProjectTableAdapter();

            NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetData();

            foreach (NuRacingDataSet.ProjectRow projectRow in projectTable.Rows)
            {
                if (projectRow.Project_Name == CarName &&
                    projectRow.Project_YearMade == YearMade &&
                    projectRow.Project_Description == CarDescription &&
                    projectRow.Project_Active == IsCarActive)
                {
                    ProjectID = projectRow.Project_UID;
                    break;
                }
            }

            if (ProjectID != -1)
            {
                foreach (string CarPart in CarParts)
                {
                    WorkType.AddWorkType(ProjectID, CarPart);
                }
            }
        }
Example #3
0
        public static ProjectInfo getProject(int ProjectID)
        {
            ProjectTableAdapter projectAdapter = new ProjectTableAdapter();

            NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetProject(ProjectID);

            if (projectTable.Rows.Count == 0)
            {
                throw new ArgumentException("Project doesn't exist");
            }

            return(new ProjectInfo((NuRacingDataSet.ProjectRow)projectTable.Rows[0]));
        }
Example #4
0
 public static bool projectActive(int ProjectID)
 {
     if (!projectExists(ProjectID))
     {
         throw new ArgumentException("Project doesn't exist");
     }
     else
     {
         ProjectTableAdapter projectAdapter            = new ProjectTableAdapter();
         NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetProject(ProjectID);
         return(((NuRacingDataSet.ProjectRow)projectTable.Rows[0]).Project_Active);
     }
 }
Example #5
0
        public static List <ProjectInfo> getProjects(bool OnlyActive = true)
        {
            ProjectTableAdapter projectAdapter = new ProjectTableAdapter();

            NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetData();

            List <ProjectInfo> result = new List <ProjectInfo>();

            foreach (NuRacingDataSet.ProjectRow projectRow in projectTable.Rows)
            {
                if (!(OnlyActive && !projectRow.Project_Active))
                {
                    result.Add(new ProjectInfo(projectRow));
                }
            }
            return(result);
        }
Example #6
0
        public void updateDatabase()
        {
            if (beenChanged)
            {
                ProjectTableAdapter projectAdapter            = new ProjectTableAdapter();
                NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetProject(projectID);
                NuRacingDataSet.ProjectRow       projectRow   = (NuRacingDataSet.ProjectRow)(projectTable.Rows[0]);

                projectRow.Project_Active            = active;
                projectRow.Project_Name              = name;
                projectRow.Project_Description       = description;
                projectRow.Project_UID               = projectID;
                projectRow.Project_Status            = status;
                projectRow.Project_StatusChangedDate = statusLastChanged;

                projectAdapter.Update(projectTable);
            }
        }
Example #7
0
        public static void AddProject(string ProjectName, int YearOfProject, string ProjectDescription, bool IsActive = true)
        {
            ProjectTableAdapter projectAdapter = new ProjectTableAdapter();
            NuRacingDataSet.ProjectDataTable projectTable = new NuRacingDataSet.ProjectDataTable();

            projectAdapter.Fill(projectTable);

            NuRacingDataSet.ProjectRow newProjectRow = projectTable.NewProjectRow();

            newProjectRow.Project_Name = ProjectName;
            newProjectRow.Project_YearMade = YearOfProject;
            newProjectRow.Project_Description = ProjectDescription;
            newProjectRow.Project_Active = IsActive;
            newProjectRow.Project_Status = "Planning";
            newProjectRow.Project_StatusChangedDate = DateTime.Now;

            projectTable.AddProjectRow(newProjectRow);
            projectAdapter.Update(projectTable);
        }
Example #8
0
        public static void AddProject(string ProjectName, int YearOfProject, string ProjectDescription, bool IsActive = true)
        {
            ProjectTableAdapter projectAdapter = new ProjectTableAdapter();

            NuRacingDataSet.ProjectDataTable projectTable = new NuRacingDataSet.ProjectDataTable();

            projectAdapter.Fill(projectTable);

            NuRacingDataSet.ProjectRow newProjectRow = projectTable.NewProjectRow();

            newProjectRow.Project_Name              = ProjectName;
            newProjectRow.Project_YearMade          = YearOfProject;
            newProjectRow.Project_Description       = ProjectDescription;
            newProjectRow.Project_Active            = IsActive;
            newProjectRow.Project_Status            = "Planning";
            newProjectRow.Project_StatusChangedDate = DateTime.Now;

            projectTable.AddProjectRow(newProjectRow);
            projectAdapter.Update(projectTable);
        }
Example #9
0
        public void resetData()
        {
            ProjectTableAdapter projectAdapter = new ProjectTableAdapter();

            NuRacingDataSet.ProjectDataTable projectTable = projectAdapter.GetProject(projectID);
            NuRacingDataSet.ProjectRow       projectRow   = (NuRacingDataSet.ProjectRow)(projectTable.Rows[0]);

            active            = projectRow.Project_Active;
            name              = projectRow.Project_Name;
            description       = projectRow.Project_Description;
            projectID         = projectRow.Project_UID;
            status            = projectRow.Project_Status;
            statusLastChanged = projectRow.Project_StatusChangedDate;

            if (projectRow.IsProject_YearMadeNull())
            {
                yearMade = null;
            }
            else
            {
                yearMade = projectRow.Project_YearMade;
            }
            beenChanged = false;
        }