示例#1
0
        public int RemoveProj(string projectName)
        {
            RetrieveTables();       // get a fresh copy of the database tables before every query to prevent errors
            try
            {
                // check if the user is already gone
                List <string> fetchedProjNames = (from Column in ProjectTable.AsEnumerable()     // pulls existing usernames
                                                  select Column.Field <string>("projectName")).ToList();

                if (fetchedProjNames.Contains(projectName))
                {
                    string query = "DELETE FROM Project WHERE projectName = '" + projectName + "';";
                    ExecuteSQLCommand(query);
                    return(0);
                }
                else
                {
                    return(0);
                }
            }
            catch (SqlException e)
            {
                return(-1);
            }
        }
示例#2
0
        public int SetProjectDefconLevel(string projectName, int newLevel) // sets the new level passed. The newLevel is NOT additive
        {
            RetrieveTables();                                              // get a fresh copy of the database tables before every query to prevent errors
            try
            {
                // check if the user is already gone
                List <string> fetchedProjNames = (from Column in ProjectTable.AsEnumerable()     // pulls existing usernames
                                                  select Column.Field <string>("projectName")).ToList();

                if (fetchedProjNames.Contains(projectName))
                {
                    string query = "UPDATE Project SET defconScale = " + newLevel
                                   + " WHERE projectName = '"
                                   + projectName + "';";
                    ExecuteSQLCommand(query);
                    return(0);
                }
                else
                {
                    return(0);
                }
            }
            catch (SqlException e)
            {
                return(-1);
            }
        }
示例#3
0
        public Project GetProj(string projectName)
        {
            RetrieveTables();       // get a fresh copy of the database tables before every query to prevent errors
            Project fetchedProject = new Project();

            try
            {
                var fetchedProjectRow = from Row in ProjectTable.AsEnumerable()
                                        where Row.Field <string>("projectName") == projectName
                                        select Row;

                if (fetchedProjectRow.AsEnumerable().Count() == 0)      // project not found
                {
                    return(null);
                }

                fetchedProject.defconScale = (from Row in ProjectTable.AsEnumerable()
                                              where Row.Field <string>("projectName") == projectName
                                              select Row.Field <int>("defconScale")).ToList().ElementAt(0);

                fetchedProject.dueDate = (from Row in ProjectTable.AsEnumerable()
                                          where Row.Field <string>("projectName") == projectName
                                          select Row.Field <DateTime>("dueDate")).ToList().ElementAt(0);

                fetchedProject.projectName = projectName;
            }
            catch (SqlException e)
            {
                return(null);
            }
            return(fetchedProject);
        }