Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         try
         {
             Employee loggedEmployee = (Employee)Session["MY_INFORMATION"];
             GetAllAccountCoursePermitPerEmployeeCommand cmd = new GetAllAccountCoursePermitPerEmployeeCommand(loggedEmployee);
             cmd.Execute();
             acpList = cmd.GetResults();
             List <AccountCoursePermit> activeAcp = new List <AccountCoursePermit>();
             foreach (AccountCoursePermit acp in acpList)
             {
                 if ((acp.status == 1))
                 {
                     activeAcp.Add(acp);
                 }
             }
             if (activeAcp.Count != 0)
             {
                 repCostCenter.DataSource = activeAcp;
                 repCostCenter.DataBind();
             }
             else
             {
                 Response.Redirect("~/site/employees/dashboard.aspx", false);
             }
         }
         catch (Exception ex)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "randomText", "errorSweetAlert('Ha ocurrido un error al cargar la información', 'error')", true);
         }
     }
 }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         if (Session["EMPLOYEE_EMAIL"] != null)
         {
             string employeeEmail = Session["EMPLOYEE_EMAIL"].ToString();
             try
             {
                 employee = new Employee(employeeEmail);
                 GetEmployeeInformationCommand cmd = new GetEmployeeInformationCommand(employee);
                 cmd.Execute();
                 consultedEmployee = cmd.GetResult();
                 if (consultedEmployee.status != 0)
                 {
                     string employeeName = consultedEmployee.firstName + " " + consultedEmployee.lastName;
                     Session["MY_INFORMATION"] = consultedEmployee;
                     employeeOptions.InnerHtml = "<i class=\"fa fa-user\"></i> " + employeeName + " <b class=\"caret\"></b>";
                     if ((consultedEmployee.organizationalUnit.Equals("Directiva")) && (consultedEmployee.positionName.Equals("Director")))
                     {
                         rrhhLi.Visible = true;
                         acpLi.Visible  = true;
                         stLi.Visible   = true;
                     }
                     else if ((consultedEmployee.organizationalUnit.Equals("Administración")) && (consultedEmployee.positionName.Equals("Gerente de Talento Humano")))
                     {
                         rrhhLi.Visible = true;
                         acpLi.Visible  = false;
                         stLi.Visible   = false;
                     }
                     else if ((consultedEmployee.organizationalUnit.Equals("Contraloría")) && (consultedEmployee.positionName.Equals("Contralor de Gestión")))
                     {
                         rrhhLi.Visible = true;
                         acpLi.Visible  = true;
                         stLi.Visible   = true;
                     }
                     else
                     {
                         rrhhLi.Visible = false;
                         acpLi.Visible  = false;
                         stLi.Visible   = false;
                     }
                     GetAllAccountCoursePermitPerEmployeeCommand cmdACP = new GetAllAccountCoursePermitPerEmployeeCommand(consultedEmployee);
                     cmdACP.Execute();
                     List <AccountCoursePermit> accountCoursePermits = cmdACP.GetResults();
                     myAcpLi.Visible = false;
                     if (accountCoursePermits.Count > 0)
                     {
                         myAcpLi.Visible = true;
                     }
                     OrganizationalUnit organizationalUnit = new OrganizationalUnit();
                     organizationalUnit.overseer = consultedEmployee.id;
                     GetOverseerUnitCommand _cmd = new GetOverseerUnitCommand(organizationalUnit);
                     _cmd.Execute();
                     organizationalUnit = _cmd.GetResult();
                     if (organizationalUnit.id != -1)
                     {
                         myUnitLi.Visible = true;
                     }
                     else
                     {
                         myUnitLi.Visible = false;
                     }
                 }
                 else
                 {
                     Session.Remove("EMPLOYEE_EMAIL");
                     Session.RemoveAll();
                     Response.Redirect("~/site/usermanagement/login.aspx", false);
                 }
             }
             catch (Exception ex)
             {
                 Session.Remove("EMPLOYEE_EMAIL");
                 Session.RemoveAll();
                 Response.Redirect("~/site/usermanagement/login.aspx", false);
             }
         }
         else
         {
             Session.Remove("EMPLOYEE_EMAIL");
             Session.RemoveAll();
             Response.Redirect("~/site/usermanagement/login.aspx", false);
         }
     }
 }