protected void gvEmployees_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "btnDelete")
     {
         ff.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
         int                 row         = Convert.ToInt32(e.CommandArgument);
         GridViewRow         selectedRow = gvEmployees.Rows[row];
         EmployeeWorkPackage empwp       = ff.EmployeeWorkPackages.Where(emp => emp.empId == (Convert.ToInt32(selectedRow.Cells[0].Text)) && emp.wpId == lblWPID2.Text).First();
         ff.EmployeeWorkPackages.DeleteOnSubmit(empwp);
         ff.SubmitChanges();
         populateManageWorkPackage();
     }
 }
Esempio n. 2
0
    protected void populateManageProject()
    {
        try
        {
            ff.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
            if (Session["projID"] == null)
            {
                Response.Redirect("~/PM/ProjectList.aspx");
            }
            if (Session["wpID"] != null)
            {
                Session["wpID"] = null;
            }
            if (divChangeAlloc.Visible == false)
            {
                divOriginalAlloc.Visible = true;
            }
            divChangeAlloc.Visible = false;
            lblProjID2.Text        = Session["projID"].ToString();

            //Get project name
            var proj =
                from p in ff.Projects
                where p.projId == Convert.ToInt32(Session["projID"])
                select p;
            lblProjName2.Text = proj.First().projName;
            try
            {
                lblProjectManager2.Text = ff.Employees
                                          .Where(a => a.empId == proj.First().manager).First().firstName + " " +
                                          ff.Employees
                                          .Where(a => a.empId == proj.First().manager).First().lastName;
            }
            catch (Exception e)
            {
                lblProjectManager2.Text = "";
            }
            if (proj.First().allocated_dollars == null)
            {
                lblAlloc2.Text = "UNDEFINED";
            }
            else
            {
                lblAlloc2.Text = proj.First().allocated_dollars.ToString();
            }
            if (proj.First().unallocated_dollars == null)
            {
                lblUnalloc2.Text = "UNDEFINED";
            }
            else
            {
                lblUnalloc2.Text = proj.First().unallocated_dollars.ToString();
            }

            getAllActiveWP();
            getAllUnactiveWP();
            identifyRole();
            string[] name  = lblProjectManager2.Text.Split(' ');
            var      query =
                (from emp in ff.Employees
                 where emp.firstName == name[0] && emp.lastName == name[1]
                 select new { emp.empId }).First();
            try
            {
                Roles.AddUserToRole(name[0].ToLower() + "_" + name[1].ToLower(), "ProjectManager");
            }
            catch (Exception exception)
            {
            }
            try
            {
                EmployeeProject ep = new EmployeeProject();
                ep.projId = Convert.ToInt32(lblProjID2.Text);
                ep.empId  = query.empId;
                ff.EmployeeProjects.InsertOnSubmit(ep);
                ff.SubmitChanges();
            }
            catch (Exception exception) {
            }
        }
        catch (Exception exception)
        {
            //lblException.Text = exception.StackTrace;
        }
    }