Example #1
0
 private static void SelectProjects(DataAccessLayer.Project objP)
 {
     Console.WriteLine("Current Data in Projects");
     foreach (DataAccessLayer.Project Row in objP.SelProject())
     {
         Console.WriteLine("  ProjectID:{0}\n  ProjectName:{1}\n  ProjectDescription:{2} \n", Row.ProjectID, Row.ProjectName, Row.ProjectDescription);
     }
     Console.WriteLine("---------------------------");
 }
Example #2
0
        public void SuspendProject(int ProjectID)
        {
            DataAccessLayer.Project proj = new DataAccessLayer.Project
            {
                ProjectID = ProjectID
            };

            var user = _projectManager.Users.Where(x => x.ProjectID == ProjectID).FirstOrDefault();

            if (user != null)
            {
                user.ProjectID = null;
            }
            _projectManager.Entry(proj).State = EntityState.Deleted;
            _projectManager.SaveChanges();
        }
Example #3
0
        public void AddProject(CommonLibrary.Projects project)
        {
            DataAccessLayer.Project proj = new DataAccessLayer.Project
            {
                Project1  = project.Project,
                StartDate = project.StartDate,
                EndDate   = project.EndDate,
                Prioriy   = project.Priority
            };

            _projectManager.Projects.Add(proj);
            _projectManager.SaveChanges();

            var ProjId = proj.ProjectID;
            var usr    = _projectManager.Users.Where(x => x.UserID == project.ManagerID).FirstOrDefault();

            if (usr != null)
            {
                usr.ProjectID = ProjId;
                _projectManager.SaveChanges();
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            int NewID = -1, RC;
            bool ShowEmployeesTest = true;
            bool ShowProjectsTest = true;
            bool ShowEmployeeProjectHoursTest = true;
            bool ShowThisYearsDatesTest = false;
            bool ShowValidHourEntriesTest = false;

            #region Employees Test
            if (ShowEmployeesTest)
            {
                DataAccessLayer.Employee objE = new DataAccessLayer.Employee();
                Console.WriteLine("++++ Testing: Employees ++++");

                RC = objE.InsEmployee("Emp1", out NewID);
                Console.WriteLine("Insert = RC: {0} and NewID: {1}", RC, NewID);
                SelectEmployees(objE);

                RC = objE.UpdEmployee(NewID, "Emp1A");
                Console.WriteLine("Update = RC: {0}", RC);
                SelectEmployees(objE);

                RC = objE.DelEmployee(NewID);
                Console.WriteLine("Del = RC: {0}", RC);
                SelectEmployees(objE); 
                Console.WriteLine("\n"); 
            }
            #endregion

            #region Projects Test
            if (ShowProjectsTest)
            {
                DataAccessLayer.Project objP = new DataAccessLayer.Project();
                Console.WriteLine("++++ Testing: Projects ++++");

                RC = objP.InsProject("Project1000", "DescA", out NewID);
                Console.WriteLine("Insert = RC: {0} and NewID: {1}", RC, NewID);
                SelectProjects(objP);

                RC = objP.UpdProject(NewID, "Project1100", "DescZ");
                Console.WriteLine("Update = RC: {0}", RC);
                SelectProjects(objP);

                RC = objP.DelProject(NewID);
                Console.WriteLine("Del = RC: {0}", RC);
                SelectProjects(objP);
                Console.WriteLine("\n"); 
            }
            #endregion
             
            #region EmployeeProjectHours Test
            if (ShowEmployeeProjectHoursTest)
            {
                DataAccessLayer.EmployeeProjectHour objEPH = new DataAccessLayer.EmployeeProjectHour();
                Console.WriteLine("++++ Testing: EmployeeProjectHours ++++");

                RC = objEPH.InsEmployeeProjectHour(2, 100, DateTime.Parse("2016/01/03"), 17);
                Console.WriteLine("Insert = RC: {0} and NewID: {1}", RC, NewID);
                SelectEmployeeProjectHours(objEPH);

                RC = objEPH.UpdEmployeeProjectHour(2, 100, DateTime.Parse("2016/01/03"), 7);
                Console.WriteLine("Update = RC: {0}", RC);
                SelectEmployeeProjectHours(objEPH);

                RC = objEPH.DelEmployeeProjectHour(2, 100, DateTime.Parse("2016/01/03"));
                Console.WriteLine("Del = RC: {0}", RC);
                SelectEmployeeProjectHours(objEPH);
                Console.WriteLine("\n"); 
            }
            #endregion

            #region ThisYearsDates Test
            if (ShowThisYearsDatesTest)
            {
                DataAccessLayer.ThisYearsDate objTYD = new DataAccessLayer.ThisYearsDate();
                Console.WriteLine("++++ Testing: ValidHourEntries ++++");
                SelectThisYearsDates(objTYD);
                Console.ReadLine(); 
            }
            #endregion

            #region ValidHourEntries Test
            if (ShowValidHourEntriesTest)
            {
                DataAccessLayer.ValidHourEntry objVHE = new DataAccessLayer.ValidHourEntry();
                Console.WriteLine("++++ Testing: ValidHourEntries ++++");
                SelectValidHourEntries(objVHE);
            }
            #endregion

            Console.WriteLine("Press any key to quit");
            Console.ReadLine(); 
        }
Example #5
0
        static void Main(string[] args)
        {
            int  NewID = -1, RC;
            bool ShowEmployeesTest            = true;
            bool ShowProjectsTest             = true;
            bool ShowEmployeeProjectHoursTest = true;
            bool ShowThisYearsDatesTest       = false;
            bool ShowValidHourEntriesTest     = false;

            #region Employees Test
            if (ShowEmployeesTest)
            {
                DataAccessLayer.Employee objE = new DataAccessLayer.Employee();
                Console.WriteLine("++++ Testing: Employees ++++");

                RC = objE.InsEmployee("Emp1", out NewID);
                Console.WriteLine("Insert = RC: {0} and NewID: {1}", RC, NewID);
                SelectEmployees(objE);

                RC = objE.UpdEmployee(NewID, "Emp1A");
                Console.WriteLine("Update = RC: {0}", RC);
                SelectEmployees(objE);

                RC = objE.DelEmployee(NewID);
                Console.WriteLine("Del = RC: {0}", RC);
                SelectEmployees(objE);
                Console.WriteLine("\n");
            }
            #endregion

            #region Projects Test
            if (ShowProjectsTest)
            {
                DataAccessLayer.Project objP = new DataAccessLayer.Project();
                Console.WriteLine("++++ Testing: Projects ++++");

                RC = objP.InsProject("Project1000", "DescA", out NewID);
                Console.WriteLine("Insert = RC: {0} and NewID: {1}", RC, NewID);
                SelectProjects(objP);

                RC = objP.UpdProject(NewID, "Project1100", "DescZ");
                Console.WriteLine("Update = RC: {0}", RC);
                SelectProjects(objP);

                RC = objP.DelProject(NewID);
                Console.WriteLine("Del = RC: {0}", RC);
                SelectProjects(objP);
                Console.WriteLine("\n");
            }
            #endregion

            #region EmployeeProjectHours Test
            if (ShowEmployeeProjectHoursTest)
            {
                DataAccessLayer.EmployeeProjectHour objEPH = new DataAccessLayer.EmployeeProjectHour();
                Console.WriteLine("++++ Testing: EmployeeProjectHours ++++");

                RC = objEPH.InsEmployeeProjectHour(2, 100, DateTime.Parse("2016/01/03"), 17);
                Console.WriteLine("Insert = RC: {0} and NewID: {1}", RC, NewID);
                SelectEmployeeProjectHours(objEPH);

                RC = objEPH.UpdEmployeeProjectHour(2, 100, DateTime.Parse("2016/01/03"), 7);
                Console.WriteLine("Update = RC: {0}", RC);
                SelectEmployeeProjectHours(objEPH);

                RC = objEPH.DelEmployeeProjectHour(2, 100, DateTime.Parse("2016/01/03"));
                Console.WriteLine("Del = RC: {0}", RC);
                SelectEmployeeProjectHours(objEPH);
                Console.WriteLine("\n");
            }
            #endregion

            #region ThisYearsDates Test
            if (ShowThisYearsDatesTest)
            {
                DataAccessLayer.ThisYearsDate objTYD = new DataAccessLayer.ThisYearsDate();
                Console.WriteLine("++++ Testing: ValidHourEntries ++++");
                SelectThisYearsDates(objTYD);
                Console.ReadLine();
            }
            #endregion

            #region ValidHourEntries Test
            if (ShowValidHourEntriesTest)
            {
                DataAccessLayer.ValidHourEntry objVHE = new DataAccessLayer.ValidHourEntry();
                Console.WriteLine("++++ Testing: ValidHourEntries ++++");
                SelectValidHourEntries(objVHE);
            }
            #endregion

            Console.WriteLine("Press any key to quit");
            Console.ReadLine();
        }