Esempio n. 1
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            var username = HttpContext.Session.GetString("_username");
            var usertype = HttpContext.Session.GetString("_usertype");
            var access   = new Access(username, "Supervisor");

            if (access.IsLogin())
            {
                if (access.IsAuthorize(usertype))
                {
                    Project = await _context.Project.Where(p => p.DateDeleted == null).FirstOrDefaultAsync(p => p.ProjectId == id && p.SupervisorId == username);

                    if (Project == null)
                    {
                        ErrorMessage = "Project not found.";
                        return(RedirectToPage("/Supervisor/Project/ViewProject", id));
                    }

                    if (Project.ProjectStatus != "Available" && Project.ProjectStatus != "Taken")
                    {
                        ErrorMessage = "Action denied.";
                        return(RedirectToPage("/Supervisor/Project/ViewProject", id));
                    }

                    CanCancel = Project.ProjectStatus == "Available" ? true : false;

                    Epf = new EditProjectForm();

                    //Supervisor = await _context.Supervisor.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(s => s.AssignedId == Project.SupervisorId);

                    //CoSupervisor = await _context.Supervisor.Where(s => s.DateDeleted == null).FirstOrDefaultAsync(s => s.AssignedId == Project.CoSupervisorId);

                    ProjectSpecializations = await _context.ProjectSpecialization.Include(p => p.Specialization).Where(p => p.ProjectId == Project.ProjectId).ToListAsync();

                    Epf.Title       = Project.ProjectTitle;
                    Epf.Description = ProjectSpecializations[0].ProjectDescription;
                    Epf.Objective   = ProjectSpecializations[0].ProjectObjective;
                    Epf.Scope       = ProjectSpecializations[0].ProjectScope;

                    ViewData["Type"] = Enumerable.ToList(new[] { "Edit Project" })
                                       .Select(n => new SelectListItem
                    {
                        Value = n.ToString(),
                        Text  = n.ToString()
                    }).ToList();

                    return(Page());
                }
                else
                {
                    ErrorMessage = "Access Denied";
                    return(RedirectToPage($"/{usertype}/Index"));
                }
            }
            else
            {
                ErrorMessage = "Login Required";
                return(RedirectToPage("/Account/Login"));
            }
        }
Esempio n. 2
0
 private void Dg_CellValueChanged(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 1)
     {
         DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)dg.Rows[e.RowIndex].Cells[1];
         if (cb.Value != null)
         {
             if (cb.Value.ToString() == "<Edit...>")
             {
                 ArrayList       L   = ConfigurationManagerForm.GetSolutionPlatform(vs);
                 EditProjectForm epf = new EditProjectForm();
                 epf.Text = "Edit Project Configurations";
                 epf.LoadPlatforms(L);
                 DialogResult r = epf.ShowDialog();
                 cb.Value = cmb.Items[2];
             }
             else if (cb.Value.ToString() == "<New...>")
             {
                 ArrayList         L   = ConfigurationManagerForm.GetSolutionPlatform(vs);
                 NewProjectConForm epf = new NewProjectConForm();
                 epf.Text = "New Project Configurations";
                 epf.LoadProject(L);
                 DialogResult r = epf.ShowDialog();
                 cb.Value = cmb.Items[2];
             }
         }
     }
     else if (e.ColumnIndex == 2)
     {
         DataGridViewComboBoxCell cd = (DataGridViewComboBoxCell)dg.Rows[e.RowIndex].Cells[2];
         if (cd.Value != null)
         {
             if (cd.Value.ToString() == "<Edit...>")
             {
                 ArrayList       L   = ConfigurationManagerForm.GetProjectPlatform(vs);
                 EditProjectForm epf = new EditProjectForm();
                 epf.Text = "Edit Platform Configurations";
                 epf.LoadPlatforms(L);
                 DialogResult r = epf.ShowDialog();
                 cd.Value = cmp.Items[2];
             }
             else if (cd.Value.ToString() == "<New...>")
             {
                 int                c   = e.RowIndex;
                 string             p   = dg.Rows[c].Tag as string;
                 VSProject          vp  = vs.GetProjectbyName(p);
                 ArrayList          L   = ConfigurationManagerForm.GetProjectPlatform(vs);
                 NewPlatformConForm epf = new NewPlatformConForm(this);
                 epf.vp   = vp;
                 epf.Text = "New Platform Configurations";
                 epf.LoadPlatforms(L);
                 DialogResult r = epf.ShowDialog();
                 cd.Value = cmp.Items[2];
             }
         }
     }
 }
Esempio n. 3
0
        public async Task <IActionResult> OnGetAsync(int id)
        {
            var username = HttpContext.Session.GetString("_username");
            var usertype = HttpContext.Session.GetString("_usertype");
            var access   = new Access(username, "Coordinator");

            if (access.IsLogin())
            {
                if (access.IsAuthorize(usertype))
                {
                    Project = await _context.Project
                              .Where(p => p.DateDeleted == null)
                              .FirstOrDefaultAsync(p => p.ProjectId == id);

                    if (Project == null)
                    {
                        ErrorMessage = "Project not found";

                        return(RedirectToPage("/Coordinator/Project/Index"));
                    }

                    Epf = new EditProjectForm();

                    Supervisor = await _context.Supervisor
                                 .Where(s => s.DateDeleted == null)
                                 .FirstOrDefaultAsync(s => s.AssignedId == Project.SupervisorId);

                    SupervisorList = new SelectList(_context.Supervisor.Where(s => s.AssignedId != Project.SupervisorId).Where(s => s.AssignedId != Project.CoSupervisorId), "AssignedId", "SupervisorName");

                    ViewData["Type"] = Enumerable.ToList(new[] { "Edit Supervisor" })
                                       .Select(n => new SelectListItem
                    {
                        Value = n.ToString(),
                        Text  = n.ToString()
                    }).ToList();

                    return(Page());
                }
                else
                {
                    ErrorMessage = "Access Denied";
                    return(RedirectToPage($"/{usertype}/Index"));
                }
            }
            else
            {
                ErrorMessage = "Login Required";
                return(RedirectToPage("/Account/Login"));
            }
        }